//添加领料单单身到框框内(并未插入到数据库) protected void Issue_Line_Commit(object sender, EventArgs e) { try { DataSet ds; if (string.IsNullOrWhiteSpace(invoice_no.Value)) { PageUtil.showToast(this, "请填写单据号"); return; } string Invoice_no = invoice_no.Value; if (invoiceDC.getIssueHeaderBySome(Invoice_no, "", "") == null) { PageUtil.showToast(this, "请确定单据号存在"); return; } ds = invoiceDC.getIssueHeaderBySome(Invoice_no, "", ""); //工单领料时 if (ds.Tables[0].Rows[0]["issue_type"].ToString() == "工单领料") { string Issue_wo_no = DropDownList_issue_wo_no.SelectedValue.ToString(); string Item_name = DropDownList_item_name.SelectedValue.ToString(); if (DropDownList_issue_wo_no.SelectedValue.ToString() == "--选择工单--" || DropDownList_item_name.SelectedValue.ToString() == "--选择料号--") { PageUtil.showToast(this, "请选择工单,料号后再做操作"); return; } if (DropDownList_operation_seq_num.SelectedValue.ToString() == "--选择制程--" || DropDownList_issue_sub_key.SelectedValue.ToString() == "--选择库别--") { PageUtil.showToast(this, "请选择制程,库别后再做操作"); return; } //若该单身已对应工单(且不是当前添加的工单)则不允许添加 DataSet ds2, ds3; ds2 = invoiceDC.getIssueLineBySome(Invoice_no, ""); ds3 = invoiceDC.getIssueLineBySome(Invoice_no, Issue_wo_no); if (ds2 != null && ds3 == null) { PageUtil.showToast(this, "同一个领料单号只对应一个工单,请检查工单号!"); return; } int Operation_seq_num = int.Parse(DropDownList_operation_seq_num.SelectedValue.ToString()); string Issue_sub_key = DropDownList_issue_sub_key.SelectedValue.ToString(); //string Frame_key = DropDownList_frame_key.SelectedValue.ToString(); if (required_qty.Value == "" || simulated_qty.Value == "") { required_qty.Value = "0"; simulated_qty.Value = "0"; } int Issued_qty; int Simulated_qty; int Required_qty; try { Issued_qty = int.Parse(issued_qty.Value); Simulated_qty = int.Parse(simulated_qty.Value); Required_qty = int.Parse(required_qty.Value); } catch (Exception e2) { PageUtil.showToast(this, "请规范填写领料量后再做操作"); return; } if (Required_qty != 0 && Simulated_qty != 0) { if (Issued_qty > (Required_qty - Simulated_qty) || Issued_qty <= 0) { PageUtil.showToast(this, "请规范填写领料量,领料量大于0且小于 需求量-发料量"); return; } } //从数据库中获取该单据对应的line_num值 int Line_num = invoiceDC.getIssueLine_numByInvoice_no(Invoice_no); //Line_num生成失败 if (Line_num == -1) { PageUtil.showToast(this, "添加单身失败"); return; } DataTable table = new DataTable(); table = GetGridViewData(table); //当框框中已经有一条数据及以上时,需要对line_num做处理 if (table.Rows.Count >= 1) { Line_num = Line_num + table.Rows.Count; } //检验数据库中相同工单+料号的情况下,领料量有没有超过临界值 int db_issued_qty = invoiceDC.getIssued_qty(Issue_wo_no, Item_name); if (Issued_qty + db_issued_qty > (Required_qty - Simulated_qty)) { PageUtil.showToast(this, "该料号领料量超过需求量-发料量了,不能再申请领料,请去查看相关信息再申请"); return; } //当框框中已经有多条数据时,需要检验此时添加的新单身是否与在框框中的单身信息一样(工单号+料号),需要对料号数量进行管控 int qty = 0; for (int i = 0; i < table.Rows.Count; i++) { if (Issue_wo_no == table.Rows[i].ItemArray[3].ToString() && Item_name == table.Rows[i].ItemArray[1].ToString()) { //累加已经领的料 qty += int.Parse(table.Rows[i].ItemArray[6].ToString()); //判断该工单下的该料号领料量是否超过需求量-发料量 if (Issued_qty + qty > (Required_qty - Simulated_qty)) { PageUtil.showToast(this, "该料号领料量超过需求量-发料量了,不能再申请领料"); return; } } } DataRow sourseRow = table.NewRow(); sourseRow["wo_no"] = Issue_wo_no; sourseRow["line_num"] = Line_num; sourseRow["item_name"] = Item_name; sourseRow["peration_seq_num"] = Operation_seq_num; sourseRow["issued_qty"] = Issued_qty; sourseRow["simulated_qty"] = Simulated_qty; sourseRow["required_qty"] = Required_qty; //sourseRow["frame_key"] = Frame_key; sourseRow["issued_sub"] = Issue_sub_key; sourseRow["create_man"] = user; sourseRow["create_time"] = DateTime.Now; table.Rows.Add(sourseRow); GridView1.DataSource = table; GridView1.DataBind(); //提交单个单身数据成功时,清除用户已填写的单身数据,方便用户填写下一个单身 DropDownList_issue_wo_no.SelectedValue = "--选择工单--"; DropDownList_item_name.SelectedValue = "--选择小料号--"; DropDownList_operation_seq_num.SelectedValue = "--选择制程--"; DropDownList_issue_sub_key.SelectedValue = "--选择库别--"; //DropDownList_frame_key.SelectedValue = "--选择料架--"; issued_qty.Value = ""; simulated_qty.Value = ""; required_qty.Value = ""; } //非工单领料时 if (ds.Tables[0].Rows[0]["issue_type"].ToString() == "非工单领料") { string Item_name2 = item_name2.Value; string Subinventory2 = subinventory2.Value; //string Frame2 = frame2.Value; int Route_id; int Issued_qty2; if (String.IsNullOrWhiteSpace(Item_name2) == true || String.IsNullOrWhiteSpace(Subinventory2) == true) { PageUtil.showToast(this, "请将非工单领料部分数据填写完整"); return; } //if (invoiceDC.getMaterial_io(Item_name2, Frame2) == null) //{ // PageUtil.showToast(this, "请重新输入料号或料架,库存明细表中没有对应数据"); // return; //} //if (invoiceDC.getSubinventoryByFrame(Frame2) == null) //{ // PageUtil.showToast(this, "请重新输入库别,该料架不属于该库别下"); // return; //} if (invoiceDC.getItems_onhand_qty_detail(Subinventory2, Item_name2) == null) { PageUtil.showToast(this, "请重新输入库别或料号,库存总表中没有对应数据"); return; } try { Route_id = int.Parse(invoiceDC.getRoute(operation_seq_num2.Value).Tables[0].Rows[0]["route_id"].ToString()); } catch (Exception e2) { PageUtil.showToast(this, "请检查制程代号是否填写正确"); return; } try { Issued_qty2 = int.Parse(issued_qty2.Value); } catch (Exception e2) { PageUtil.showToast(this, "请规范填写领料量"); return; } if (Issued_qty2 <= 0) { PageUtil.showToast(this, "领料量应大于0"); return; } //从数据库中获取该单据对应的line_num值 int Line_num = invoiceDC.getIssueLine_numByInvoice_no(Invoice_no); //Line_num生成失败 if (Line_num == -1) { PageUtil.showToast(this, "添加单身失败"); return; } DataTable table = new DataTable(); table = GetGridViewData(table); //当框框中已经有一条数据及以上时,需要对line_num做处理 if (table.Rows.Count >= 1) { Line_num = Line_num + table.Rows.Count; } DataRow sourseRow = table.NewRow(); sourseRow["wo_no"] = "none"; sourseRow["line_num"] = Line_num; sourseRow["item_name"] = Item_name2; sourseRow["peration_seq_num"] = Route_id; sourseRow["issued_qty"] = Issued_qty2; sourseRow["simulated_qty"] = 0; sourseRow["required_qty"] = 0; //sourseRow["frame_key"] = Frame2; sourseRow["issued_sub"] = Subinventory2; sourseRow["create_man"] = user; sourseRow["create_time"] = DateTime.Now; table.Rows.Add(sourseRow); GridView1.DataSource = table; GridView1.DataBind(); //提交单个单身数据成功时,清除用户已填写的单身数据,方便用户填写下一个单身 item_name2.Value = ""; subinventory2.Value = ""; //frame2.Value = ""; operation_seq_num2.Value = ""; issued_qty2.Value = ""; } } catch (Exception e2) { PageUtil.showToast(this, "添加单身失败"); } }