public static void ProductInStoreCheck(long id) { var bl = BIFactory.Create <IProductInStoreBL>(); var bo = bl.Load(id); bl.Check(bo); }
public static long CreateOutPut(ProduceOutput output) { using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IProduceOutputBL>(session); output.Domain_ID = DomainContext.Current.ID; foreach (var detail in output.Details) { if (detail.Goods_ID == 0) { var goodsid = GetGoodsIdByName(session, detail.Goods_Name); if (goodsid == null || goodsid == 0) { throw new Exception("没有找到计数名称:" + detail.Goods_Name + " 对应的存货"); } detail.Goods_ID = goodsid.Value; } } bl.Insert(output); return(output.ID); } }
public static ProductInStore Load(long id) { var bl = BIFactory.Create <IProductInStoreBL>(); var dmo = bl.Load(id); return(dmo); }
public static long?ProductInStoreSaveAndCheck(ProductInStore dto) { if (!BLContext.User.IsInRole("B3Butchery.成品入库.新建")) { return(0); } if (!BLContext.User.IsInRole("B3Butchery.成品入库.审核")) { return(-1); } using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProductInStoreBL>(context.Session); var dmo = bl.Load(dto.ID); foreach (var detail in dmo.Details) { var fd = dto.Details.FirstOrDefault(x => x.ID == detail.ID); if (fd != null) { detail.Number = fd.Number; detail.SecondNumber = fd.Number * fd.Goods_SecondUnitRatio / fd.Goods_MainUnitRatio; } } bl.Update(dmo); bl.Check(dmo); context.Commit(); return(dmo.ID); } }
public static void InsertProductInStore(ProductInStore dmo) { var query = new DQueryDom(new JoinAlias(typeof(ProductInStore))); query.Columns.Add(DQSelectColumn.Field("DeviceId")); query.Where.Conditions.Add(DQCondition.EQ("InStoreDate", dmo.InStoreDate)); var deviceIds = query.EExecuteList <string>(); if (deviceIds.Contains(dmo.DeviceId)) { return; } using (var context = new TransactionContext()) { foreach (var d in dmo.Details) { d.Price = 0; d.Money = 0; d.ProductionDate = GetProductPlanDate(d.ProductPlan_ID); } var bl = BIFactory.Create <IProductInStoreBL>(context); //dmo.BillState = 单据状态.已审核; dmo.IsHandsetSend = true; bl.Insert(dmo); if (new B3ButcheryConfig().DoCheckCreatedInStore.Value) { bl.Check(dmo); } context.Commit(); } }
private void CreateFrozenOutStore(WorkShopPackBill dmo) { var bl = BIFactory.Create <IFrozenOutStoreBL>(Session); var bo = new FrozenOutStore(); bl.InitNewDmo(bo); bo.AccountingUnit_ID = dmo.AccountingUnit_ID; bo.Department_ID = dmo.Department_ID; bo.WorkBill_ID = dmo.ID; bo.Date = dmo.Date; var group = dmo.Details.GroupBy(x => new { x.PlanNumber_ID, x.Goods_ID }); foreach (var one in group) { var de = new FrozenOutStore_Detail(); de.Goods2_ID = one.Key.Goods_ID; de.Goods_ID = GetBanChengPinByGoodsID(one.Key.Goods_ID) ?? 0; DmoUtil.RefreshDependency(de, "Goods_ID", "Goods2_ID"); de.PlanNumber_ID = one.Key.PlanNumber_ID; de.Number = one.Sum(x => (x.Number ?? 0).Value); if (de.Goods_SecondUnitII_MainUnitRatio != null && de.Goods_SecondUnitII_MainUnitRatio != 0) { de.SecondNumber2 = de.Number / de.Goods_SecondUnitII_MainUnitRatio * de.Goods_SecondUnitII_SecondUnitRatio; } if (de.Goods_MainUnitRatio != null && de.Goods_MainUnitRatio != 0) { de.SecondNumber = de.Number / de.Goods_MainUnitRatio * de.Goods_SecondUnitRatio; } bo.Details.Add(de); } bl.Insert(bo); }
public static long PdaInsertAndCheck(FrozenInStore dmo) { if (!BLContext.User.IsInRole("B3Butchery.产出单.新建")) { return(0); } if (!BLContext.User.IsInRole("B3Butchery.产出单.审核")) { return(-1); } SetSecondNumberByNumber(dmo); using (var context = new TransactionContext()) { var bl = BIFactory.Create <IFrozenInStoreBL>(context.Session); dmo.Date = dmo.Date ?? DateTime.Today; dmo.Employee_ID = B3ButcheryUtil.GetCurrentBindingEmployeeID(context.Session); bl.InitNewDmo(dmo); bl.Insert(dmo); bl.Check(dmo); context.Commit(); } return(dmo.ID); }
public static long?DeleteByFrozenInStore(long?frozenInStoreId) { if (!BLContext.User.IsInRole("B3Butchery.成品入库.删除")) { return(-3); } long?id = null; using (var context = new TransactionContext()) { var frozenInStoreBl = BIFactory.Create <IFrozenInStoreBL>(context.Session); var frozenInStoreDmo = frozenInStoreBl.Load(Convert.ToInt64(frozenInStoreId)); var query = new DQueryDom(new JoinAlias(typeof(ProductInStore))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.未审核)); query.Where.Conditions.Add(DQCondition.EQ("Client", frozenInStoreDmo.Client)); var result = query.EExecuteList <long?>(); foreach (var l in result) { var bl = BIFactory.Create <IProductInStoreBL>(context); var obj = bl.Load(Convert.ToInt64(l)); id = (int)obj.ID; bl.Delete(obj); } context.Commit(); } return(id); }
public static long Insert(ProduceOutput dmo) { var bl = BIFactory.Create <IProduceOutputBL>(); bl.InitNewDmo(dmo); bl.Insert(dmo); return(dmo.ID); }
public static long CreateOutPutByJson2(string json) { var dto = JsonConvert.DeserializeObject <OutPutDto>(json); using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IProduceOutputBL>(session); var dmo = new ProduceOutput(); dmo.Domain_ID = DomainContext.Current.ID; dmo.AccountingUnit_ID = dto.AccountingUnit_ID; dmo.Department_ID = dto.Department_ID; dmo.ProductionUnit_ID = dto.ProductionUnit_ID; dmo.Time = dto.Time; foreach (var dtodetail in dto.Details) { var detail = new ProduceOutput_Detail(); detail.Goods_ID = dtodetail.Goods_ID ?? 0; detail.CalculateGoods_ID = dtodetail.CalculateGoods_ID; detail.Goods_Name = dtodetail.Goods_Name; detail.Remark = dtodetail.CalculateSpec_Name; detail.Number = dtodetail.Number; detail.SecondNumber = dtodetail.SecondNumber; detail.SecondNumber2 = dtodetail.SecondNumber2; detail.RecordCount = dtodetail.RecordCount; //detail.CalculateCatalog_Name = dtodetail.CalculateCatalog_Name; //var calculateCatalog = GetCalculateCatalogIDByName(session, detail.Goods_Name); //if (calculateCatalog != null) //{ // detail.CalculateCatalog_ID = calculateCatalog.Item1; // detail.CalculateGoods_ID = calculateCatalog.Item2; //} if (detail.Goods_ID == 0) { var goodsid = GetGoodsIdByName2(session, detail.Goods_Name); if (goodsid == null || goodsid == 0) { throw new Exception("没有找到存货名称:" + detail.Goods_Name + " 对应的存货"); } detail.Goods_ID = goodsid.Value; } var id = GetProductIdByName(session, dtodetail.PlanNumber); if (id == null) { throw new Exception("生产计划中不存在" + dtodetail.PlanNumber + "计划号"); } detail.PlanNumber_ID = id; dmo.Details.Add(detail); } bl.Insert(dmo); session.Commit(); return(dmo.ID); } }
public static FormData FormActions(string action, FormData data) { var productInput = (ProduceInput)data.MainObject; var bl = BIFactory.Create <IProduceInputBL>(); switch (action) { case FormActionNames.Load: var dom = bl.Load(productInput.ID); data.MainObject = dom; break; case FormActionNames.Save: if (productInput.ID == 0) { bl.InitNewDmo(productInput); bl.Insert(productInput); data.MainObject = productInput; return(FormActions(FormActionNames.Load, data)); } bl.Update(productInput); return(FormActions(FormActionNames.Load, data)); case FormActionNames.New: var dmo = new ProduceInput(); data.MainObject = dmo; break; case FormActionNames.Prev: var prevDmo = GetPrevOrNext(productInput.ID); if (prevDmo == null) { throw new IndexOutOfRangeException("Current is first"); } data.MainObject = prevDmo; break; case FormActionNames.Next: var nextDmo = GetPrevOrNext(productInput.ID, false); if (nextDmo == null) { throw new IndexOutOfRangeException("Current is last"); } data.MainObject = nextDmo; break; //case "LoadDetail": // LoadDetail(productInput); // break; default: throw new ArgumentException("Unknown action: " + action); } return(data); }
public static long CreateWorkShopPackJson(string json) { var dto = JsonConvert.DeserializeObject <WorkShopDto>(json); using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IWorkShopPackBillBL>(session); var dmo = new WorkShopPackBill(); // dmo.MiddleWorkBillID = dto.MiddleWorkBillID; dmo.Domain_ID = DomainContext.Current.ID; dmo.AccountingUnit_ID = dto.AccountingUnit_ID; dmo.Department_ID = dto.Department_ID; dmo.Date = dto.Time; dmo.Store_ID = dto.Store_ID; dmo.ChaCarBarCode = dto.Code; foreach (var dtodetail in dto.Details) { var detail = new WorkShopRecord(); detail.Goods_ID = dtodetail.Goods_ID ?? 0; detail.Goods_Name = dtodetail.Goods_Name; detail.Remark = dtodetail.CalculateSpec_Name; detail.Number = dtodetail.Number; detail.SecondNumber = dtodetail.SecondNumber; detail.SecondNumber2 = dtodetail.SecondNumber2; detail.ChaCarBoardCode = dtodetail.ChaCarBarCode; detail.BarCode = dtodetail.Code; var id = GetProductIdByName(session, dtodetail.PlanNumber); if (id == null) { //throw new Exception("生产计划中不存在" + dtodetail.PlanNumber + "计划号"); } detail.PlanNumber_ID = id; //if (detail.Goods_ID == 0) //{ // var goodsid = GetGoodsIdByName(session, detail.Goods_Name); // if (goodsid == null || goodsid == 0) // { // throw new Exception("没有找到计数名称:" + detail.Goods_Name + " 对应的存货"); // } // detail.Goods_ID = goodsid.Value; //} dmo.Details.Add(detail); } bl.Insert(dmo); bl.Check(dmo); session.Commit(); return(dmo.ID); } }
public static long CreateHandoverRecordJson(string json) { var dto = JsonConvert.DeserializeObject <HandoverRecord>(json); using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IHandoverRecordBL>(session); bl.Insert(dto); session.Commit(); return(dto.ID); } }
protected override void InitLoadedMinDmo(ButcheryGoods mMinDmo) { base.InitLoadedMinDmo(mMinDmo); if (mMinDmo.GoodsProperty_ID.HasValue) { mMinGoodsProperty = BIFactory.Create <IGoodsPropertyBL>().LoadMinDmo(mMinDmo.GoodsProperty_ID.Value); if (mMinGoodsProperty == null) { throw new Exception("存货上的存货属性在数据库中已不存在"); } } }
public static long?UnCheck(long id) { if (!BLContext.User.IsInRole("B3Butchery.速冻入库.撤销")) { return(0); } using (var context = new TransactionContext()) { var bl = BIFactory.Create <IFrozenInStoreBL>(context.Session); var dmo = bl.Load(id); bl.UnCheck(dmo); context.Commit(); return(dmo.ID); } }
public static long InsertProductInStore(ProductInStore dmo) { using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProductInStoreBL>(context); bl.InitNewDmo(dmo); dmo.InStoreDate = BLContext.Today; foreach (var detail in dmo.Details) { DmoUtil.RefreshDependency(detail, "Goods_ID"); } bl.Insert(dmo); context.Commit(); return(dmo.ID); } }
public static long?Nullify(long id) { if (!BLContext.User.IsInRole("B3Butchery.产出单.作废")) { return(0); } using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProduceOutputBL>(context.Session); var dmo = bl.Load(id); bl.Nullify(dmo); context.Commit(); return(dmo.ID); } }
public static long PdaInsert(ProduceOutput dmo) { using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProduceOutputBL>(context.Session); dmo.Time = DateTime.Today; dmo.IsHandsetSend = true; dmo.Employee_ID = B3ButcheryUtil.GetCurrentBindingEmployeeID(context.Session); // bl.InitNewDmo(dmo); 板块信息由手持机传入 bl.Insert(dmo); bl.Check(dmo); context.Commit(); } return(dmo.ID); }
public static void InsertProduceOutput(ProduceOutput dmo) { using (var context = new TransactionContext()) { foreach (var d in dmo.Details) { d.Price = 0; d.Money = 0; } var bl = BIFactory.Create <IProduceOutputBL>(context); dmo.Time = BLContext.Today; dmo.BillState = 单据状态.已审核; dmo.IsHandsetSend = true; bl.Insert(dmo); context.Commit(); } }
public static long AppInsert(ProductInStore dmo) { var bl = BIFactory.Create <IProductInStoreBL>(); foreach (ProductInStore_Detail detail in dmo.Details) { DmoUtil.RefreshDependency(detail, "Goods_ID"); if (detail.Number == null && detail.SecondNumber.HasValue) { detail.Number = detail.SecondNumber * detail.Goods_MainUnitRatio / detail.Goods_SecondUnitRatio; } } // bl.InitNewDmo(dmo); dmo.Domain_ID = DomainContext.Current.ID; bl.Insert(dmo); return(dmo.ID); }
public static long PdaInsertAndCheck(ProduceOutput dmo) { SetSecondNumberByNumber(dmo); using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProduceOutputBL>(context.Session); dmo.Time = dmo.Time ?? DateTime.Today; dmo.Employee_ID = B3ButcheryUtil.GetCurrentBindingEmployeeID(context.Session); bl.InitNewDmo(dmo); bl.Insert(dmo); bl.Check(dmo); context.Commit(); } return(dmo.ID); }
private void DeleteFrozenOutStore(WorkShopPackBill dmo) { var bl = BIFactory.Create <IFrozenOutStoreBL>(Session); var id = GetFrozenId(dmo.ID); var bo = bl.Load(id ?? 0); if (bo != null) { if (bo.BillState == 单据状态.已审核) { throw new Exception("关联单据" + id + "已审核"); } else if (bo.BillState == 单据状态.未审核) { bl.Delete(bo); } } }
public static void AppUpdateByDetail(ProductInStoreSimpleDto dto) { var bl = BIFactory.Create <IProductInStoreBL>(); var dmo = bl.Load(dto.ID); dmo.Store_ID = dto.Store_ID; dmo.Department_ID = dto.Department_ID; dmo.InStoreDate = dto.Date; dmo.Remark = dto.Remark; var fd = dmo.Details.FirstOrDefault(x => x.Goods_ID == dto.Goods_ID); if (fd != null) { fd.SecondNumber = dto.SecondNumber; fd.Number = fd.SecondNumber * fd.Goods_MainUnitRatio / fd.Goods_SecondUnitRatio; } bl.Update(dmo); }
public static long ButcherTouchScreenInsert(FrozenInStore dmo) { using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IFrozenInStoreBL>(session); var profile = DomainUserProfileUtil.Load <B3ButcheryUserProfile>(); dmo.AccountingUnit_ID = profile.AccountingUnit_ID; dmo.Store_ID = profile.FrozenInStore_Store_ID; SetEmployeeDepartment(dmo, session); SetProductPlan(dmo, session); //日期默认当天 dmo.Date = DateTime.Today; dmo.Domain_ID = DomainContext.Current.ID; bl.Insert(dmo); session.Commit(); return(dmo.ID); } }
public static long InertAndCheck(string json) { PackingRecipients jsonDom = JsonConvert.DeserializeObject <PackingRecipients>(json); long returnid; using (new SpecialDomainUserBLScope(jsonDom.CreateUser_Name)) { //判断是否有权限 if (!BLContext.User.IsInRole("B3Butchery.包装领用.新建")) { throw new Exception("没有新建权限"); } using (var session = Dmo.NewSession()) { var bl = BIFactory.Create <IPackingRecipientsBL>(session); // bl.InitNewDmo(jsonDom); var profile = DomainUserProfileUtil.Load <B3ButcheryUserProfile>(); if (profile.AccountingUnit_ID == null) { throw new Exception("板块个性设置没有设置会计单位"); } if (profile.PackingRecipients_Store_ID == null) { throw new Exception("板块个性设置没有设置包装领用默认仓库"); } jsonDom.AccountingUnit_ID = profile.AccountingUnit_ID; jsonDom.Domain_ID = DomainContext.Current.ID; jsonDom.Store_ID = profile.PackingRecipients_Store_ID; //插入单据 bl.Insert(jsonDom); //审核 bl.Check(jsonDom); returnid = jsonDom.ID; session.Commit(); } } return(returnid); }
private void DoExecute() { var days = Days ?? 0; var date = DateTime.Today.AddDays(-1 * days); var ids = FindNeedNullifyBillIDs(date); if (ids == null || ids.Count == 0) { return; } var bl = BIFactory.Create <IProductNoticeBL>(); foreach (var item in ids) { var dmo = bl.Load(item); if (dmo == null) { continue; } bl.Nullify(dmo); } }
public void Import(Stream fileStream) { var man = new ExcelImportManager(); var accColumn = man.Add(new ExecelImportColumn() { Name = "会计单位", Required = true, Nullable = false }); var deptColumn = man.Add(new ExecelImportColumn() { Name = "部门", Required = true, Nullable = false }); var empColumn = man.Add(new ExecelImportColumn() { Name = "经办人", Required = true, Nullable = false }); var timeColumn = man.Add(new ExecelImportColumn() { Name = "日期", Required = true, Nullable = false }); var planNumberColumn = man.Add(new ExecelImportColumn() { Name = "计划号", Required = false, Nullable = true }); var productLinksColumn = man.Add(new ExecelImportColumn() { Name = "生产环节", Required = false, Nullable = true }); var remarkColumn = man.Add(new ExecelImportColumn() { Name = "摘要", Required = false, Nullable = true }); var nameColumn = man.Add(new ExecelImportColumn() { Name = "存货名称", Required = true, Nullable = false }); var codeColumn = man.Add(new ExecelImportColumn() { Name = "存货编码", Required = false, Nullable = true }); var numberColumn = man.Add(new ExecelImportColumn() { Name = "数量", Required = true, Nullable = false }); var detailRemarkColumn = man.Add(new ExecelImportColumn() { Name = "备注", Required = false, Nullable = true }); var billList = new DmoCollection <ProduceOutput>(); int i = 0; using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProduceOutputBL>(context); foreach (var row in man.Parse(fileStream)) { var bill = new ProduceOutput(); bl.InitNewDmo(bill); i++; bill.ID = i; billList.Add(bill); long accID = default(long); if (accColumn.TryGetIDByName <AccountingUnit>(row, ref accID)) { bill.AccountingUnit_ID = accID; } long deptID = default(long); if (deptColumn.TryGetIDByName <Department>(row, ref deptID)) { bill.Department_ID = deptID; } long empID = default(long); if (empColumn.TryGetIDByName <Employee>(row, ref empID)) { bill.Employee_ID = empID; } long planNumberID = default(long); if (ExecelImportHelper.TryGetID <ProductPlan>(planNumberColumn, row, "PlanNumber", ref planNumberID)) { bill.PlanNumber_ID = planNumberID; } long productLinksID = default(long); if (productLinksColumn.TryGetIDByName <ProductLinks>(row, ref productLinksID)) { bill.ProductLinks_ID = productLinksID; } DateTime time = default(DateTime); if (timeColumn.TryGetValue(row, ref time)) { bill.Time = time; } bill.Remark = remarkColumn.GetStringValue(row); var detail = new ProduceOutput_Detail(); long goodsID = default(long); if (codeColumn.TryGetIDByCode <Goods>(row, ref goodsID)) { detail.Goods_ID = goodsID; } else if (nameColumn.TryGetIDByName <Goods>(row, ref goodsID)) { detail.Goods_ID = goodsID; } decimal number = default(decimal); if (numberColumn.TryGetValue(row, ref number)) { detail.Number = number; } detail.Remark = detailRemarkColumn.GetStringValue(row); DmoUtil.RefreshDependency(detail, "Goods_ID"); ConvertToSecondNumber(detail); bill.Details.Add(detail); } foreach (var group in billList.GroupBy(x => new { x.Time, x.AccountingUnit_ID, x.Employee_ID, x.Department_ID, x.PlanNumber_ID, x.ProductLinks_ID })) { var dmo = group.FirstOrDefault(); foreach (var produceOutput in group) { if (dmo.ID == produceOutput.ID) { continue; } foreach (var detail in produceOutput.Details) { dmo.Details.Add(detail); } } dmo.ID = 0; bl.Insert(dmo); } context.Commit(); } }
public static long InertAndCheck(string json) { //static JavaScriptSerializer serializer = new JavaScriptSerializer(); //var list = serializer.Deserialize<List<CTuple<long, string, string>>>(result); //反序列化读取数据 WorkShopPackBill jsonDom = JsonConvert.DeserializeObject <WorkShopPackBill>(json); long returnid; using (new SpecialDomainUserBLScope(jsonDom.CreateUser_Name)) { //判断是否有权限 if (!BLContext.User.IsInRole("B3Butchery.车间包装.新建")) { throw new Exception("没有新建权限"); } //事务 using (var session = Dmo.NewSession()) { var dmo = GetBillByChaCarBarCode(session, jsonDom.ChaCarBarCode); //dmo.Domain_ID = DomainContext.Current.ID var bl = BIFactory.Create <IWorkShopPackBillBL>(session); if (dmo == null) { foreach (WorkShopRecord record in jsonDom.Details) { //已知record.PlanNumber_Name //record.ProductLine_ID = "select ProductPlan.ID from ProductPlan where ProductPlan.PlanNumber_Name=ProductPlan.PlanNumber_Name"; record.PlanNumber_ID = GetPlanIDByName(session, record.PlanNumber_Name); } bl.InitNewDmo(jsonDom); //插入单据 bl.Insert(jsonDom); //审核 bl.Check(jsonDom); returnid = jsonDom.ID; } else { if (dmo.BillState == 单据状态.已审核) { bl.UnCheck(dmo); } foreach (WorkShopRecord item in jsonDom.Details) { item.PlanNumber_ID = GetPlanIDByName(session, item.PlanNumber_Name); dmo.Details.Add(item); } bl.Update(dmo); bl.Check(dmo); returnid = dmo.ID; } //提交事务 session.Commit(); } } return(returnid); }
public static FormData FormActions(string action, FormData data) { var productOutput = (ProduceOutput)data.MainObject; var bl = BIFactory.Create <IProduceOutputBL>(); switch (action) { case FormActionNames.Load: var dom = bl.Load(productOutput.ID); data.MainObject = dom; break; case FormActionNames.Save: if (productOutput.Details.Count <= 0) { LoadDetail(productOutput); //在 save 的 FormAction 里,向客户端返回脚本: "scrollToCollection(0)", 也就是: "0 ()scrollToCollection " data.Codes = "0 ()scrollToCollection "; } if (productOutput.ID == 0) { bl.InitNewDmo(productOutput); bl.Insert(productOutput); data.MainObject = productOutput; //在 save 的 FormAction 里,向客户端返回脚本: "scrollToCollection(0)", 也就是: "0 ()scrollToCollection " data.Codes = "0 ()scrollToCollection "; return(FormActions(FormActionNames.Load, data)); } bl.Update(productOutput); return(FormActions(FormActionNames.Load, data)); case FormActionNames.New: var dmo = new ProduceOutput(); data.MainObject = dmo; dmo.Time = DateTime.Now; bl.InitNewDmo(dmo); var productPlan = GetProductPlan(dmo.AccountingUnit_ID, dmo.Department_ID, Convert.ToDateTime(Convert.ToDateTime(dmo.Time).ToShortDateString())); if (productPlan != null) { dmo.PlanNumber_ID = productPlan.Item1; dmo.PlanNumber_Name = productPlan.Item2; } break; case FormActionNames.Prev: var prevDmo = GetPrevOrNext(productOutput.ID); if (prevDmo == null) { throw new IndexOutOfRangeException("Current is first"); } data.MainObject = prevDmo; break; case FormActionNames.Next: var nextDmo = GetPrevOrNext(productOutput.ID, false); if (nextDmo == null) { throw new IndexOutOfRangeException("Current is last"); } data.MainObject = nextDmo; break; case "LoadDetail": LoadDetail(productOutput); bl.Update(productOutput); break; case "ReferToCreate": data.MainObject = HippoUtil.ReferenceToCreate <ProduceOutput>(productOutput); break; default: throw new ArgumentException("Unknown action: " + action); } return(data); }
public static FormData FormActions(string action, FormData data) { var productInput = (ProductNotice)data.MainObject; var bl = BIFactory.Create <IProductNoticeBL>(); switch (action) { case FormActionNames.Load: var dom = bl.Load(productInput.ID); data.MainObject = dom; break; case FormActionNames.Save: BeforeSave(productInput); if (productInput.ID == 0) { bl.InitNewDmo(productInput); UpdateDetail(productInput); bl.Insert(productInput); data.MainObject = productInput; return(FormActions(FormActionNames.Load, data)); } UpdateDetail(productInput); bl.Update(productInput); return(FormActions(FormActionNames.Load, data)); case FormActionNames.Check: bl.Check(productInput); data.MainObject = productInput; break; case FormActionNames.New: var dmo = new ProductNotice(); data.MainObject = dmo; break; case FormActionNames.Prev: var prevDmo = GetPrevOrNext(productInput.ID); if (prevDmo == null) { throw new IndexOutOfRangeException("Current is first"); } data.MainObject = prevDmo; break; case FormActionNames.Next: var nextDmo = GetPrevOrNext(productInput.ID, false); if (nextDmo == null) { throw new IndexOutOfRangeException("Current is last"); } data.MainObject = nextDmo; break; case "LoadDetail": LoadDetail(productInput); break; case "ReferToCreate": data.MainObject = HippoUtil.ReferenceToCreate(productInput); break; case "Predict": LoadPredictDetail(productInput); UpdateDetail(productInput); break; default: throw new ArgumentException("Unknown action: " + action); } return(data); }