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"); StockCheck scEnt = null; IList <String> strList = RequestData.GetList <string>("data"); switch (RequestActionString) { case "update": scEnt = this.GetMergedData <StockCheck>(); scEnt.DoUpdate(); ProcessDetail(strList, scEnt); break; case "create": scEnt = this.GetPostedData <StockCheck>(); scEnt.State = "未结束"; scEnt.DoCreate(); ProcessDetail(strList, scEnt); break; case "delete": scEnt = this.GetTargetData <StockCheck>(); scEnt.DoDelete(); return; default: if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { scEnt = StockCheck.Find(id); SetFormData(scEnt); IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAllByProperty("StockCheckId", id); PageState.Add("DataList", scdEnts); } } else { PageState.Add("StockCheckNo", DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getStockCheckNo()")); this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple")); if (RequestActionString == "submitfinish") { StockCheck pc = StockCheck.Find(this.RequestData.Get <string>("id")); pc.State = "End"; // pc.InventoryState = this.RequestData.Get<string>("ApprovalState"); pc.Save(); } } break; } }
protected void Page_Load(object sender, EventArgs e) { StockCheck ent = null; switch (RequestActionString) { case "delete": ent = this.GetTargetData <StockCheck>(); ent.DoDelete(); break; case "batchdelete": DoBatchDelete(); break; case "SubmitExamine": string id = this.RequestData.Get <string>("Id"); ent = StockCheck.Find(id); ent.WorkFlowState = RequestData.Get <string>("state"); ent.ExamineResult = RequestData.Get <string>("ApprovalState"); ent.DoUpdate(); StartFlow(id); break; case "AutoExecuteFlow": Task task = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"))[0]; //自动执行,关键代码 Aim.WorkFlow.WorkFlow.AutoExecute(task); this.PageState.Add("TaskId", task.ID); break; default: if (RequestData.Get <string>("optype") == "getChildData") { string stockCheckId = RequestData.Get <string>("StockCheckId"); IList <StockCheckDetail> scdEnt = StockCheckDetail.FindAllByProperty("StockCheckId", stockCheckId); PageState.Add("DetailList", scdEnt); } else { DoSelect(); } break; } }
private void ProcessDetail(IList <string> strList, StockCheck ent) { StockCheckDetail scdEnt = null; foreach (string str in strList) { JObject json = JsonHelper.GetObject <JObject>(str); scdEnt = StockCheckDetail.Find(json.Value <string>("Id")); if (json.Value <int>("StockCheckQuantity") >= 0) { scdEnt.StockCheckQuantity = json.Value <int>("StockCheckQuantity"); if (scdEnt.StockQuantity > scdEnt.StockCheckQuantity) { scdEnt.StockCheckResult = "盘亏"; } if (scdEnt.StockQuantity < scdEnt.StockCheckQuantity) { scdEnt.StockCheckResult = "盘赢"; } if (scdEnt.StockQuantity == scdEnt.StockCheckQuantity) { scdEnt.StockCheckResult = "正常"; scdEnt.StockCheckState = "盘点结束"; } scdEnt.DoUpdate(); } } //1 如果所有的盘点明细都正常 则把盘点单的状态改为已结束 SearchCriterion.AddSearch("StockCheckResult", "正常", SearchModeEnum.NotEqual); IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAll(SearchCriterion); if (scdEnts.Count == 0) { ent.State = "已结束"; ent.Result = "正常"; } else { ent.Result = "异常"; } ent.DoUpdate(); }
protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); ent = StockCheck.Find(id); switch (RequestActionString) { case "WorkFlowEnd": ent.WorkFlowState = RequestData.Get <string>("state"); ent.ExamineResult = RequestData.Get <string>("ApprovalState"); ent.State = "已结束"; ent.DoUpdate(); IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAllByProperty("StockCheckId", id); foreach (StockCheckDetail scdEnt in scdEnts) { if (scdEnt.StockCheckResult != "正常") { scdEnt.StockCheckState = "盘点结束"; scdEnt.DoUpdate(); } } if (ent.ExamineResult == "同意") { foreach (StockCheckDetail scdEnt in scdEnts) { if (scdEnt.StockCheckResult != "正常") //创建库存变更日志 并更改库存 { StockLog slEnt = new StockLog(); slEnt.InOrOutDetailId = scdEnt.Id; StockCheck scEnt = StockCheck.Find(scdEnt.StockCheckId); slEnt.InOrOutBillNo = scEnt.StockCheckNo; slEnt.OperateType = "库存盘点"; slEnt.WarehouseId = scEnt.WarehouseId; slEnt.WarehouseName = scEnt.WarehouseName; slEnt.StockQuantity = scdEnt.StockQuantity; slEnt.Quantity = scdEnt.StockCheckQuantity - scdEnt.StockQuantity; slEnt.ProductId = scdEnt.ProductId; Product pEnt = Product.Find(scdEnt.ProductId); slEnt.ProductName = pEnt.Name; slEnt.ProductCode = pEnt.Code; slEnt.ProductIsbn = pEnt.Isbn; slEnt.ProductPcn = pEnt.Pcn; slEnt.CreateId = UserInfo.UserID; slEnt.CreateName = UserInfo.Name; slEnt.CreateTime = System.DateTime.Now; slEnt.DoCreate(); IList <StockInfo> siEnts = StockInfo.FindAllByProperties("ProductId", scdEnt.ProductId, "WarehouseId", ent.WarehouseId); if (siEnts.Count > 0) { siEnts[0].StockQuantity = scdEnt.StockCheckQuantity; siEnts[0].DoUpdate(); } } } } break; default: DoSelect(); break; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { SetFormData(ent); } } }