/// <summary> /// 组批 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Asse_Click(object sender, EventArgs e) { try { if (this.gv_ZGZPJH.RowCount == 0) { MessageBox.Show("计划记录为空!"); return; } int selectedPlanHandle = this.gv_ZGZPJH.FocusedRowHandle;//获取计划焦点行索引 if (selectedPlanHandle != 0 && string.IsNullOrWhiteSpace(txt_Remark.Text)) { MessageBox.Show("配批必须输入备注!"); return; } int selectedAllowGrd = this.gv_KDZGZ.FocusedRowHandle;//获取可轧钢种焦点行索引 if (selectedPlanHandle < 0 || selectedAllowGrd < 0) { MessageBox.Show("请检查计划和可轧钢种,记录为空!"); return; } if (DialogResult.No == MessageBox.Show("确认组批吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } string planID = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_ID").ToString(); //获取焦点主键 string planGrd = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_STL_GRD").ToString(); //获取焦点行钢种 string planStd = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_STD_CODE").ToString(); //获取焦点行执行标准 string planSpec = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_SPEC").ToString(); //获取焦点规格 string status = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "N_STATUS").ToString(); //获取焦点状态 string planMatCode = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_MAT_CODE").ToString(); //获取焦点物料编码 string planMatName = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "C_MAT_NAME").ToString(); //获取焦点物料名称 string planIsMerge = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "N_IS_MERGE").ToString(); //获取焦点合并标记 string maxWgt = this.gv_ZGZPJH.GetRowCellValue(selectedPlanHandle, "MaxWgt").ToString(); //获取焦点合并标记 int allowGrdNum = Convert.ToInt32(this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "N_QUA")); //可轧钢种支数 string grd = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_STL_GRD").ToString(); //钢种 string std = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_STD_CODE").ToString(); //执行标准 string spec = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_SPEC").ToString(); //钢坯断面 string matCode = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_MAT_CODE").ToString(); //获取焦点物料编码 string matName = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_MAT_NAME").ToString(); //获取焦点物料名称 string remark = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_REMARK").ToString(); //获取焦点物料名称 decimal planPw = decimal.Parse(this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "N_WGT").ToString()); //获取焦点单重 string kpBatchNo = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_BATCH_NO").ToString(); //获取焦点开批号 string strMenuName = RV.UI.UserInfo.menuName; UserLog.AddLog(strMenuName, this.Name + "轧钢组坯" + this.txt_BranchNo.Text, "轧钢组坯", "轧钢组坯");//添加操作日志 if (status != "1" && status != "2") { MessageBox.Show("请选择已下发、已组坯状态计划组坯!"); return; } int errorNum = 0;//TryParse 输出参数 string asseNum = txt_AsseNum.Text.Trim(); if (!Int32.TryParse(asseNum, out errorNum) || int.Parse(asseNum) == 0) { MessageBox.Show("组批支数只能是整数!"); return; } if (int.Parse(asseNum) > allowGrdNum) { MessageBox.Show("组批支数不能大于钢坯库存支数!"); return; } Mod_TRC_ROLL_MAIN model = new Mod_TRC_ROLL_MAIN(); model.C_ID = bll_TRC_ROLL_MAIN.CreateID(); model.C_STOVE = this.gv_KDZGZ.GetRowCellValue(selectedAllowGrd, "C_STOVE").ToString(); model.C_BATCH_NO = this.txt_BranchNo.Text; model.C_PLAN_ID = planID; model.C_STL_GRD_SLAB = grd; model.C_STD_CODE_SLAB = std; model.C_SPEC_SLAB = spec; model.N_QUA_TOTAL = decimal.Parse(asseNum); model.N_WGT_TOTAL = planPw * decimal.Parse(asseNum); model.C_EMP_ID = UserInfo.UserID; model.C_STL_GRD = planGrd; model.C_SPEC = planSpec; model.C_STD_CODE = planStd; model.C_MAT_SLAB_CODE = matCode; model.C_MAT_SLAB_NAME = matName; model.C_REMARK = this.txt_Remark.Text; if (!string.IsNullOrWhiteSpace(remark)) { model.C_REMARK += "|" + remark; } model.C_GROUP = this.cbo_Group.EditValue.ToString(); model.C_SHIFT = this.cbo_Shift.EditValue.ToString(); model.N_QUA_TOTAL_VRITUAL = model.N_QUA_TOTAL; model.N_WGT_TOTAL_VRITUAL = model.N_WGT_TOTAL; model.C_PLANT = kpBatchNo; model.C_STA_ID = staID; model.N_IS_MERGE = decimal.Parse(planIsMerge); string result = bll_TRC_ROLL_MAIN.AssemblyHandler(model, grd, std, slbwhCode, kpBatchNo, planMatCode, staID, maxWgt); if (result == "1") { btn_AssePlanQuery_Click(null, null); Query3(); MessageBox.Show("操作成功!"); //生成批号 this.txt_BranchNo.Text = bll_TRC_ROLL_MAIN.CreateBranchNo(staID); } else if (result == "8") { btn_AssePlanQuery_Click(null, null); Query3(); MessageBox.Show("组批量超出计划量,不能组坯"); //生成批号 this.txt_BranchNo.Text = bll_TRC_ROLL_MAIN.CreateBranchNo(staID); } else if (result == "9") { btn_AssePlanQuery_Click(null, null); Query3(); MessageBox.Show("组批量超出订单总量,不能组坯"); //生成批号 this.txt_BranchNo.Text = bll_TRC_ROLL_MAIN.CreateBranchNo(staID); } else { btn_AssePlanQuery_Click(null, null); Query3(); MessageBox.Show("操作失败!"); //生成批号 this.txt_BranchNo.Text = bll_TRC_ROLL_MAIN.CreateBranchNo(staID); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Seave_Click(object sender, EventArgs e) { //if (string.IsNullOrEmpty(txt_Stove.Text.Trim())) //{ // MessageBox.Show("炉号不能为空!"); // return; //} if (string.IsNullOrEmpty(txt_Batch.Text.Trim())) { MessageBox.Show("批号不能为空!"); return; } if (string.IsNullOrEmpty(fil_STlGRD.Text.Trim())) { MessageBox.Show("钢种不能为空!"); return; } if (string.IsNullOrEmpty(txt_Spec.Text.Trim())) { MessageBox.Show("规格不能为空!"); return; } if (Convert.ToDecimal(txt_Spec.Text.Trim()) == 0) { MessageBox.Show("规格不能为0!"); return; } try { Mod_TRC_ROLL_MAIN mod = new Mod_TRC_ROLL_MAIN(); mod.C_STA_ID = imgcbo_Plant.EditValue?.ToString(); mod.C_STOVE = txt_Stove.Text.Trim(); mod.C_BATCH_NO = txt_Batch.Text.Trim(); mod.C_STL_GRD = fil_STlGRD.Text.Trim(); mod.C_STD_CODE = imgcbo_STD.Text.Trim(); if (!txt_Spec.Text.Contains("φ")) { mod.C_SPEC = "φ" + txt_Spec.Text; } else { mod.C_SPEC = txt_Spec.Text; } mod.N_QUA_TOTAL_VIRTUAL = Convert.ToDecimal(txt_Count.Text.Trim()); mod.N_WGT_TOTAL_VIRTUAL = Convert.ToDecimal(txt_WGT.Text.Trim()); mod.C_SHIFT = txt_BC.Text.Trim(); mod.C_GROUP = txt_BZ.Text.Trim(); mod.C_EMP_ID = RV.UI.UserInfo.UserID; mod.D_MOD_DT = RV.UI.ServerTime.timeNow(); mod.C_REMARK = "手动添加请勿删除!!"; #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_BATCH_NO", mod.C_BATCH_NO); ht.Add("N_STATUS", "1"); if (Common.CheckRepeat.CheckTable("TRC_ROLL_MAIN", ht) > 0) { MessageBox.Show("批号已存在,不能重复添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion if (bll_trc_roll_main.Add(mod)) { Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "添加组批实绩");//添加操作日志 MessageBox.Show("保存成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }