elfisa-pharmacy/src/ElectronicPharmacy/HelpForms/HF_Comment.cs
Magomed d1740d49bf Initial commit: Электронная Фармация desktop client.
WinForms app with Elfisa.UI, API integration, order workflow, invoices/refusals sync, and production-ready fixes from the desktop roadmap.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 12:25:38 +03:00

87 lines
3.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.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;
using Электроннаяармация.UserControls;
namespace Электроннаяармация.HelpForms
{
using Электроннаяармация.Classes;
public partial class HF_Comment : Form
{
public FOrders ParentForm { get; set; }
string _OrderNumber;
string _idOrder;
public HF_Comment(string OrderNumber, string Id_Order)
{
InitializeComponent();
_OrderNumber = OrderNumber;
_idOrder = Id_Order;
Электроннаяармация.Classes.UiThemeHelper.ApplyToControlTree(this);
this.Text = $"Добавить комментарий к заказу {_OrderNumber}";
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnAddComment_Click(object sender, EventArgs e)
{
if (rtxtComment.Text.Replace(" ", "") != "")
{
string connectionStringToLocalDB = AppConfig.SqliteConnectionString;
using (SQLiteConnection conAddComment = new SQLiteConnection(connectionStringToLocalDB))
{
string qShowMeStatusOrder = $"select OrderState from Orders where Id_Order = '{_idOrder}'";
string qAddComment = $"update Orders set Comment = '{rtxtComment.Text}' where Id_Order = '{_idOrder}'";
try
{
conAddComment.Open();
SQLiteCommand cmdShowMeOrderStatus = new SQLiteCommand(qShowMeStatusOrder, conAddComment);
string OrderState = cmdShowMeOrderStatus.ExecuteScalar().ToString();
if (OrderState == "НОВЫЙ")
{
SQLiteCommand cmdAddComment = new SQLiteCommand(qAddComment, conAddComment);
cmdAddComment.ExecuteNonQuery();
}
else
{
UiDialogs.ShowError("Добавить комментарий можно только к заказу со статусом НОВЫЙ.", "Ошибка", this);
}
this.Close();
}
catch(Exception ex)
{
UiDialogs.ShowError($"Ошибка при добавлении комментария к заказу {_OrderNumber}.\n{ex}", "Ошибка", this);
}
finally
{
conAddComment.Close();
}
}
}
else
{
UiDialogs.ShowError("Комментарий не заполнен", "Ошибка ввода", this);
}
}
}
}