//提交单头 protected void insert1(object sender, EventArgs e) { Return_headerDC DC = new Return_headerDC(); WoDC DC2 = new WoDC(); string invoice_no = invoice_no2.Value; string quit_type = quit_type1.Items[quit_type1.SelectedIndex].Value; int enabled = 0; int subinventory = 0; string remark = remark1.InnerText; string return_man = Session["LoginName"].ToString(); string wo_no = return_wo_no1.Value; if (String.IsNullOrEmpty(invoice_no)) { PageUtil.showToast(this.Page, "请点击插入自动生成单据号!"); } else if (String.IsNullOrEmpty(return_wo_no1.Value)) { PageUtil.showToast(this.Page, "请输入工单号!"); } List <ModelWO> wo; wo = DC2.getWOByWo_no(wo_no); if (wo == null) { PageUtil.showToast(this.Page, "没有这个工单号,请检查数据"); } else { try { enabled = int.Parse(Enabled1.Items[Enabled1.SelectedIndex].Value); subinventory = int.Parse(Subinventory1.Items[Subinventory1.SelectedIndex].Value); } catch (Exception ex) { PageUtil.showToast(this.Page, "数据转换出错,请检查数据格式!"); } bool a = DC.insertReturn_header(invoice_no, quit_type, subinventory, enabled, wo[0].Wo_key, return_man, remark); if (a == true) { PageUtil.showToast(this.Page, "添加退料单头成功!"); Line_Repeater.DataSource = DC.getReturn_headerByLikeINVOICE_NO(invoice_no); if (Line_Repeater.DataSource == null) { PageUtil.showToast(this, "数据库中没有对应数据,请添加数据后再查询"); } else { Line_Repeater.DataBind(); } } else { PageUtil.showToast(this.Page, "添加退料单头失败!"); } } }
//更新单头 protected void update1(object sender, EventArgs e) { Return_headerDC DC = new Return_headerDC(); WoDC woDC = new WoDC(); string invoice_no = quit_invoice_no2.Value; string quit_type = quit_type2.Items[quit_type2.SelectedIndex].Value; int subinventory = 0; int status = 0; int quit_wo_no = 0; string remark = remark2.Value; string return_man = Session["LoginName"].ToString(); if (String.IsNullOrEmpty(quit_wo_no2.Value)) { PageUtil.showToast(this.Page, "请输入工单号!"); } else { try { subinventory = int.Parse(Subinventory4.Items[Subinventory4.SelectedIndex].Value); status = int.Parse(status2.Items[status2.SelectedIndex].Value); quit_wo_no = woDC.getWo_keyByReturn_wo_no(quit_wo_no2.Value); } catch (Exception ex) { PageUtil.showToast(this.Page, "数据转换出错,请检查数据格式!"); return; } bool a = DC.updateReturn_header(invoice_no, quit_type, subinventory, status, quit_wo_no, return_man, remark); if (a == true) { try { Line_Repeater.DataSource = DC.getReturn_headerByLikeINVOICE_NO(invoice_no); if (Line_Repeater.DataSource == null) { PageUtil.showToast(this, "数据库中没有对应数据,请添加数据后再查询"); } Line_Repeater.DataBind(); } catch (Exception ex) { PageUtil.showToast(this.Page, "数据查询失败!"); } PageUtil.showToast(this.Page, "单据号为" + invoice_no + "更新成功!"); } else { PageUtil.showToast(this.Page, "单据号为" + invoice_no + "更新失败!"); } } }
//删除单头 protected void delete1(object sender, EventArgs e) { Return_headerDC DC = new Return_headerDC(); string invoice_no = lab1.Value; bool a = DC.deleteReturn_header(invoice_no); if (a == true) { string invoice_no1 = invoice_no4.Value; try { Line_Repeater.DataSource = DC.getReturn_headerByLikeINVOICE_NO(invoice_no1); if (Line_Repeater.DataSource == null) { PageUtil.showToast(this, "数据库中没有对应数据,请添加数据后再查询"); } else { Line_Repeater.DataBind(); } } catch (Exception ex) { PageUtil.showToast(this.Page, "数据查询失败!"); } Return_lineDC DC1 = new Return_lineDC(); string return_wo_no = return_wo_no4.Value; try { Repeater1.DataSource = DC1.getReturn_lineByLikeRETURN_WO_NO(return_wo_no); if (Repeater1.DataSource == null) { PageUtil.showToast(this, "数据库中没有对应数据,请添加数据后再查询"); } else { Repeater1.DataBind(); } } catch (Exception ex) { PageUtil.showToast(this.Page, "数据查询错误!"); } PageUtil.showToast(this.Page, "单据号" + invoice_no + "删除成功!"); } else { PageUtil.showToast(this.Page, "单据号" + invoice_no + "删除失败!"); } }
//生成单据号规则 protected void num_no(object sender, EventArgs e) { string num; Return_headerDC header = new Return_headerDC(); ModelReturn_header invoice = header.getTheNewestReturn_headerByCreatetime(); if (invoice == null) { num = Number.code(0, 2); } else { num = Number.code(invoice.Return_header_id, 2); } invoice_no2.Value = num; }
//查询单头 protected void select1(object sender, EventArgs e) { Return_headerDC DC = new Return_headerDC(); string invoice_no = invoice_no4.Value; try { Line_Repeater.DataSource = DC.getReturn_headerByLikeINVOICE_NO(invoice_no); if (Line_Repeater.DataSource == null) { PageUtil.showToast(this, "数据库中没有对应数据,请添加数据后再查询"); } else { Line_Repeater.DataBind(); } } catch (Exception ex) { PageUtil.showToast(this.Page, "数据查询失败!"); } }