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); }
static void SetSecondNumberByNumber(FrozenInStore dmo) { foreach (FrozenInStore_Detail detail in dmo.Details) { DmoUtil.RefreshDependency(detail, "Goods_ID"); if (detail.Goods_UnitConvertDirection == null) { continue; } if (detail.Goods_UnitConvertDirection == 主辅转换方向.双向转换 || detail.Goods_UnitConvertDirection == 主辅转换方向.由主至辅) { //辅单位数量 if (detail.Goods_MainUnitRatio != null && detail.Goods_SecondUnitRatio != null) { detail.SecondNumber = detail.Number * detail.Goods_SecondUnitRatio / detail.Goods_MainUnitRatio; } //辅单位Ⅱ数量 if (detail.Goods_SecondUnitII_MainUnitRatio != null && detail.Goods_SecondUnitII_SecondUnitRatio != null) { detail.SecondNumber2 = detail.Number * detail.Goods_SecondUnitII_SecondUnitRatio / detail.Goods_SecondUnitII_MainUnitRatio; } } } }
private static void SetProductPlan(FrozenInStore dmo, IDmoSessionWithTransaction session) { var query = new DQueryDom(new JoinAlias(typeof(ProductPlan))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Where.Conditions.Add(DQCondition.LessThanOrEqual("Date", dmo.Date)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("EndDate", dmo.Date)); query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); var planid = query.EExecuteScalar <long?>(session); dmo.ProductionPlan_ID = planid; }
static void SetEmployeeDepartment(FrozenInStore dmo, IDmoSession session) { var employeeId = GetCurrentBindingEmployeeID(session); dmo.Employee_ID = employeeId; var query = new DQueryDom(new JoinAlias(typeof(Employee))); query.Where.Conditions.Add(DQCondition.EQ("ID", employeeId)); query.Columns.Add(DQSelectColumn.Field("Department_ID")); using (var reader = session.ExecuteReader(query)) { if (reader.Read()) { var depId = (long?)reader[0] ?? 0; dmo.Department_ID = depId; } } }
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); } }