protected void btnEdit_Click(object sender, EventArgs e) { #region 设置自己要判断的信息 if (txtName.Text.Trim() == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写姓名!');</script>"); txtName.Focus(); return; } if (txtCreateTime.Text.Trim() == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写领用日期!');</script>"); txtCreateTime.Focus(); return; } try { Convert.ToDateTime(txtCreateTime.Text); } catch (Exception) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('你填写的时间格式有误!');</script>"); txtCreateTime.Focus(); return; } #endregion Tb_ExpInv model = new Tb_ExpInv(); model.ExpTime = Convert.ToDateTime(txtCreateTime.Text); List <Tb_ExpInvs> projectList = Session["ProInvs"] as List <Tb_ExpInvs>; model.Id = Convert.ToInt32(Request["allE_id"]); string IDS = ViewState["ProInvsIds"].ToString(); Tb_ExpInvService proMainSer = new Tb_ExpInvService(); if (proMainSer.updateTran(model, projectList, IDS)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交成功!');</script>"); } else { btnSub.Enabled = false; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交失败!');</script>"); } }
protected void Button1_Click(object sender, EventArgs e) { if (FormCheck()) { if (ddlPers.Visible == false && lblOutState.Text != "已发货") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须先确认发货才能通过!');</script>"); return; } btnSub.Enabled = false; if (base.Request["ProId"] != null) { List <Tb_ExpInvs> projectList_1 = Session["ProInvs"] as List <Tb_ExpInvs>; if (Request["allE_id"] == null)//单据增加 { if (projectList_1.Count <= 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写领料信息!');</script>"); btnSub.Enabled = true; return; } Tb_ExpInvsService mainSer = new Tb_ExpInvsService(); string ids = ""; foreach (var model1 in projectList_1) { ids += model1.InvId + ","; } if (ids.Length > 0) { ids = ids.Substring(0, ids.Length - 1); List <Tb_ExpInvs> sumRep = mainSer.GroupByListArray(string.Format(" 1=1 and Tb_Inventory.Id in({0})", ids)); foreach (var model1 in sumRep) { var currentModel = projectList_1.Find(p => p.InvId == model1.InvId); if (model1.ExpNum - currentModel.ExpNum < 0) { List <Model.ReportForms.Tb_ExpInvsSumRep> detailInv = mainSer.GetListArray_NoReurnInvs(" Tb_Inventory.Id=" + model1.InvId); string mess = string.Format("货品[{0}]剩余数量不足\\n", currentModel.InvName); foreach (var detailModel in detailInv) { if (detailModel.InvName == "小计" || detailModel.LoginName == null || detailModel.LoginName == "") { continue; } mess += string.Format("借出人:{0},数量{1}\\n", detailModel.LoginName, detailModel.ExpNum); } mess += model1.InvName + " 你预计借出数量 " + currentModel.ExpNum; btnSub.Enabled = true; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + mess + "!');</script>"); return; } } } } if (ddlPers.Visible == false) { int count = projectList_1.FindAll(p => p.ReturnTime == null).Count; if (count > 0) { btnSub.Enabled = true; base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('单据存在尚未归还的货品信息,无法提交!');</script>"); return; } } #region 获取单据基本信息 Tb_ExpInv model = new Tb_ExpInv(); model.CreateUserId = Convert.ToInt32(DBHelp.ExeScalar(string.Format("select ID from tb_User where loginName='{0}'", txtName.Text))); model.ExpTime = Convert.ToDateTime(txtCreateTime.Text); List <Tb_ExpInvs> projectList = Session["ProInvs"] as List <Tb_ExpInvs>; #endregion if (Request["allE_id"] == null)//单据增加 { VAN_OA.Model.EFrom.tb_EForm eform = new tb_EForm(); int userId = 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_ExpInvService proMainSer = new Tb_ExpInvService(); if (proMainSer.addTran(model, eform, projectList) > 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 = 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; } 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 (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"]); } } string IDS = ViewState["ProInvsIds"].ToString(); Tb_ExpInvService proMainSer = new Tb_ExpInvService(); if (proMainSer.updateTran(model, eform, forms, projectList, IDS)) { // 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>"); } } } } }