string type = String.Empty; // 对象类型 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); IList <string> entStrList = RequestData.GetList <string>("data"); switch (RequestActionString) { case "WorkFlowEnd": PayBill ent = PayBill.Find(id); ent.WorkFlowState = RequestData.Get <string>("state"); ent.ExamineResult = RequestData.Get <string>("ApprovalState"); ent.DoUpdate(); break; default: DoSelect(); break; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { string tempsql = @"select A.* ,B.MoneyType,B.Symbo from SHHG_AimExamine..PayBill as A left join SHHG_AimExamine..Supplier as B on A.SupplierId=B.Id where A.Id='{0}'"; tempsql = string.Format(tempsql, id); IList <EasyDictionary> dics = DataHelper.QueryDictList(tempsql); if (dics.Count > 0) { SetFormData(dics[0]); } } } }
protected void Page_Load(object sender, EventArgs e) { switch (RequestActionString) { case "batchdelete": DoBatchDelete(); break; case "FinishPay": IList <string> entStrList = RequestData.GetList <string>("data"); IList <PayBill> ents = entStrList.Select(tent => JsonHelper.GetObject <PayBill>(tent) as PayBill).ToList(); foreach (PayBill pbEnt in ents) { if (!string.IsNullOrEmpty(pbEnt.Id)) { PayBill tempEnt = PayBill.Find(pbEnt.Id); //直接更新会丢失字段信息 tempEnt.State = "已付款"; tempEnt.DoUpdate(); UpdatePayState(tempEnt.Id); } } break; default: DoSelect(); break; } }
string type = String.Empty; // 对象类型 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); PayBill ent = null; switch (RequestActionString) { case "PayBillPay": ent = PayBill.Find(id); ActualPayDetail apdEnt = new ActualPayDetail(); if (!string.IsNullOrEmpty(RequestData.Get <string>("PayAmount"))) { ent.ActuallyPayAmount = ent.ActuallyPayAmount + RequestData.Get <decimal>("PayAmount"); apdEnt.ActualPayAmount = RequestData.Get <decimal>("PayAmount"); } apdEnt.PayBillId = ent.Id; apdEnt.CreateId = UserInfo.UserID; apdEnt.CreateName = UserInfo.Name; apdEnt.CreateTime = System.DateTime.Now; apdEnt.Remark = RequestData.Get <string>("Remark"); ent.DoUpdate(); apdEnt.DoCreate(); IList <PayBillDetail> pbdEnts = PayBillDetail.FindAll("from PayBillDetail where PayBillId='" + ent.Id + "'"); Supplier supplierEnt = Supplier.Find(ent.SupplierId); if (supplierEnt.Symbo == "¥") //如果付款单的币种为本币 { if (ent.PAmount == ent.ActuallyPayAmount + (ent.DiscountAmount.HasValue ? ent.DiscountAmount.Value : 0)) { ent.State = "已付款"; ent.DoUpdate(); } } //付款成功后 如果付款单为已付款状态 遍历采购单详细 if (ent.State == "已付款") { string tempsql = @"select * from SHHG_AimExamine..PayBillDetail where PayBillId='{0}'"; tempsql = string.Format(tempsql, ent.Id); IList <EasyDictionary> dicPayDetail = DataHelper.QueryDictList(tempsql); PurchaseOrderDetail podEnt = null; ArrayList idarray = new ArrayList(); //搜集涉及的采购单ID string poId = string.Empty; string podId = string.Empty; int nopay = 0; foreach (EasyDictionary ea in dicPayDetail) { podId = ea.Get <string>("PurchaseOrderDetailId"); podEnt = PurchaseOrderDetail.TryFind(podId); //取得采购详细的实际未付款数目 nopay = Convert.ToInt32(DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_ActuallNoPayQuan('" + podId + "')")); if (nopay == 0) { podEnt.PayState = "已付款"; podEnt.DoUpdate(); } if (podEnt.PurchaseOrderId != poId) { poId = podEnt.PurchaseOrderId; idarray.Add(poId); } } //付款单涉及的采购详细表状态遍历完后。再遍历付款单涉及的采购单 PurchaseOrder poEnt = null; foreach (object ob in idarray) { IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where PayState='未付款' and PurchaseOrderId='" + ob.ToString() + "'"); if (podEnts.Count == 0) { poEnt = PurchaseOrder.TryFind(ob.ToString()); poEnt.PayState = "已付款"; if (poEnt.InvoiceState == "已关联" && poEnt.InWarehouseState == "已入库") { poEnt.OrderState = "已结束"; } poEnt.DoUpdate(); } } } break; default: DoSelect(); break; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { string tempsql = @"select A.* ,B.MoneyType,B.Symbo from SHHG_AimExamine..PayBill as A left join SHHG_AimExamine..Supplier as B on A.SupplierId=B.Id where A.Id='{0}'"; tempsql = string.Format(tempsql, id); IList <EasyDictionary> dics = DataHelper.QueryDictList(tempsql); if (dics.Count > 0) { this.SetFormData(dics[0]); } } } }
protected void Page_Load(object sender, EventArgs e) { try { Aim.Portal.Web.WebPortalService.CheckLogon(); } catch { Response.Write("<script> window.location.href = '/Login.aspx';</script>"); Response.End(); } string action = Request["action"]; string where = ""; DataTable dt = null; string id = Request["id"]; PayBill pbEnt = null; if (!string.IsNullOrEmpty(id)) { pbEnt = PayBill.Find(id); } IList <PayBillDetail> pbdEnts = null; switch (action) { case "load": if (!string.IsNullOrEmpty(Request["PayBillNo"])) { where += " and PayBillNo like '%" + Request["PayBillNo"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["SupplierName"])) { where += " and SupplierName like '%" + Request["SupplierName"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["State"])) { where += " and State = '" + Request["State"] + "'"; } if (!string.IsNullOrEmpty(Request["ProductCode"])) { where += " and Id in (select distinct PayBillId from SHHG_AimExamine..PayBillDetail where ProductCode like '%" + Request["ProductCode"] + "%')"; } sql = @"select * from SHHG_AimExamine..PayBill where 1=1 " + where; dt = DataHelper.QueryDataTable(GetPageSql(sql)); Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "loaddetail": sql = @"select a.*,c.PurchaseOrderNo from SHHG_AimExamine..PayBillDetail a left join SHHG_AimExamine..PurchaseOrderDetail b on a.PurchaseOrderDetailId=b.Id left join SHHG_AimExamine..PurchaseOrder c on b.PurchaseOrderId=c.Id where a.PayBillId='" + id + "' order by a.ProductCode asc"; dt = DataHelper.QueryDataTable(sql); Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "delete": pbEnt = PayBill.Find(id); pbdEnts = PayBillDetail.FindAllByProperty("PayBillId", id); foreach (PayBillDetail tempEnt in pbdEnts) { //删除完付款单明细后需要更新入库单明细的生成付款单的数量 if (!string.IsNullOrEmpty(tempEnt.InWarehouseDetailId)) { InWarehouseDetail iwdEnt = InWarehouseDetail.Find(tempEnt.InWarehouseDetailId); iwdEnt.FuKuanDanQuan = iwdEnt.FuKuanDanQuan - tempEnt.PayQuantity; iwdEnt.DoUpdate(); tempEnt.DoDelete(); } } //如果已经审批过了,还需要删除workflowinstance task记录 IList <WorkflowInstance> wiEnts = WorkflowInstance.FindAllByProperty(WorkflowInstance.Prop_EFormInstanceID, pbEnt.Id); foreach (WorkflowInstance wiEnt in wiEnts) { IList <Task> tEnts = Task.FindAllByProperty(Task.Prop_WorkflowInstanceID, wiEnt.ID); foreach (Task tEnt in tEnts) { tEnt.DoDelete(); } } pbEnt.DoDelete(); Response.Write("{success:true}"); Response.End(); break; case "examine": WorkflowTemplate ne = WorkflowTemplate.FindAllByProperties(Aim.WorkFlow.WorkflowTemplate.Prop_Code, Request["flowkey"])[0]; string formUrl = "/PurchaseManagement/PayBillView.aspx?id=" + id; //启动流程表单路径,后面加上参数传入 Guid instanceid = Aim.WorkFlow.WorkFlow.StartWorkFlow(id, formUrl, "付款单【" + pbEnt.PayBillNo + "】申请人【" + pbEnt.CreateName + "】", Request["flowkey"], WebPortalService.CurrentUserInfo.UserID, WebPortalService.CurrentUserInfo.Name); pbEnt.WorkFlowState = "flowing"; pbEnt.ExamineResult = "已提交"; pbEnt.DoUpdate(); Response.Write("{success:true,instanceid:'" + instanceid + "'}"); Response.End(); break; case "autoexec": Task task = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, Request["instanceid"])[0]; Aim.WorkFlow.WorkFlow.AutoExecute(task); Response.Write("{success:true}"); Response.End(); break; } }