Persist last successful login only, show active pharmacy in the status bar, and keep settings compact at the bottom-right. Co-authored-by: Cursor <cursoragent@cursor.com>
96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
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 [Грузополучатель],
|
||
ifnull(LocationId, '') as [Location ID],
|
||
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;
|
||
}
|
||
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();
|
||
}
|
||
}
|
||
}
|