/// <summary> /// 增加零件数量 /// </summary> private void btnAdd_Click(object sender, EventArgs e) { try { if (!FrmMainDAO.QueryUserButtonPower(this.Name, this.Text, sender, true)) { return; } DataRow headRow = ((DataRowView)bindingSource_PSchedule.Current).Row; if (headRow == null || headRow.RowState == DataRowState.Added) { MessageHandler.ShowMessageBox("请先保存生产计划单后,再进行Bom操作。"); return; } List <TreeListNode> nodes = GetCheckedPSBomNodeList(true); if (nodes.Count == 0) { MessageHandler.ShowMessageBox("请选择要操作的零件Bom的根节点信息。"); return; } List <string> pbBomNoList = new List <string>(); foreach (TreeListNode node in nodes) { pbBomNoList.Add(DataTypeConvert.GetString(node["PbBomNo"])); } string psNoStr = DataTypeConvert.GetString(headRow["PsNo"]); decimal defValue = 1; defValue = FrmInputNumber.ShowFrmInputNumber("输入数量", "增加数量", defValue); if (defValue == 0) { return; } if (!CheckDragBomAmount(psNoStr, pbBomNoList, defValue)) { return; } if (defValue != 0) { psDAO.ProductionSchedule_InsertBom(psNoStr, pbBomNoList, DataTypeConvert.GetDateTime(headRow["ReqDate"]), defValue); } RefreshPSBom(); } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--操作当前选中的信息错误。", ex); } }
/// <summary> /// 实现拖拽设计Bom信息事件 /// </summary> private void treeListPSBom_DragDrop(object sender, DragEventArgs e) { try { if (TableProductionSchedule.Rows.Count == 0 || bindingSource_PSchedule.Current == null) { return; } if (btnEditAutoSalesOrderNo.Text != buttonEditSalesOrderNo.Text) { MessageHandler.ShowMessageBox("设计Bom信息的销售单号必须和生产计划单的销售单号相同。"); return; } DataRow headRow = ((DataRowView)bindingSource_PSchedule.Current).Row; //if (headRow.RowState == DataRowState.Added || headRow.RowState == DataRowState.Modified || btnSave.Text == "保存") if (headRow == null || btnSave.Text == "保存") { MessageHandler.ShowMessageBox("请先保存生产计划单后,再进行Bom操作。"); return; } List <string> pbBomNoList = new List <string>(); List <TreeListNode> nodes = e.Data.GetData(typeof(List <TreeListNode>)) as List <TreeListNode>; if (nodes != null)//拖拽Bom信息 { //TreeList grid = sender as TreeList; //DataTable table = grid.DataSource as DataTable; if (nodes != null && nodes.Count > 0) { foreach (TreeListNode node in nodes) { //treeList1.Nodes.Add(node); pbBomNoList.Add(DataTypeConvert.GetString(node["PbBomNo"])); //MessageHandler.ShowMessageBox(node["PbBomNo"].ToString()); } } } if (pbBomNoList.Count > 0) { decimal defValue = 1; if (pbBomNoList.Count == 1) { foreach (TreeListNode node in treeListDesignBom.Nodes) { if (DataTypeConvert.GetString(node["PbBomNo"]) == pbBomNoList[0]) { defValue = DataTypeConvert.GetDecimal(node["RemainQty"]); break; } } foreach (TreeListNode node in treeListPSBom.Nodes) { if (DataTypeConvert.GetString(node["PbBomNo"]) == pbBomNoList[0]) { defValue = defValue - DataTypeConvert.GetDecimal(node["PurQty"]); break; } } if (defValue == 0) { MessageHandler.ShowMessageBox("剩余数量为0,不能再进行添加。"); return; } } defValue = FrmInputNumber.ShowFrmInputNumber("输入数量", "增加数量", defValue); if (defValue == 0) { return; } if (!CheckDragBomAmount(DataTypeConvert.GetString(headRow["PsNo"]), pbBomNoList, defValue)) { return; } if (defValue != 0) { psDAO.ProductionSchedule_InsertBom(DataTypeConvert.GetString(headRow["PsNo"]), pbBomNoList, DataTypeConvert.GetDateTime(headRow["ReqDate"]), defValue); RefreshPSBom(); treeListDesignBom.UncheckAll(); } } } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--实现拖拽设计Bom信息事件错误。", ex); } }