elfisa-pharmacy/src/ElectronicPharmacy/HelpForms/HFConsignees.cs
Magomed d68155b8ef Persist per-pharmacy markup percent and simplify consignee picker UI.
Store client markup on each Consignee so it survives restarts and price refresh; show only name and address in the selection dialog with a wider window.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 14:53:28 +03:00

105 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Data;
using System.Data.SQLite;
using System.Windows.Forms;
using Электроннаяармация;
using Электроннаяармация.Classes;
namespace Электроннаяармация.HelpForms
{
public partial class HFConsignees : Form
{
public new ElectroPharmacy ParentForm { get; set; }
public HFConsignees()
{
InitializeComponent();
}
void loadingDataAboutConsignees()
{
string connectionStringToLocalDB = AppConfig.SqliteConnectionString;
using (SQLiteConnection conConsigneesList = new SQLiteConnection(connectionStringToLocalDB))
{
try
{
conConsigneesList.Open();
string qShowMeConsigneesList = @"
select ConsigneesName as [Грузополучатель],
ConsigneesAddress as [Адрес]
from Consignees
order by ConsigneesUseAsDefault desc, ConsigneesName";
SQLiteCommand cmdShowMeConsigneesList = new SQLiteCommand(qShowMeConsigneesList, conConsigneesList);
SQLiteDataAdapter daConsigneesList = new SQLiteDataAdapter(cmdShowMeConsigneesList);
DataTable tableConsignees = new DataTable();
daConsigneesList.Fill(tableConsignees);
dgvConsignees.DataSource = tableConsignees;
if (dgvConsignees.Columns.Contains("Грузополучатель"))
{
dgvConsignees.Columns["Грузополучатель"].FillWeight = 45;
}
if (dgvConsignees.Columns.Contains("Адрес"))
{
dgvConsignees.Columns["Адрес"].FillWeight = 55;
}
}
catch (Exception ex)
{
UiDialogs.ShowError($"При загрузке списка получателей возникла ошибка.\n{ex}", "Ошибка", this);
}
}
}
private void btnCloseThis_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void btnConfirmConsignee_Click(object sender, EventArgs e)
{
if (dgvConsignees.CurrentRow == null)
{
UiDialogs.ShowInfo("Выберите грузополучателя из списка.", "Грузополучатель", this);
return;
}
string consigneesName = dgvConsignees.CurrentRow.Cells[0].Value?.ToString();
if (string.IsNullOrWhiteSpace(consigneesName))
{
UiDialogs.ShowInfo("Выберите грузополучателя из списка.", "Грузополучатель", this);
return;
}
var locationId = ConsigneeHelper.GetLocationIdByName(consigneesName);
if (string.IsNullOrWhiteSpace(locationId))
{
var ask = UiDialogs.ConfirmYesNo(
$"У аптеки «{consigneesName}» не задан Location ID.\nПродолжить без него? Заказы этой аптеки нельзя будет отправить, пока ID не заполните.",
"Location ID",
this);
if (ask != DialogResult.Yes)
{
return;
}
}
ConsigneeHelper.SetActiveConsignee(consigneesName);
ParentForm?.showMePriceList(consigneesName);
DialogResult = DialogResult.OK;
Close();
}
private void HFConsignees_Load(object sender, EventArgs e)
{
UiThemeHelper.ApplyToControlTree(this);
loadingDataAboutConsignees();
}
}
}