//插入领料单--只是生成领料单号 protected void insert(object sender, EventArgs e) { string strInvoice_no = invoice_no.Value; if (!string.IsNullOrWhiteSpace(strInvoice_no)) { PageUtil.showToast(this, "当前领料单信息未提交!"); return; } issueHeaderDC = new IssueHeaderDC(); int end; string end_text; string month = string.Empty; string year = string.Empty; modelMtl_issue_header = issueHeaderDC.getTheNewestIssueHeaderByCreatetime(); //判断数据库是否有数据,没有数据则初始化一个流水号 if (modelMtl_issue_header == null) { end_text = "00001"; month = DateTime.Now.Month.ToString(); year = DateTime.Now.Year.ToString(); //为月份补0 for (int i = month.Length; i < 2; i++) { month = "0" + month; } //截取年份后两位 year = year.Substring(2, 2); } else { end = modelMtl_issue_header.Issue_header_id; //判断id是否为99998,是则取下一个流水号为99999,否则取余+1作为下一个流水号 end = end % 99998 == 0 ? 99998 + 1 : end % 99999 + 1; end_text = end.ToString(); //为流水号补0 for (int i = end_text.Length; i < 5; i++) { end_text = "0" + end_text; } month = DateTime.Now.Month.ToString(); year = DateTime.Now.Year.ToString(); year = year.Substring(2, 2); for (int i = month.Length; i < 2; i++) { month = "0" + month; } } invoice_no.Value = "Q" + year + month + end_text; }
//提交领料单主表信息 ,并写入数据库. protected void Issue_Header_Commit(object sender, EventArgs e) { issueHeaderDC = new IssueHeaderDC(); string INVOICE_NO = invoice_no.Value; //领料单号 /*避免重复提交*/ try { ModelMtl_issue_header header = header = issueHeaderDC.getTheNewestIssueHeaderByCreatetime(); if (header.Invoice_no == INVOICE_NO) { PageUtil.showToast(this, "请勿重复提交!"); return; } } catch (Exception) { Boolean flag = false; } string WO_NO = Request.Form["wo_no_c"]; //工单号 string ISSUED_SUB_KEY = Request["issued_sub_key_c"]; //库别 string OPERATION_SEQ_NUM = Request.Form["operation_seq_num_c"]; //制程 string ISSUE_TYPE = issue_type.SelectedValue; //领料类别 string ISSUE_MAN = issue_man.Value; //领料人 string CUSTOMER_KEY = customer_key.Value; //客户代码 if (ISSUE_MAN.Length > 10) { PageUtil.showToast(this, "领料人长度超出范围!"); return; } if (CUSTOMER_KEY.Length > 10) { PageUtil.showToast(this, "客户代码长度超出范围!"); return; } DateTime CREATE_TIME = DateTime.Now; DateTime UPDATE_TIME = DateTime.Now; if (string.IsNullOrWhiteSpace(ISSUE_MAN) || string.IsNullOrWhiteSpace(CUSTOMER_KEY)) { string error = "请填写完整信息!"; PageUtil.showToast(this, error); return; } try { issueHeaderDC.insertIssueHeader(INVOICE_NO, WO_NO, ISSUED_SUB_KEY, CREATE_TIME, UPDATE_TIME, OPERATION_SEQ_NUM, ISSUE_TYPE, ISSUE_MAN, CUSTOMER_KEY); PageUtil.showToast(this, "插入信息成功!"); } catch (Exception) { PageUtil.showToast(this, "插入信息失败!"); return; } if (ISSUE_TYPE == "工单领料") { string target_qty = issueHeaderDC.getTarget(WO_NO); required_qty.Value = target_qty; } }