Compare commits
No commits in common. "ui/clinical-redesign" and "v1.0.26" have entirely different histories.
ui/clinica
...
v1.0.26
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -394,64 +394,6 @@ namespace Электронная_Фармация.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Отправляет свободный запрос («промт») ИИ-сервису и получает готовый
|
|
||||||
/// документ (Word/Excel). Токен покупателя уходит в теле — сервис ходит на
|
|
||||||
/// платформу от его имени и видит ТОЛЬКО его данные.
|
|
||||||
/// </summary>
|
|
||||||
public async Task<AiReportResult> GenerateAiReportAsync(string prompt, string format = "docx")
|
|
||||||
{
|
|
||||||
EnsureAuthenticated();
|
|
||||||
if (string.IsNullOrWhiteSpace(prompt))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Пустой запрос для ИИ.", nameof(prompt));
|
|
||||||
}
|
|
||||||
|
|
||||||
var aiBase = AppConfig.AiBaseUrl.TrimEnd('/');
|
|
||||||
var fullUrl = new Uri(new Uri(aiBase + "/"), "generate").ToString();
|
|
||||||
var payload = new AiReportRequest { Prompt = prompt, Token = _token, Format = format };
|
|
||||||
var requestJson = JsonSerializer.Serialize(payload, JsonOptions);
|
|
||||||
var stopwatch = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
AppDebugLog.ApiRequest("POST", fullUrl, extra: $"ai prompt len={prompt.Length}, format={format}");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, fullUrl))
|
|
||||||
{
|
|
||||||
httpRequest.Content = new StringContent(requestJson, Encoding.UTF8, "application/json");
|
|
||||||
var response = await _httpClient.SendAsync(httpRequest);
|
|
||||||
stopwatch.Stop();
|
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var errBody = await response.Content.ReadAsStringAsync();
|
|
||||||
AppDebugLog.ApiHttpError("POST", fullUrl, (int)response.StatusCode, errBody, "ai-report");
|
|
||||||
var detail = TryDeserializeError(errBody)?.Error ?? errBody;
|
|
||||||
throw new HttpRequestException($"ИИ-сервис вернул {(int)response.StatusCode}: {detail}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var bytes = await response.Content.ReadAsByteArrayAsync();
|
|
||||||
var fileName = response.Content.Headers.ContentDisposition?.FileNameStar
|
|
||||||
?? response.Content.Headers.ContentDisposition?.FileName
|
|
||||||
?? (format == "xlsx" ? "Отчёт.xlsx" : "Отчёт.docx");
|
|
||||||
fileName = fileName.Trim('"');
|
|
||||||
AppDebugLog.ApiResponse("POST", fullUrl, (int)response.StatusCode, stopwatch.ElapsedMilliseconds,
|
|
||||||
$"ai file={fileName}, {bytes.Length} bytes");
|
|
||||||
return new AiReportResult { Content = bytes, FileName = fileName };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (HttpRequestException)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
stopwatch.Stop();
|
|
||||||
throw WrapNetworkError(ex, "формирование ИИ-отчёта");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<BuyerLocationDto>> GetBuyerLocationsAsync()
|
public async Task<List<BuyerLocationDto>> GetBuyerLocationsAsync()
|
||||||
{
|
{
|
||||||
EnsureAuthenticated();
|
EnsureAuthenticated();
|
||||||
@ -836,24 +778,6 @@ namespace Электронная_Фармация.Classes
|
|||||||
public List<BuyerOrderListItemDto> Orders { get; set; }
|
public List<BuyerOrderListItemDto> Orders { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AiReportRequest
|
|
||||||
{
|
|
||||||
[JsonPropertyName("prompt")]
|
|
||||||
public string Prompt { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("token")]
|
|
||||||
public string Token { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("format")]
|
|
||||||
public string Format { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class AiReportResult
|
|
||||||
{
|
|
||||||
public byte[] Content { get; set; }
|
|
||||||
public string FileName { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class BuyerReportResponse
|
public sealed class BuyerReportResponse
|
||||||
{
|
{
|
||||||
[JsonPropertyName("lines")]
|
[JsonPropertyName("lines")]
|
||||||
|
|||||||
@ -17,10 +17,6 @@ namespace Электронная_Фармация.Classes
|
|||||||
public const string DefaultInstallerDownloadUrl = "https://cdn.24pharmdata.ru/ElfisaPharmacy-Setup.exe";
|
public const string DefaultInstallerDownloadUrl = "https://cdn.24pharmdata.ru/ElfisaPharmacy-Setup.exe";
|
||||||
private const string LegacyApiBaseUrl = "http://195.34.241.84:9988";
|
private const string LegacyApiBaseUrl = "http://195.34.241.84:9988";
|
||||||
private const string ApiBaseUrlEnvVar = "ELF_API_BASE_URL";
|
private const string ApiBaseUrlEnvVar = "ELF_API_BASE_URL";
|
||||||
/// <summary>ИИ-сервис отчётов (проксируется Caddy на Мак-мини). Можно переопределить
|
|
||||||
/// переменной ELF_AI_BASE_URL, напр. http://192.168.95.116:8808 для теста по локальной сети.</summary>
|
|
||||||
public const string DefaultAiBaseUrl = "https://24pharmdata.ru/ai";
|
|
||||||
private const string AiBaseUrlEnvVar = "ELF_AI_BASE_URL";
|
|
||||||
private static bool _sqliteInteropPrepared;
|
private static bool _sqliteInteropPrepared;
|
||||||
private static readonly object _sqliteInteropLock = new object();
|
private static readonly object _sqliteInteropLock = new object();
|
||||||
|
|
||||||
@ -115,21 +111,6 @@ namespace Электронная_Фармация.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Базовый URL ИИ-сервиса отчётов.</summary>
|
|
||||||
public static string AiBaseUrl
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var fromEnv = Environment.GetEnvironmentVariable(AiBaseUrlEnvVar);
|
|
||||||
if (!string.IsNullOrWhiteSpace(fromEnv))
|
|
||||||
{
|
|
||||||
return fromEnv.Trim().TrimEnd('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefaultAiBaseUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string NormalizeApiBaseUrl(string url)
|
public static string NormalizeApiBaseUrl(string url)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
|
|||||||
@ -32,6 +32,6 @@ using System.Runtime.InteropServices;
|
|||||||
// пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ
|
// пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ
|
||||||
// пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "*", пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅ:
|
// пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "*", пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅ:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.29.0")]
|
[assembly: AssemblyVersion("1.0.26.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.29.0")]
|
[assembly: AssemblyFileVersion("1.0.26.0")]
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -25,71 +23,26 @@ namespace Электронная_Фармация.UserControls
|
|||||||
private readonly Button _btnBuild;
|
private readonly Button _btnBuild;
|
||||||
private readonly Label _lblTotals;
|
private readonly Label _lblTotals;
|
||||||
private readonly DataGridView _grid;
|
private readonly DataGridView _grid;
|
||||||
private readonly TextBox _txtPrompt;
|
|
||||||
private readonly ComboBox _cboFormat;
|
|
||||||
private readonly Button _btnAi;
|
|
||||||
private List<BuyerReportLineDto> _lines = new List<BuyerReportLineDto>();
|
private List<BuyerReportLineDto> _lines = new List<BuyerReportLineDto>();
|
||||||
|
|
||||||
// Палитра под общий стиль приложения (бирюза шапки #0F766E).
|
|
||||||
private static readonly Color Accent = Color.FromArgb(15, 118, 110);
|
|
||||||
private static readonly Color AccentHover = Color.FromArgb(13, 148, 136);
|
|
||||||
private static readonly Color TextMain = Color.FromArgb(31, 41, 55);
|
|
||||||
private static readonly Color TextMuted = Color.FromArgb(120, 128, 134);
|
|
||||||
private static readonly Color RowAlt = Color.FromArgb(247, 250, 250);
|
|
||||||
private static readonly Color SelBack = Color.FromArgb(178, 240, 230);
|
|
||||||
private static readonly Color GridLine = Color.FromArgb(230, 234, 236);
|
|
||||||
|
|
||||||
private static void StylePrimaryButton(Button b)
|
|
||||||
{
|
|
||||||
b.FlatStyle = FlatStyle.Flat;
|
|
||||||
b.FlatAppearance.BorderSize = 0;
|
|
||||||
b.FlatAppearance.MouseOverBackColor = AccentHover;
|
|
||||||
b.FlatAppearance.MouseDownBackColor = AccentHover;
|
|
||||||
b.BackColor = Accent;
|
|
||||||
b.ForeColor = Color.White;
|
|
||||||
b.Cursor = Cursors.Hand;
|
|
||||||
b.Font = new Font("Segoe UI", 9F, FontStyle.Regular);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UCReports()
|
public UCReports()
|
||||||
{
|
{
|
||||||
Dock = DockStyle.Fill;
|
Dock = DockStyle.Fill;
|
||||||
|
|
||||||
var uiFont = new Font("Segoe UI", 9F);
|
var top = new Panel { Dock = DockStyle.Top, Height = 46 };
|
||||||
var top = new Panel { Dock = DockStyle.Top, Height = 100, BackColor = Color.White };
|
|
||||||
|
|
||||||
// --- строка 1: период + готовый отчёт по данным ---
|
var lblFrom = new Label { Text = "С", AutoSize = true, Left = 10, Top = 15 };
|
||||||
var lblFrom = new Label { Text = "С", AutoSize = true, Left = 12, Top = 17, ForeColor = TextMain, Font = uiFont };
|
_dtFrom = new DateTimePicker { Format = DateTimePickerFormat.Short, Width = 110, Left = 30, Top = 11, Value = DateTime.Today.AddMonths(-1) };
|
||||||
_dtFrom = new DateTimePicker { Format = DateTimePickerFormat.Short, Width = 112, Left = 32, Top = 13, Value = DateTime.Today.AddMonths(-1), Font = uiFont };
|
var lblTo = new Label { Text = "по", AutoSize = true, Left = 146, Top = 15 };
|
||||||
var lblTo = new Label { Text = "по", AutoSize = true, Left = 150, Top = 17, ForeColor = TextMain, Font = uiFont };
|
_dtTo = new DateTimePicker { Format = DateTimePickerFormat.Short, Width = 110, Left = 172, Top = 11, Value = DateTime.Today };
|
||||||
_dtTo = new DateTimePicker { Format = DateTimePickerFormat.Short, Width = 112, Left = 176, Top = 13, Value = DateTime.Today, Font = uiFont };
|
_cboReport = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Width = 190, Left = 292, Top = 11 };
|
||||||
_cboReport = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Width = 190, Left = 298, Top = 13, Font = uiFont, FlatStyle = FlatStyle.Flat };
|
|
||||||
_cboReport.Items.AddRange(new object[] { "Мои заказы", "По поставщикам", "По товарам", "По аптекам" });
|
_cboReport.Items.AddRange(new object[] { "Мои заказы", "По поставщикам", "По товарам", "По аптекам" });
|
||||||
_cboReport.SelectedIndex = 0;
|
_cboReport.SelectedIndex = 0;
|
||||||
_btnBuild = new Button { Text = "Сформировать", Left = 498, Top = 12, Width = 140, Height = 28 };
|
_btnBuild = new Button { Text = "Сформировать", Left = 492, Top = 10, Width = 120, Height = 26 };
|
||||||
_lblTotals = new Label { AutoSize = true, Left = 654, Top = 17, Text = "", ForeColor = Accent, Font = new Font("Segoe UI", 9F, FontStyle.Bold) };
|
_lblTotals = new Label { AutoSize = true, Left = 624, Top = 15, Text = "" };
|
||||||
|
|
||||||
top.Controls.AddRange(new Control[] { lblFrom, _dtFrom, lblTo, _dtTo, _cboReport, _btnBuild, _lblTotals });
|
top.Controls.AddRange(new Control[] { lblFrom, _dtFrom, lblTo, _dtTo, _cboReport, _btnBuild, _lblTotals });
|
||||||
|
|
||||||
// --- строка 2: свободный запрос к ИИ (клиент пишет словами -> Word/Excel) ---
|
|
||||||
var lblAi = new Label { Text = "Запрос ИИ:", AutoSize = true, Left = 12, Top = 61, ForeColor = TextMain, Font = uiFont };
|
|
||||||
_txtPrompt = new TextBox { Left = 92, Top = 57, Width = 470, Font = uiFont, BorderStyle = BorderStyle.FixedSingle };
|
|
||||||
_cboFormat = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Left = 574, Top = 57, Width = 92, Font = uiFont, FlatStyle = FlatStyle.Flat };
|
|
||||||
_cboFormat.Items.AddRange(new object[] { "Word", "Excel" });
|
|
||||||
_cboFormat.SelectedIndex = 0;
|
|
||||||
_btnAi = new Button { Text = "🤖 Сформировать ИИ", Left = 676, Top = 56, Width = 170, Height = 28 };
|
|
||||||
_btnAi.Text = "Сформировать ИИ"; // без эмодзи (криво рендерился в кнопке)
|
|
||||||
var lblHint = new Label { AutoSize = true, Left = 92, Top = 83, ForeColor = TextMuted, Font = new Font("Segoe UI", 8F),
|
|
||||||
Text = "Напр.: «закупки по поставщикам за июль», «топ товаров за 3 месяца», «заказы у Farmsnab»" };
|
|
||||||
|
|
||||||
StylePrimaryButton(_btnBuild);
|
|
||||||
StylePrimaryButton(_btnAi);
|
|
||||||
|
|
||||||
var tip = new ToolTip();
|
|
||||||
tip.SetToolTip(_txtPrompt, "Опишите нужный отчёт словами — ИИ подберёт тип, период и соберёт документ.");
|
|
||||||
|
|
||||||
top.Controls.AddRange(new Control[] { lblAi, _txtPrompt, _cboFormat, _btnAi, lblHint });
|
|
||||||
|
|
||||||
_grid = new DataGridView
|
_grid = new DataGridView
|
||||||
{
|
{
|
||||||
Dock = DockStyle.Fill,
|
Dock = DockStyle.Fill,
|
||||||
@ -100,91 +53,14 @@ namespace Электронная_Фармация.UserControls
|
|||||||
RowHeadersVisible = false,
|
RowHeadersVisible = false,
|
||||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
||||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
|
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
|
||||||
BorderStyle = BorderStyle.None,
|
BorderStyle = BorderStyle.None
|
||||||
BackgroundColor = Color.White,
|
|
||||||
EnableHeadersVisualStyles = false,
|
|
||||||
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None,
|
|
||||||
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing,
|
|
||||||
ColumnHeadersHeight = 34,
|
|
||||||
CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal,
|
|
||||||
GridColor = GridLine,
|
|
||||||
RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None
|
|
||||||
};
|
};
|
||||||
_grid.ColumnHeadersDefaultCellStyle.BackColor = Accent;
|
|
||||||
_grid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
|
|
||||||
_grid.ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI", 9.5F, FontStyle.Bold);
|
|
||||||
_grid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
|
||||||
_grid.ColumnHeadersDefaultCellStyle.Padding = new Padding(6, 0, 0, 0);
|
|
||||||
_grid.DefaultCellStyle.Font = new Font("Segoe UI", 9.5F);
|
|
||||||
_grid.DefaultCellStyle.ForeColor = TextMain;
|
|
||||||
_grid.DefaultCellStyle.SelectionBackColor = SelBack;
|
|
||||||
_grid.DefaultCellStyle.SelectionForeColor = TextMain;
|
|
||||||
_grid.DefaultCellStyle.Padding = new Padding(6, 0, 6, 0);
|
|
||||||
_grid.AlternatingRowsDefaultCellStyle.BackColor = RowAlt;
|
|
||||||
_grid.RowTemplate.Height = 30;
|
|
||||||
|
|
||||||
Controls.Add(_grid);
|
Controls.Add(_grid);
|
||||||
Controls.Add(top);
|
Controls.Add(top);
|
||||||
|
|
||||||
_btnBuild.Click += async (_, __) => await LoadAsync();
|
_btnBuild.Click += async (_, __) => await LoadAsync();
|
||||||
_cboReport.SelectedIndexChanged += (_, __) => Render();
|
_cboReport.SelectedIndexChanged += (_, __) => Render();
|
||||||
_btnAi.Click += async (_, __) => await BuildAiAsync();
|
|
||||||
_txtPrompt.KeyDown += async (_, e) =>
|
|
||||||
{
|
|
||||||
if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; await BuildAiAsync(); }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task BuildAiAsync()
|
|
||||||
{
|
|
||||||
var prompt = _txtPrompt.Text?.Trim();
|
|
||||||
if (string.IsNullOrWhiteSpace(prompt))
|
|
||||||
{
|
|
||||||
ToastNotification.ShowError("Введите запрос для ИИ.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var token = Settings.Default.stringToken;
|
|
||||||
if (string.IsNullOrWhiteSpace(token))
|
|
||||||
{
|
|
||||||
ToastNotification.ShowError("Не найден токен авторизации. Войдите в систему.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_btnAi.Enabled = false;
|
|
||||||
_btnAi.Text = "Формирую…";
|
|
||||||
|
|
||||||
var fmt = _cboFormat.SelectedIndex == 1 ? "xlsx" : "docx";
|
|
||||||
var client = new ApiClient();
|
|
||||||
client.SetToken(token);
|
|
||||||
var result = await client.GenerateAiReportAsync(prompt, fmt);
|
|
||||||
|
|
||||||
var dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
||||||
var safe = string.Join("_", (result.FileName ?? "Отчёт").Split(Path.GetInvalidFileNameChars()));
|
|
||||||
var path = Path.Combine(dir, safe);
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
var name = Path.GetFileNameWithoutExtension(safe);
|
|
||||||
var ext = Path.GetExtension(safe);
|
|
||||||
path = Path.Combine(dir, $"{name}_{DateTime.Now:yyyyMMdd_HHmmss}{ext}");
|
|
||||||
}
|
|
||||||
|
|
||||||
File.WriteAllBytes(path, result.Content);
|
|
||||||
ToastNotification.ShowCustom("Отчёт готов, открываю…", Color.SeaGreen, Color.White);
|
|
||||||
Process.Start(new ProcessStartInfo { FileName = path, UseShellExecute = true });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
AppDebugLog.Error("UCReports", "Ошибка ИИ-отчёта", ex);
|
|
||||||
ToastNotification.ShowError("Ошибка ИИ-отчёта: " + ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_btnAi.Enabled = true;
|
|
||||||
_btnAi.Text = "🤖 Сформировать ИИ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadAsync()
|
private async Task LoadAsync()
|
||||||
@ -293,21 +169,9 @@ namespace Электронная_Фармация.UserControls
|
|||||||
_grid.DataSource = dt;
|
_grid.DataSource = dt;
|
||||||
foreach (DataGridViewColumn c in _grid.Columns)
|
foreach (DataGridViewColumn c in _grid.Columns)
|
||||||
{
|
{
|
||||||
bool numeric = c.Name == "Сумма" || c.Name == "Кол-во" || c.Name == "Позиций" || c.Name == "Заказов";
|
|
||||||
if (c.Name == "Сумма") c.DefaultCellStyle.Format = "N2";
|
if (c.Name == "Сумма") c.DefaultCellStyle.Format = "N2";
|
||||||
if (c.Name == "Кол-во") c.DefaultCellStyle.Format = "N3";
|
if (c.Name == "Кол-во") c.DefaultCellStyle.Format = "N3";
|
||||||
if (numeric)
|
if (c.Name == "Позиций" || c.Name == "Заказов") c.Width = 80;
|
||||||
{
|
|
||||||
c.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
|
||||||
c.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
|
|
||||||
c.HeaderCell.Style.Padding = new Padding(0, 0, 6, 0);
|
|
||||||
}
|
|
||||||
// Узкие числовые колонки, широкие — текстовые (Fill распределит по весу).
|
|
||||||
if (c.Name == "Позиций" || c.Name == "Заказов") c.FillWeight = 45;
|
|
||||||
else if (c.Name == "Сумма" || c.Name == "Кол-во") c.FillWeight = 70;
|
|
||||||
else if (c.Name == "Дата" || c.Name == "Статус" || c.Name == "Код") c.FillWeight = 75;
|
|
||||||
else if (c.Name == "Номер") c.FillWeight = 90;
|
|
||||||
else c.FillWeight = 150; // Поставщик / Товар / Аптека
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int orders = _lines.Select(l => l.OrderID).Distinct().Count();
|
int orders = _lines.Select(l => l.OrderID).Distinct().Count();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user