diff --git a/ButcherWeight/WeightForm.Designer.cs b/ButcherWeight/WeightForm.Designer.cs index 720ab04..a21cda1 100644 --- a/ButcherWeight/WeightForm.Designer.cs +++ b/ButcherWeight/WeightForm.Designer.cs @@ -635,6 +635,7 @@ this.penMoneyInput.Font = new System.Drawing.Font("宋体", 14F); this.penMoneyInput.Location = new System.Drawing.Point(854, 89); this.penMoneyInput.Name = "penMoneyInput"; + this.penMoneyInput.ReadOnly = true; this.penMoneyInput.Size = new System.Drawing.Size(135, 29); this.penMoneyInput.TabIndex = 15; this.penMoneyInput.TextChanged += new System.EventHandler(this.penMoneyInput_TextChanged); @@ -669,6 +670,7 @@ this.penWeightInput.Font = new System.Drawing.Font("宋体", 14F); this.penWeightInput.Location = new System.Drawing.Point(854, 9); this.penWeightInput.Name = "penWeightInput"; + this.penWeightInput.ReadOnly = true; this.penWeightInput.Size = new System.Drawing.Size(135, 29); this.penWeightInput.TabIndex = 0; this.penWeightInput.TextChanged += new System.EventHandler(this.penMoneyInput_TextChanged); @@ -818,6 +820,7 @@ this.farmerGrid.Size = new System.Drawing.Size(1249, 113); this.farmerGrid.TabIndex = 8; this.farmerGrid.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.farmerGrid_CellMouseDown); + this.farmerGrid.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.farmerGrid_CellValueChanged); // // F_ID // diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index 12ab11b..40cb6fb 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -49,7 +49,6 @@ namespace ButcherWeight uDatePicker1.Date = DateTime.Today; supplierSelect.Init("BaseInfoRpc/GetSupplierList"); purchaseTypeSelect.Init("BaseInfoRpc/GetPurchaseTypeList"); - purchaseTypeSelect.SelectedIndexChanged += PurchaseTypeSelectIndexChange; carSelect.Init("BaseInfoRpc/GetCarList"); liveVarietiesSelect.Init("BaseInfoRpc/GetLiveVarietiesList"); employeeSelect.Init("BaseInfoRpc/GetEmployeeList"); @@ -80,24 +79,6 @@ namespace ButcherWeight }; } - private void PurchaseTypeSelectIndexChange(object sender, EventArgs e) - { - var selectObj = purchaseTypeSelect.SelectedItem as WordPair; - if (selectObj.DisplayName == "社会") - { - penMoneyInput.Text = string.Empty; - penWeightInput.Text = string.Empty; - penPriceInput.Text = string.Empty; - penMoneyInput.ReadOnly = true; - penWeightInput.ReadOnly = true; - } - else - { - penMoneyInput.ReadOnly = false; - penWeightInput.ReadOnly = false; - } - } - private void WeightForm_Load(object sender, EventArgs e) { BindWeightBill(); @@ -262,7 +243,7 @@ namespace ButcherWeight Dmo.Farmer_Name = info.Name; Dmo.Farmer_IDCard = info.IDCard; Dmo.Farmer_Tel = info.Tel; - Dmo.Farmer_Address = info.Address; + Dmo.Farmer_Address = info.Address; if (_farmerDetails.Any(x => x.Farmer_ID == detail.Farmer_ID)) return; detail.Farmer_Name = farmerSelect.DisplayValue; @@ -507,12 +488,6 @@ namespace ButcherWeight farmerGrid.ClearSelection(); farmerGrid.Rows[e.RowIndex].Selected = true; } - ////只选中一行时设置活动单元格 - //if (weightGrid.SelectedRows.Count == 1) - //{ - // weightGrid.CurrentCell = weightGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]; - //} - //弹出操作菜单 farmerMenu.Show(MousePosition.X, MousePosition.Y); } } @@ -624,5 +599,19 @@ namespace ButcherWeight else bankAccountLabel.Text = WeightBillRpc.GetSupplierBankAccount(supplierSelect.LongValue.Value); } + + private void farmerGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex < 0) + return; + if (e.ColumnIndex == 6) + { + penWeightInput.Text = (farmerGrid.DataSource as List).Sum(x => x.Weight ?? 0).ToString("#0.######"); + } + else if (e.ColumnIndex == 7) + { + penMoneyInput.Text = (farmerGrid.DataSource as List).Sum(x => x.Money ?? 0).ToString("#0.######"); + } + } } } \ No newline at end of file