Browse Source

UI页面更新,部分逻辑调整

yuanrf 1 week ago
parent
commit
d344d413b4
2 changed files with 142 additions and 4 deletions
  1. 80 0
      travelExport/Home.Designer.cs
  2. 62 4
      travelExport/Home.cs

+ 80 - 0
travelExport/Home.Designer.cs

@@ -33,6 +33,12 @@
             this.btnOutput = new System.Windows.Forms.Button();
             this.btnOutputInfo = new System.Windows.Forms.Button();
             this.tripItemSelect = new System.Windows.Forms.ComboBox();
+            this.airLable = new System.Windows.Forms.Label();
+            this.hotelLable = new System.Windows.Forms.Label();
+            this.gwLabel = new System.Windows.Forms.Label();
+            this.airCheckbox = new System.Windows.Forms.CheckBox();
+            this.hotelCheckbox = new System.Windows.Forms.CheckBox();
+            this.gwCheckbox = new System.Windows.Forms.CheckBox();
             this.SuspendLayout();
             // 
             // comb_Delegation
@@ -81,11 +87,78 @@
             this.tripItemSelect.Size = new System.Drawing.Size(119, 20);
             this.tripItemSelect.TabIndex = 4;
             // 
+            // airLable
+            // 
+            this.airLable.AutoSize = true;
+            this.airLable.Location = new System.Drawing.Point(159, 74);
+            this.airLable.Name = "airLable";
+            this.airLable.Size = new System.Drawing.Size(95, 12);
+            this.airLable.TabIndex = 5;
+            this.airLable.Text = "机票数据条数:0";
+            this.airLable.Click += new System.EventHandler(this.airLable_Click);
+            // 
+            // hotelLable
+            // 
+            this.hotelLable.AutoSize = true;
+            this.hotelLable.Location = new System.Drawing.Point(159, 99);
+            this.hotelLable.Name = "hotelLable";
+            this.hotelLable.Size = new System.Drawing.Size(95, 12);
+            this.hotelLable.TabIndex = 6;
+            this.hotelLable.Text = "酒店数据条数:0";
+            // 
+            // gwLabel
+            // 
+            this.gwLabel.AutoSize = true;
+            this.gwLabel.Location = new System.Drawing.Point(159, 124);
+            this.gwLabel.Name = "gwLabel";
+            this.gwLabel.Size = new System.Drawing.Size(95, 12);
+            this.gwLabel.TabIndex = 7;
+            this.gwLabel.Text = "公务数据条数:0";
+            // 
+            // airCheckbox
+            // 
+            this.airCheckbox.AutoSize = true;
+            this.airCheckbox.Location = new System.Drawing.Point(0, 73);
+            this.airCheckbox.Name = "airCheckbox";
+            this.airCheckbox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+            this.airCheckbox.Size = new System.Drawing.Size(132, 16);
+            this.airCheckbox.TabIndex = 8;
+            this.airCheckbox.Text = "机票行程是否有数据";
+            this.airCheckbox.UseVisualStyleBackColor = true;
+            // 
+            // hotelCheckbox
+            // 
+            this.hotelCheckbox.AutoSize = true;
+            this.hotelCheckbox.Location = new System.Drawing.Point(24, 98);
+            this.hotelCheckbox.Name = "hotelCheckbox";
+            this.hotelCheckbox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+            this.hotelCheckbox.Size = new System.Drawing.Size(108, 16);
+            this.hotelCheckbox.TabIndex = 9;
+            this.hotelCheckbox.Text = "酒店是否有数据";
+            this.hotelCheckbox.UseVisualStyleBackColor = true;
+            // 
+            // gwCheckbox
+            // 
+            this.gwCheckbox.AutoSize = true;
+            this.gwCheckbox.Location = new System.Drawing.Point(24, 124);
+            this.gwCheckbox.Name = "gwCheckbox";
+            this.gwCheckbox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+            this.gwCheckbox.Size = new System.Drawing.Size(108, 16);
+            this.gwCheckbox.TabIndex = 10;
+            this.gwCheckbox.Text = "公务是否有数据";
+            this.gwCheckbox.UseVisualStyleBackColor = true;
+            // 
             // Home
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(497, 256);
+            this.Controls.Add(this.gwCheckbox);
+            this.Controls.Add(this.hotelCheckbox);
+            this.Controls.Add(this.airCheckbox);
+            this.Controls.Add(this.gwLabel);
+            this.Controls.Add(this.hotelLable);
+            this.Controls.Add(this.airLable);
             this.Controls.Add(this.tripItemSelect);
             this.Controls.Add(this.btnOutputInfo);
             this.Controls.Add(this.btnOutput);
@@ -95,6 +168,7 @@
             this.Text = "Home";
             this.Load += new System.EventHandler(this.Form1_Load);
             this.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
@@ -105,6 +179,12 @@
         private System.Windows.Forms.Button btnOutput;
         private System.Windows.Forms.Button btnOutputInfo;
         private System.Windows.Forms.ComboBox tripItemSelect;
+        private System.Windows.Forms.Label airLable;
+        private System.Windows.Forms.Label hotelLable;
+        private System.Windows.Forms.Label gwLabel;
+        private System.Windows.Forms.CheckBox airCheckbox;
+        private System.Windows.Forms.CheckBox hotelCheckbox;
+        private System.Windows.Forms.CheckBox gwCheckbox;
     }
 }
 

+ 62 - 4
travelExport/Home.cs

@@ -114,6 +114,11 @@ namespace travelExport
 
         private void Form1_Load(object sender, EventArgs e)
         {
+
+            airCheckbox.AutoCheck = false;
+            gwCheckbox.AutoCheck = false;
+            hotelCheckbox.AutoCheck = false;
+
             // 使用封装的方法执行查询
             soure = ExecuteDbContext(db => 
                 db.Grp_DelegationInfo
@@ -128,6 +133,7 @@ namespace travelExport
             comb_Delegation.DropDownHeight = 200;
             comb_Delegation.MouseClick += comb_Delegation_MouseClick;
             comb_Delegation.TextUpdate += comb_Delegation_TextUpdate;
+            comb_Delegation.SelectedValueChanged += comb_Delegation_SelectedValueChanged;
             FormBorderStyle = FormBorderStyle.FixedSingle;
             MinimizeBox = false;
             MaximizeBox = false;
@@ -139,6 +145,21 @@ namespace travelExport
 
         }
 
+        private void comb_Delegation_SelectedValueChanged(object sender, EventArgs e)
+        {
+            var diid = -1;
+            try
+            {
+                var dele = (comb_Delegation.SelectedItem as Grp_DelegationInfo);
+                diid = dele.Id;
+                QueryDbData(diid);
+            }
+            catch (Exception)
+            {
+                return;
+            }
+        }
+
         private void comb_Delegation_MouseClick(object sender, MouseEventArgs e)
         {
             comb_Delegation.Text = "";
@@ -165,7 +186,7 @@ namespace travelExport
 
             cb.SelectionStart = cb.Text.Length;  // 设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
             cb.Cursor = Cursors.Default; //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置
-            cb.MaxDropDownItems = 8; // 自动弹出下拉框            
+            cb.MaxDropDownItems = 8; // 自动弹出下拉框
         }
 
         private async void btnImport_Click(object sender, EventArgs e)
@@ -729,6 +750,41 @@ namespace travelExport
             threadExec.Start();
         }
 
+        private void QueryDbData(int diid)
+        {
+            Task.Run(() =>
+            {
+
+                using (var db = CreateDbContext())
+                {
+                    //机票行程数据
+                    var listAir = db.Air_TicketBlackCode
+                      .Where(x => x.DiId == diid && x.IsDel == 0)
+                      .ToList();
+
+                    //本团酒店信息
+                    var listht = db.Grp_HotelReservations.Where(x => x.DiId == diid && x.IsDel == 0).ToList();
+
+                    //公务出访信息
+                    var listgw = db.Res_OfficialActivities.Where(x => x.DiId == diid && x.IsDel == 0).ToList();
+
+                    // 更新 UI
+                    this.Invoke(new Action(() =>
+                    {
+                        airCheckbox.Checked = listAir.Count > 0;
+                        airLable.Text = $"机票数据条数:{listAir.Count}";
+
+                        hotelCheckbox.Checked = listht.Count > 0;
+                        hotelLable.Text = $"酒店数据条数:{listht.Count}";
+
+                        gwCheckbox.Checked = listgw.Count > 0;
+                        gwLabel.Text = $"公务数据条数:{listgw.Count}";
+                    }));
+                }
+
+            });
+        }
+
         private void execTemp(int tempValue, int diid, Grp_DelegationInfo di)
         {
             var dropItem = dropDownItem.FirstOrDefault(x => x.Id == tempValue);
@@ -1002,9 +1058,6 @@ namespace travelExport
                     {
                         using (var sw = db.Database.BeginTransaction())
                         {
-                            db.Grp_TravelList.RemoveRange(listTravel);
-                            db.SaveChanges();
-
                             var NewListTravel = new List<Grp_TravelList>();
                             var index = 1;
                             var stopCity = string.Empty;
@@ -1480,6 +1533,7 @@ namespace travelExport
                                                .Replace("\r\n10:30 公务活动;", string.Empty);
                             });
 
+                            db.Grp_TravelList.RemoveRange(db.Grp_TravelList.Where(x => x.IsDel == 0 && x.Diid == diid));
                             db.Grp_TravelList.AddRange(NewListTravel);
                             db.SaveChanges();
 
@@ -2570,6 +2624,10 @@ namespace travelExport
             return finalString.ToString();
         }
 
+        private void airLable_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 
     public class GoogleApiFormat