private void MenuItem_Click(object sender, RoutedEventArgs e) { #region 除方法 if (this.DataGrid.SelectedCells.Count != 0) { ProductManagement_PickingDetailModel m = DataGrid.SelectedCells[0].Item as ProductManagement_PickingDetailModel; CellId = m.Id; if (!m.ProductID.Equals(Guid.Empty)) { if (MessageBox.Show("是否删除此行数据?", "确认信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { bool flag = new DeliveryProcessInConsole().DeleteDetail(m); if (!flag) { MessageBox.Show("删除不成功!未找到对应数据!"); } } else { return; } } m.Number = ""; m.Name = ""; m.QuantityA = 0; m.QuantityB = 0; m.QuantityC = 0; m.QuantityD = 0; } #endregion }
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { ProductManagement_PickingDetailModel model = this.DataGrid.SelectedCells[0].Item as ProductManagement_PickingDetailModel; string newValue = (e.EditingElement as TextBox).Text.Trim(); string Header = e.Column.Header.ToString(); if (Header == "编号") { if (ComboBox_Processors.SelectedIndex == 0) { MessageBox.Show("请选择抛光户!"); return; } int d = 0; if (string.IsNullOrEmpty(newValue)) { return; } ProductManagement_PickingDetailModel m = new ProductManagement_PickingDetailModel(); new DeliveryProcessInConsole().ReadProductInfo((Guid)ComboBox_Processors.SelectedValue, newValue, out m, out d); if (string.IsNullOrEmpty(m.Name)) { MessageBox.Show("找不到编号对应的品名"); data[data.IndexOf(model)].Number = ""; DataGrid.CurrentCell = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[0]); return; } DataGrid.CurrentCell = new DataGridCellInfo(DataGrid.SelectedCells[0].Item, DataGrid.Columns[2]); data[data.IndexOf(model)].ProductID = m.ProductID; data[data.IndexOf(model)].Name = m.Name; data[data.IndexOf(model)].QuantityC = d; } else if (Header.Equals("合格数量")) { int temp = 0; int.TryParse(newValue, out temp); data[data.IndexOf(model)].QuantityA = temp; data[data.IndexOf(model)].QuantityD = data[data.IndexOf(model)].QuantityC - (temp + data[data.IndexOf(model)].QuantityB); } else if (Header.Equals("损坏数量")) { int temp = 0; int.TryParse(newValue, out temp); data[data.IndexOf(model)].QuantityB = temp; data[data.IndexOf(model)].QuantityD = data[data.IndexOf(model)].QuantityC - (temp + data[data.IndexOf(model)].QuantityA); } }
internal bool ReadProductInfo(Guid processorID, string Number, out ProductManagement_PickingDetailModel m, out int value) { m = new ProductManagement_PickingDetailModel(); string sql0 = "select Guid,Name from T_ProductInfo_Product where Number='" + Number + "'"; DataSet ds = new DataSet(); value = 0; decimal temp = 0; if (new Helper.SQLite.DBHelper().QueryData(sql0, out ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { m.ProductID = (Guid)dr["Guid"]; m.Name = dr["Name"].ToString(); } string sql1 = " SELECT " + " total(a.Quantity) as QuantityB " + " FROM " + " T_Warehouse_SparePartsInventory a " + " WHERE " + " a.ProcessorID = '" + processorID + "' AND A.ProductID = '" + m.ProductID + "' GROUP BY " + " a.ProductID " ; object obj; new Helper.SQLite.DBHelper().QuerySingleResult(sql1, out obj); decimal.TryParse(obj.ToString(), out temp); value = decimal.ToInt32(temp); return(true); } else { return(false); } }
internal bool DeleteDetail(ProductManagement_PickingDetailModel m) { string sql = "update T_PM_ProductInProcessDetail set DeleteMark='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' Where Guid='" + m.Guid + "'"; return(new Helper.SQLite.DBHelper().SingleExecution(sql)); }