| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using UAS_Tools_HY.PublicMethods;
- namespace UAS_Tools_HY
- {
- public partial class Loading : Form
- {
- public Loading()
- {
- InitializeComponent();
- }
- public DataTable ResultData { get; private set; }
- string Filter;
- private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
- public Loading(string str)
- {
- InitializeComponent();
- Filter = str;
- }
- private async void Loading_Load(object sender, EventArgs e)
- {
- Msg.Visible = false;
- Confirm.Enabled = false;
- try
- {
- ResultData = ConnectDB.ExecuteSelect($@"SELECT count(*) num FROM g_packing_sncheck {Filter}");
- if(ResultData.Rows.Count > 0)
- {
- int allCount = Convert.ToInt32(ResultData.Rows[0]["num"].ToString());
- loadingBar.Visible = true;
- await Task.Run(() =>
- {
- /*ResultData = ConnectDB.ExecuteSelect($@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
- update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
- FROM g_packing_sncheck {Filter} ORDER BY sn,update_time desc");*/
- Task<DataTable> task = ConnectDB.ExecuteSelectCancellableSimpleAsync(
- sqlQuery: $@"SELECT sn dqsn,outbox_no dqoutbox_no,count dqcount,
- update_time dqupdate_time,update_name dqname,rule_name dqrule_name,rule_value dqrule_value
- FROM g_packing_sncheck {Filter} ORDER BY sn,update_time desc",
- cancellationToken: _cancellationTokenSource.Token);
- ResultData = task.Result;
- this.Invoke(new Action(() =>
- {
- loadingBar.Visible = false;
- Msg.Visible = true;
- Msg.Text = $"已查询到:{ResultData.Rows.Count}条数据";
- Confirm.Enabled = true;
- }));
- });
- }
- } catch(Exception ex) { }
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
- _cancellationTokenSource?.Dispose();
- _cancellationTokenSource = null;
- this.DialogResult = DialogResult.OK;
- this.Dispose();
- this.Close();
- GC.Collect();
- }
- private void Loading_FormClosing(object sender, FormClosingEventArgs e)
- {
- _cancellationTokenSource?.Dispose();
- _cancellationTokenSource = null;
- }
- }
- }
|