protected void Button1_Click(object sender, EventArgs e) { if (txtSupplier.Text.Trim() == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请选择供应商');</script>"); return; } txtSupplier.Text = txtSupplier.Text.Trim(); //判断改供应商是否有在支付中的单子 if (TB_SupplierInvoiceService.checkSupplierDoing(txtSupplier.Text)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('该供应商有在执行中的支付单,请排队等候');</script>"); return; } if (TB_SupplierInvoiceService.CheckAdvanceAndSupplierInvoices(txtSupplier.Text, 1)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('该供应商有【预付款】在执行中的【抵扣支付单】,请排队等候');</script>"); return; } GetSelectedData(); if (ViewState["ids"] != null) { string where = ViewState["ids"].ToString().Substring(1); if (where != "") { where = where.Substring(0, where.Length - 1); Session["backurl"] = "/JXC/WFSupplierInvoice.aspx"; Session["SupplierInvoiceIds"] = where; base.Response.Redirect("~/JXC/WFSupplierInvoiceVerify.aspx?ProId=31&ids="); } } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请选择数据!');</script>"); } }
protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "select") { string ProId = "0"; string allE_id = "0"; string[] payType_Id = e.CommandArgument.ToString().Split('_'); if (payType_Id[0] == "支") { var obj = DBHelp.ExeScalar(string.Format(@"select SUM(SupplierInvoiceTotal) from TB_SupplierInvoices where Id={0} or ids in ( select SupplierInvoiceIds from TB_TempSupplierInvoice where SupplierInvoiceId={0});", payType_Id[1])); if (obj != null) { lblAllTotal.Text = obj.ToString(); } gvDiXiao.DataSource = new SupplierToInvoiceViewService().GetSupplierInvoiceListToDiXiao(Convert.ToInt32(payType_Id[1])); gvDiXiao.DataBind(); allE_id = payType_Id[1]; ProId = "in (31,33)"; } else { if (payType_Id[0] == "预") { var obj = DBHelp.ExeScalar(string.Format(@"select SUM(SupplierInvoiceTotal) from TB_SupplierAdvancePayments where Id={0};", payType_Id[1])); if (obj != null) { lblAllTotal.Text = obj.ToString(); } ProId = "=32"; allE_id = payType_Id[1]; } else { lblAllTotal.Text = "0"; } gvDiXiao.DataSource = new List <SupplierToInvoiceView>(); gvDiXiao.DataBind(); } if (allE_id != "0") { //加载已经审批的数据 tb_EFormsService eformsSer = new tb_EFormsService(); List <VAN_OA.Model.EFrom.tb_EForms> eforms = eformsSer.GetListArray(string.Format(" e_Id in (select id from tb_EForm where proId {0} and allE_id={1})", ProId, allE_id)); if (eforms.Count > 0) { string mess = @"<table cellpadding='0' cellspacing='0' width='100%' bordercolorlight='#999999' bordercolordark='#FFFFFF' border='1' ><tr><td colspan='6' style=' height:20px; background-color:#336699; color:White;'>流程图</td></tr>"; for (int i = 0; i < eforms.Count; i++) { string per = ""; if (eforms[i].consignor != null && eforms[i].consignor != 0) { per = eforms[i].Consignor_Name + "(委托人:" + eforms[i].Audper_Name + ")"; } else { per = eforms[i].Audper_Name; } mess += string.Format("<tr><td align='center'>第{0}步</td><td>序号{0}:{1}</td><td><span style='color:red;'>{2}</span>[<span style='color:blue;'>{3} {4}</span>]<br/>意见:{5}</td></tr>", i + 1, eforms[i].RoleName , per, eforms[i].resultState, eforms[i].doTime, eforms[i].idea); } mess += "</table>"; lblMess.Text = mess; } } } if (e.CommandName == "Delete1") { // string[] payType_Id = e.CommandArgument.ToString().Split('_'); // string sql = ""; // string type = ""; // string deleteSql = ""; // if (payType_Id[0] == "支") // { // type = "供应商付款单"; // var checkSql = string.Format(@"select count(*) from TB_SupplierInvoice //left join TB_SupplierInvoices on TB_SupplierInvoice.id=TB_SupplierInvoices.id //where status='通过' and TB_SupplierInvoice.id={0} and SupplierInvoiceTotal<0", payType_Id[1]); // if (Convert.ToInt32(DBHelp.ExeScalar(checkSql)) > 0) // { // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数据由退货单生成,无法修改!');</script>"); // return; // } // deleteSql = string.Format("delete from TB_SupplierInvoice where id={0};delete from TB_SupplierInvoices where id={0};", payType_Id[1]); // sql = "select CreateName,Status,ProNo,TB_SupplierInvoices.Id,IsYuFu from TB_SupplierInvoice left join TB_SupplierInvoices on TB_SupplierInvoices.id=TB_SupplierInvoice.id where TB_SupplierInvoice.id=" + payType_Id[1]; // } // if (payType_Id[0] == "预") // { // type = "供应商预付款单"; // //首先查询这个单子有没有 生成相应的支付单 // var checksql = string.Format(@"select count(*) from CAI_OrderChecks left join CAI_OrderCheck on CAI_OrderChecks.CheckId=CAI_OrderCheck.Id //where Status<>'不通过' and CaiId in (select caiIds from TB_SupplierAdvancePayment left join TB_SupplierAdvancePayments //on TB_SupplierAdvancePayment.id=TB_SupplierAdvancePayments.Id //where status='通过' and TB_SupplierAdvancePayment.id={0} )", payType_Id[1]); // if (Convert.ToInt32(DBHelp.ExeScalar(checksql)) > 0) // { // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数据已经存在入库数据,或正在入库的单子,无法修改!');</script>"); // return; // } // deleteSql = string.Format("delete from TB_SupplierAdvancePayment where id={0};delete from TB_SupplierAdvancePayments where id={0};", payType_Id[1]); // sql = "select CreateName,Status,ProNo,Id from TB_SupplierAdvancePayment where id=" + payType_Id[1]; // } // DataTable tb = DBHelp.getDataTable(sql); // if (tb.Rows.Count <= 0) // { // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('信息不存在!');</script>"); // return; // } // string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='" + type + "')", payType_Id[1]); // string DeleteAll = string.Format("delete from tb_EForms where e_Id={0};delete from tb_EForm where id={0};", DBHelp.ExeScalar(efromId)); // deleteSql = deleteSql + DeleteAll; // DBHelp.ExeCommand(deleteSql); // Show(); // //base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除成功!');</script>"); // return; } if (e.CommandName == "ReEdit") { string[] payType_Id = e.CommandArgument.ToString().Split('_'); string sql = ""; string type = ""; if (payType_Id[0] == "支") { type = "供应商付款单"; //首先查询一下入库单有没有已经全部开票 // var checkSql = string.Format(@"select count(*) from TB_SupplierInvoice //left join TB_SupplierInvoices on TB_SupplierInvoice.id=TB_SupplierInvoices.id //left join CAI_OrderInHouses on CAI_OrderInHouses.ids=TB_SupplierInvoices.ruIds //where status='通过' and PayStatus=2 and TB_SupplierInvoice.id={0}", payType_Id[1]); var checkSql = string.Format(@"select count(*) from TB_SupplierInvoice left join TB_SupplierInvoices on TB_SupplierInvoice.id=TB_SupplierInvoices.id where status='通过' and TB_SupplierInvoice.id={0} and SupplierInvoiceTotal<0", payType_Id[1]); if (Convert.ToInt32(DBHelp.ExeScalar(checkSql)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数据由退货单生成,无法修改!');</script>"); return; } sql = "select CreateName,Status,ProNo,TB_SupplierInvoices.Id,IsYuFu,LastSupplier from TB_SupplierInvoice left join TB_SupplierInvoices on TB_SupplierInvoices.id=TB_SupplierInvoice.id where TB_SupplierInvoice.id=" + payType_Id[1]; } if (payType_Id[0] == "预") { type = "供应商预付款单"; //首先查询这个单子有没有 生成相应的支付单 // var checksql = string.Format(@"select count(*) from CAI_OrderChecks left join CAI_OrderCheck on CAI_OrderChecks.CheckId=CAI_OrderCheck.Id //where Status<>'不通过' and CaiId in (select caiIds from TB_SupplierAdvancePayment left join TB_SupplierAdvancePayments //on TB_SupplierAdvancePayment.id=TB_SupplierAdvancePayments.Id //where status='通过' and TB_SupplierAdvancePayment.id={0} )", payType_Id[1]); // if (Convert.ToInt32(DBHelp.ExeScalar(checksql)) > 0) // { // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数据已经存在入库数据,或正在入库的单子,无法修改!');</script>"); // return; // } sql = "select CreateName,Status,ProNo,Id from TB_SupplierAdvancePayment where id=" + payType_Id[1]; } DataTable tb = DBHelp.getDataTable(sql); if (tb.Rows.Count <= 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('信息不存在!');</script>"); return; } //是否是此单据的申请人 //if (payType_Id[0] != "预"&&Session["LoginName"].ToString() != tb.Rows[0]["CreateName"].ToString()) //{ // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须由原单据申请人 重新发起,其他人不能重新提交编辑!');</script>"); // return; //} //首先单子要先通过 if (tb.Rows[0]["Status"] != null && tb.Rows[0]["Status"].ToString() == "执行中") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据在执行中不能重新编辑!');</script>"); return; } else { //base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据必须已经审批通过才能重新编辑!');</script>"); //return; } if (payType_Id[0] == "支") { if (Convert.ToBoolean(tb.Rows[0]["IsYuFu"])) { type = "供应商付款单(预付单转支付单)"; } if (tb.Rows[0]["LastSupplier"] != null) { //判断改供应商是否有在支付中的单子 if (TB_SupplierInvoiceService.checkSupplierDoing(tb.Rows[0]["LastSupplier"].ToString())) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('该供应商有在执行中的支付单,请排队等候');</script>"); return; } //判断改供应商是否有在支付中的单子 if (TB_SupplierInvoiceService.CheckAdvanceAndSupplierInvoices(tb.Rows[0]["LastSupplier"].ToString(), 1)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('该供应商有【预付款】在执行中的【抵扣支付单】,请排队等候');</script>"); return; } } } sql = "select pro_Id from A_ProInfo where pro_Type='" + type + "'"; string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='" + type + "')", payType_Id[1]); string url = ""; if (payType_Id[0] == "支") { url = "~/JXC/WFSupplierInvoiceVerify.aspx?ProId=" + DBHelp.ExeScalar(sql) + "&allE_id=" + payType_Id[1] + "&EForm_Id=" + DBHelp.ExeScalar(efromId) + "&&ReAudit=true"; } else { url = "~/JXC/WFSupplierAdvancePaymentVerify.aspx?ProId=" + DBHelp.ExeScalar(sql) + "&allE_id=" + payType_Id[1] + "&EForm_Id=" + DBHelp.ExeScalar(efromId) + "&&ReAudit=true"; } Response.Redirect(url); //没有做过检验单 } }