elfisa-pharmacy/src/ElectronicPharmacy/HelpForms/HF_LocationId.cs
Magomed a6601567f2 Improve order UX and harden API debugging.
Prompt for Location ID after login, move cart delete there, refine price-list Backspace navigation, and log every API failure with stack and response body.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 16:31:00 +03:00

63 lines
2.1 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.Drawing;
using System.Windows.Forms;
using Elfisa.UI.Helpers;
using Elfisa.UI.Theming;
using Электроннаяармация.Classes;
using Электроннаяармация.Properties;
namespace Электроннаяармация.HelpForms
{
public partial class HF_LocationId : Form
{
public HF_LocationId()
{
InitializeComponent();
Shown += (_, __) => WindowChromeHelper.ApplyTitleBarTheme(this, ThemeManager.Colors);
}
/// <summary>
/// Показывает диалог Location ID. Возвращает true, если значение сохранено.
/// </summary>
public static bool PromptAndSave(IWin32Window owner)
{
using (var form = new HF_LocationId())
{
UiThemeHelper.ApplyToControlTree(form);
return form.ShowDialog(owner) == DialogResult.OK;
}
}
private void HF_LocationId_Load(object sender, EventArgs e)
{
UiThemeHelper.ApplyToControlTree(this);
WindowChromeHelper.ApplyDialogChrome(this, panelHeader, lblTitle);
txtLocationId.Text = Settings.Default.LocationId ?? string.Empty;
txtLocationId.SelectAll();
txtLocationId.Focus();
}
private void btnSave_Click(object sender, EventArgs e)
{
var locationId = (txtLocationId.Text ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
UiDialogs.ShowError("Укажите Location ID торговой точки.", "Location ID", this);
txtLocationId.Focus();
return;
}
AppConfig.SetLocationId(locationId);
AppDebugLog.Info("Auth", $"LocationId сохранён: {locationId}");
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}