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>
87 lines
3.1 KiB
C#
87 lines
3.1 KiB
C#
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);
|
||
}
|
||
}
|
||
}
|
||
}
|