protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["ElectronicInvoice"] != null) { var model = Session["ElectronicInvoice"] as ElectronicInvoice; txtCompanyName.Text = model.Company; txtRightCompanyName.Text = model.Company; txtSupplierName.Text = model.SupplierName; txtRightSupplierName.Text = model.SupplierName; txtSupplierCardNo.Text = model.SupplierBrandNo; txtRightSupplierCardNo.Text = model.SupplierBrandNo; txtBrandName.Text = model.SupplierBrandName; txtRightBrandName.Text = model.SupplierBrandName; txtNum.Text = "¥" + model.ActPay.ToString("f2").Replace(".", ""); txtDaTotal.Text = RMBCapitalization.RMBAmount(Convert.ToDouble(model.ActPay)); txtUse.Text = model.ProNo; txtTotal.Text = "¥" + string.Format("{0:n2}", model.ActPay); TB_CompanyService companySer = new TB_CompanyService(); var companyModel = companySer.GetListArray(string.Format(" ComName='{0}'", model.Company))[0]; txtCardNo.Text = companyModel.KaHao; txtRightCompanyCardNo.Text = companyModel.KaHao; TB_SupplierInfoService supplierSer = new TB_SupplierInfoService(); var list = supplierSer.GetListArray(string.Format(" SupplierName='{0}'", model.SupplierName)); if (list.Count > 0) { var supplierModel = list[0]; txtBrandAddress.Text = (string.IsNullOrEmpty(supplierModel.Province) ? " " : supplierModel.Province) + " " + supplierModel.City; txtRightBrandAddress.Text = (string.IsNullOrEmpty(supplierModel.Province) ? " " : supplierModel.Province) + " " + supplierModel.City; } else { txtBrandAddress.Text = ""; txtRightBrandAddress.Text = ""; } if (!string.IsNullOrEmpty(model.Person)) { var person = new Invoice_PersonService().GetListArray(string.Format(" name='{0}'", model.Person))[0]; txtId.Text = person.CardNo; txtRightPhone.Text = person.Phone; txtPhone.Text = person.Phone; } } } }
protected void txtSupplierName_TextChanged(object sender, EventArgs e) { if (txtSupplierName.Text != "") { TB_SupplierInfoService supplierSer = new TB_SupplierInfoService(); var supplierList = supplierSer.GetListArray(string.Format(" SupplierName='{0}' and Status='通过' and IsUse=1 ", txtSupplierName.Text)); if (supplierList.Count > 0) { var supplierModel = supplierList[0]; txtBandName.Text = supplierModel.SupplierBrandName; txtBrandNo.Text = supplierModel.SupplierBrandNo; txtCity.Text = supplierModel.City; txtProvice.Text = supplierModel.Province; hfSimpName.Value = supplierModel.SupplieSimpeName; if (supplierModel.City.Contains("苏州") || supplierModel.City.Contains("太仓") || supplierModel.City.Contains("相城") || supplierModel.City.Contains("吴中") || supplierModel.City.Contains("张家港") || supplierModel.City.Contains("常熟") || supplierModel.City.Contains("昆山")) { foreach (ListItem item in dllBillType.Items) { if (item.Text == "支票") { dllBillType.Text = item.Value; break; } } } else { foreach (ListItem item in dllBillType.Items) { if (item.Text == "银行申请单") { dllBillType.Text = item.Value; break; } } } } } }
protected void Button1_Click(object sender, EventArgs e) { if (FormCheck()) { btnSub.Enabled = false; if (base.Request["ProId"] != null) { #region 获取单据基本信息 DateTime Time = DateTime.Parse(this.txtTime.Text); string SupplierName = this.txtSupplierName.Text.Trim(); string Phone = this.txtPhone.Text; string LikeMan = this.txtLikeMan.Text; string Job = this.txtJob.Text; string FoxOrEmail = this.txtFoxOrEmail.Text; bool IfSave = this.chkIfSave.Checked; string QQMsn = this.txtQQMsn.Text; string SupplierId = this.txtSupplierId.Text; string SupplierAddress = this.txtSupplierAddress.Text; string SupplierHttp = this.txtSupplierHttp.Text; string SupplierShui = this.txtSupplierShui.Text.Trim(); string SupplierGong = this.txtSupplierGong.Text.Trim(); string SupplierBrandNo = this.txtSupplierBrandNo.Text.Trim(); string SupplierBrandName = this.txtSupplierBrandName.Text.Trim(); string Remark = this.txtRemark.Text; int CreateUser = Convert.ToInt32(DBHelp.ExeScalar(string.Format("select ID from tb_User where loginName='{0}'", lblCreateUser.Text))); DateTime CreateTime = DateTime.Now; VAN_OA.Model.ReportForms.TB_SupplierInfo model = new VAN_OA.Model.ReportForms.TB_SupplierInfo(); model.SupplieSimpeName = txtSupplierSimpleName.Text.Trim(); model.Time = Time; model.SupplierName = SupplierName; model.Phone = Phone; model.LikeMan = LikeMan; model.Job = Job; model.FoxOrEmail = FoxOrEmail; model.IfSave = IfSave; model.QQMsn = QQMsn; model.CreateUser = CreateUser; model.CreateTime = CreateTime; model.SupplierId = SupplierId; model.SupplierAddress = SupplierAddress; model.SupplierHttp = SupplierHttp; model.SupplierShui = SupplierShui; model.SupplierGong = SupplierGong; model.SupplierBrandNo = SupplierBrandNo; model.SupplierBrandName = SupplierBrandName; model.Remark = Remark; model.MainRange = txtMainRange.Text; model.ZhuJi = txtZhuJi.Text; model.IsUse = cbIsUse.Checked; model.IsSpecial = cbIsSpecial.Checked; model.City = ddlCity.Text; model.Province = ddlProvince.Text; model.Peculiarity = ddlPeculiarity.Text; #endregion if (Request["allE_id"] == null)//单据增加 { VAN_OA.Model.EFrom.tb_EForm eform = new tb_EForm(); int userId = CreateUser;// Convert.ToInt32(DBHelp.ExeScalar(string.Format("select ID from tb_User where loginName='{0}'", txtName.Text))); eform.appPer = userId; eform.appTime = DateTime.Now; eform.createPer = Convert.ToInt32(Session["currentUserId"].ToString()); eform.createTime = DateTime.Now; eform.proId = Convert.ToInt32(Request["ProId"]); if (ddlPers.Visible == false) { eform.state = "通过"; eform.toPer = 0; eform.toProsId = 0; } else { eform.state = "执行中"; eform.toPer = Convert.ToInt32(ddlPers.SelectedItem.Value); eform.toProsId = Convert.ToInt32(ViewState["ids"]); } TB_SupplierInfoService OverTimeSer = new TB_SupplierInfoService(); if (OverTimeSer.addTran(model, eform) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交成功!');</script>"); if (Session["backurl"] != null) { base.Response.Redirect("~" + Session["backurl"]); } else { base.Response.Redirect("~/EFrom/MyRequestEForms.aspx"); } } else { btnSub.Enabled = false; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交失败!');</script>"); } } else//审核 { #region 本单据的ID model.Id = Convert.ToInt32(Request["allE_id"]); #endregion tb_EForm eform = new tb_EForm(); tb_EForms forms = new tb_EForms(); eform.id = Convert.ToInt32(Request["EForm_Id"]); eform.proId = Convert.ToInt32(Request["ProId"]); eform.allE_id = Convert.ToInt32(Request["allE_id"]); int userId = CreateUser;// Convert.ToInt32(DBHelp.ExeScalar(string.Format("select ID from tb_User where loginName='{0}'", txtName.Text))); eform.appPer = userId; tb_EFormService fromSer = new tb_EFormService(); if (ViewState["ifConsignor"] != null && Convert.ToBoolean(ViewState["ifConsignor"]) == true) { forms.audPer = fromSer.getCurrentAuPer(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])); forms.consignor = Convert.ToInt32(Session["currentUserId"]); } else { forms.audPer = Convert.ToInt32(Session["currentUserId"]); forms.consignor = 0; } if (Request["ReAudit"] == null) { if (fromSer.ifAudiPerAndCon(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])) == false) { if (Session["backurl"] != null) { base.Response.Redirect("~" + Session["backurl"]); } else { base.Response.Redirect("~/EFrom/MyRequestEForms.aspx"); } return; } } forms.doTime = DateTime.Now; forms.e_Id = Convert.ToInt32(Request["EForm_Id"]); //fromSer.getCurrentid(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])); forms.idea = txtResultRemark.Text; forms.prosIds = fromSer.getCurrenttoProsId(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])); forms.resultState = ddlResult.Text; forms.RoleName = fromSer.getCurrenttoRoleName(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])); if (Request["ReAudit"] != null) { forms.RoleName = "重新编辑"; } if (ddlPers.Visible == false)//说明为最后一次审核 { eform.state = ddlResult.Text; eform.toPer = 0; eform.toProsId = 0; } else { if (ddlResult.Text == "不通过") { eform.state = ddlResult.Text; eform.toPer = 0; eform.toProsId = 0; } else { eform.state = "执行中"; eform.toPer = Convert.ToInt32(ddlPers.SelectedItem.Value); eform.toProsId = Convert.ToInt32(ViewState["ids"]); if (Request["ReAudit"] != null)//再次编辑 { VAN_OA.Model.ReportForms.TB_SupplierInfo oldModel = supplierSer.GetModel(Convert.ToInt32(Request["allE_id"])); var m = JsonConvert.SerializeObject(oldModel); var sql = string.Format("insert INTO TB_SupplierInfo_History ([SupplierInfoJosn],[SupplierId]) VALUES ('{0}',{1})", m, Request["allE_id"]); DBHelp.ExeCommand(sql); } } } if (ddlResult.Text == "不通过") { string sql = string.Format("select top 1 SupplierInfoJosn from TB_SupplierInfo_History where SupplierId={0} order by id desc", Request["allE_id"]); var value = DBHelp.ExeScalar(sql); if (value != null && !(value is DBNull)) { model = JsonConvert.DeserializeObject <TB_SupplierInfo>(value.ToString()); eform.state = "通过"; eform.E_Remark = "驳回"; } } TB_SupplierInfoService OverTimeSer = new TB_SupplierInfoService(); if (OverTimeSer.updateTran(model, eform, forms)) { // btnSub.Enabled = true; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交成功!');</script>"); if (Session["backurl"] != null) { base.Response.Redirect("~" + Session["backurl"]); } else { base.Response.Redirect("~/EFrom/MyRequestEForms.aspx"); } } else { btnSub.Enabled = false; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交失败!');</script>"); } } } } }