private void 提交单据ToolStripMenuItem_Click(object sender, EventArgs e) { if (lbDJZT.Text == "单据已完成") { MessageDialog.ShowPromptMessage("请重新确认单据状态"); } else { GetMessage(); if (m_lnqTechnology.OldParentID != null) { DataTable dt = m_serverBom.GetBomStructInfo(Convert.ToInt32(m_lnqTechnology.OldParentID), Convert.ToInt32(m_lnqTechnology.OldGoodsID)); if (dt.Rows.Count == 0) { MessageDialog.ShowPromptMessage("BOM表结构不匹配,请重新确认"); return; } m_lnqTechnology.OldCounts = Convert.ToInt32(dt.Rows[0]["Usage"]); } //m_lnqTechnology.DJH = m_billNoControl.GetNewBillNo(); if (!CheckData()) { return; } else { if (m_serverTechnology.SubmitBill(m_lnqTechnology, out m_err)) { MessageDialog.ShowPromptMessage("提交成功"); m_msgPromulgator.DestroyMessage(txtDJH.Text); m_msgPromulgator.SendNewFlowMessage(txtDJH.Text, string.Format("{0} 号技术变更单,请零件工程师批准", txtDJH.Text), CE_RoleEnum.零件工程师); } else { MessageDialog.ShowPromptMessage(m_err); return; } } } RefreshDataGirdView(m_serverTechnology.GetAllBill()); PositioningRecord(m_lnqTechnology.DJH); }
private void btnAdd_Click(object sender, EventArgs e) { try { DataTable dtTemp = (DataTable)dataGridView1.DataSource; string changMode = ""; if (rb_Update.Checked) { changMode = "修改"; } else if (rb_Add.Checked) { changMode = "新增"; } else { changMode = "删除"; } if (dataGridView1.Rows.Count > 0) { for (int i = 0; i < dtTemp.Rows.Count; i++) { if (changMode == dtTemp.Rows[i]["变更模式"].ToString() && (txtOldParentCode.Tag != null && dtTemp.Rows[i]["OldParentID"].ToString() != "" && Convert.ToInt32(dtTemp.Rows[i]["OldParentID"]) == Convert.ToInt32(txtOldParentCode.Tag)) && Convert.ToInt32(txtOldName.Tag) == Convert.ToInt32(dtTemp.Rows[i]["OldGoodsID"]) && (txtNewParentCode.Tag != null && dtTemp.Rows[i]["NewParentID"].ToString() != "" && Convert.ToInt32(dtTemp.Rows[i]["NewParentID"]) == Convert.ToInt32(txtNewParentCode.Tag)) && Convert.ToInt32(txtNewName.Tag) == Convert.ToInt32(dtTemp.Rows[i]["NewGoodsID"])) { MessageDialog.ShowPromptMessage("不能录入重复物品"); return; } if (txtOldName.Tag.ToString() != "0" && txtOldParentCode.Tag.ToString() != "0") { DataTable dt = m_serverBom.GetBomStructInfo(Convert.ToInt32(txtOldParentCode.Tag), Convert.ToInt32(txtOldName.Tag)); if (dt.Rows.Count == 0) { MessageDialog.ShowPromptMessage("第" + (i + 1) + "行中BOM表结构不匹配,请重新确认"); return; } } } } if (changMode == "修改" && (txtOldParentCode.Tag == null || txtOldParentCode.Tag.ToString() == "")) { if (MessageDialog.ShowEnquiryMessage("您没有选择父级零件,修改时将Bom表中所用到此零件的信息批量修改成现在的信息?") == DialogResult.No) { return; } } DataRow dr = dtTemp.NewRow(); dr["新零件父级编码"] = txtNewParentCode.Text; dr["新零件编码"] = txtNewCode.Text; if (cbGoodsInfo.Checked) { dr["新零件名称"] = txtNewUseName.Text; } else { dr["新零件名称"] = txtNewName.Text; } dr["新零件规格"] = txtNewSpec.Text; dr["新零件版次号"] = txtNewVersion.Text; dr["新零件基数"] = txtNewCounts.Value; dr["旧零件父级总成编码"] = txtOldParentCode.Text; dr["旧零件编码"] = txtOldCode.Text; dr["旧零件名称"] = txtOldName.Text; dr["旧零件规格"] = txtOldSpec.Text; dr["旧零件版次号"] = txtOldVersion.Text; dr["旧零件基数"] = txtOldCounts.Value; dr["变更原因"] = ""; if (rb_Add.Checked) { dr["变更模式"] = "新增"; } else if (rb_Delete.Checked) { dr["变更模式"] = "删除"; } else { dr["变更模式"] = "修改"; } if (cbGoodsInfo.Checked) { dr["是否修改零件本身"] = "是"; } else { dr["是否修改零件本身"] = "否"; } dr["NewParentID"] = txtNewParentCode.Tag == null ? 0 : Convert.ToInt32(txtNewParentCode.Tag); dr["NewGoodsID"] = txtNewName.Tag == null ? 0 : Convert.ToInt32(txtNewName.Tag); //if (txtNewParentCode.Tag != null && txtNewParentCode.Tag.ToString() != "") //{ //} //if (txtNewName.Tag != null && txtNewName.Tag != "") //{ // dr["NewGoodsID"] = txtNewName.Tag; //} if (!rb_Add.Checked) { dr["OldParentID"] = txtOldParentCode.Tag == null ? 0 : Convert.ToInt32(txtOldParentCode.Tag); dr["OldGoodsID"] = txtOldName.Tag == null ? 0 : Convert.ToInt32(txtOldName.Tag); //if (txtOldParentCode.Tag != null && txtOldParentCode.Tag.ToString() != "") //{ // dr["OldParentID"] = txtOldParentCode.Tag; //} //dr["OldGoodsID"] = txtOldName.Tag; } dtTemp.Rows.Add(dr); dataGridView1.DataSource = dtTemp; txtNewName.Text = ""; txtNewName.Tag = (int?)null; txtNewCode.Text = ""; txtNewSpec.Text = ""; txtNewVersion.Text = ""; txtNewParentCode.Text = ""; txtNewParentCode.Tag = (int?)null; txtNewCounts.Value = 0; txtOldName.Text = ""; txtOldName.Tag = (int?)null; txtOldCode.Text = ""; txtOldSpec.Text = ""; txtOldVersion.Text = ""; txtOldParentCode.Text = ""; txtOldParentCode.Tag = (int?)null; txtOldCounts.Value = 0; } catch (Exception) { throw; } }