public static DepartmentDto GetDepartmentBaseInfoDto() { var dto = new DepartmentDto(); using (var session = Dmo.NewSession()) { var employeeId = GetCurrentBindingEmployeeID(session); var query = new DQueryDom(new JoinAlias(typeof(Employee))); query.Where.Conditions.Add(DQCondition.EQ("ID", employeeId)); query.Columns.Add(DQSelectColumn.Field("Department_ID")); query.Columns.Add(DQSelectColumn.Field("Department_Name")); query.Columns.Add(DQSelectColumn.Field("Department_Depth")); using (var reader = session.ExecuteReader(query)) { if (reader.Read()) { dto.ID = (long?)reader[0] ?? 0; if (dto.ID > 0) { dto.Name = (string)reader[1]; dto.Department_Depth = (int?)reader[2] ?? 0; } } } } return(dto); }
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 List <Store> SyncStores() { var list = new List <Store>(); var query = new DQueryDom(new JoinAlias(typeof(Store))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("Name")); query.Columns.Add(DQSelectColumn.Field("Code")); query.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { list.Add(new Store() { ID = (long)reader[0], Name = (string)reader[1], Code = (string)reader[2] }); } } } return(list); }
public static bool UpdateGoodsPackingRelation(string json, string token) { if (token != "bwpsoft") { throw new Exception("请联系开发人员"); } var list = JsonConvert.DeserializeObject <List <GoodsPackingRelationDto> >(json); using (var session = Dmo.NewSession()) { foreach (GoodsPackingRelationDto dto in list) { if (dto.GoodsPacking_ID == 0 || dto.Goods_ID == 0) { continue; } var updateDom = new DQUpdateDom(typeof(PackingBagType_Detail)); updateDom.Where.Conditions.Add(DQCondition.EQ("Goods_ID", dto.Goods_ID)); updateDom.Where.Conditions.Add(DQCondition.InSubQuery(DQExpression.Field("PackingBagType_ID"), GetSubQuery(dto.Department_ID))); updateDom.Columns.Add(new DQUpdateColumn("GoodsPacking_ID", dto.GoodsPacking_ID)); session.ExecuteNonQuery(updateDom); } session.Commit(); } return(true); }
public static List <ProductInStoreSimpleDto> GetSimpleList(int pageIndex, int pageSize) { var list = new List <ProductInStoreSimpleDto>(); var query = new DQueryDom(new JoinAlias(typeof(ProductInStore))); query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.未审核)); query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("InStoreDate")); query.Columns.Add(DQSelectColumn.Field("Store_Name")); query.Range = new SelectRange(pageSize * pageIndex, pageSize); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new ProductInStoreSimpleDto(); dto.ID = (long)reader[0]; dto.InStoreDate = (DateTime)reader[1]; dto.Store_Name = (string)reader[2]; list.Add(dto); } } } return(list); }
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 List <GoodsInfoDto> GetTodayGoodsByStore(long accountUnitId, long departId, long storeId, long productPlanId) { var list = new List <GoodsInfoDto>(); var bill = new JoinAlias(typeof(ProduceOutput)); var detail = new JoinAlias(typeof(ProduceOutput_Detail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProduceOutput_ID")); query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountUnitId)); //query.Where.Conditions.Add(DQCondition.EQ("Department_ID", departId)); //DQCondition.EQ(string.Format("Department_TreeDeep{0}ID", context.Department_Depth), context.Department_ID) query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID)); query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual(bill, "Time", DateTime.Today.AddDays(-3)), DQCondition.LessThanOrEqual(bill, "Time", DateTime.Today.AddDays(1)))); //query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(bill, "Time", DateTime.Today)); //query.Where.Conditions.Add(DQCondition.LessThan(bill, "Time", DateTime.Today.AddDays(1))); query.Where.Conditions.Add(DQCondition.EQ("FrozenStore_ID", storeId)); query.Where.Conditions.Add(DQCondition.EQ("PlanNumber_ID", productPlanId)); query.Where.Conditions.Add(DQCondition.NotInSubQuery(DQExpression.Field(detail, "Goods_ID"), GetTodayGoodsByStoreSubQuery(accountUnitId, departId, storeId, productPlanId))); query.Where.Conditions.EFieldInList(DQExpression.Field(bill, "PlanNumber_ID"), GetProductPlan().Select(x => x.ID).ToArray()); OrganizationUtil.AddOrganizationLimit(query, typeof(ProduceOutput)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); //query.Columns.Add(DQSelectColumn.Field("Goods_InnerPackingPer", detail)); query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(DQExpression.Field(detail, "Number")), DQExpression.Field(detail, "Goods_InnerPackingPer")), "InnerPackingPer")); query.Columns.Add(DQSelectColumn.Field("Goods_InnerPackingPer", detail)); //query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Field(detail,"Number"),DQExpression.Field(detail, "Goods_InnerPackingPer")),"包装数")); query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_ID")); query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_Name")); query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_InnerPackingPer")); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var goods = new GoodsInfoDto { Goods_ID = (long)reader[0], Goods_Name = (string)reader[1], Number = (decimal?)(Money <decimal>?)reader[2], InnerPackingPer = (decimal?)reader[3], Goods_InnerPackingPer = (decimal?)reader[4] }; list.Add(goods); } } } return(list); }
public static void InsertSettingedGoods(long goodsid) { var dmo = new HandsetSelectedGoods(); dmo.Goods_ID = goodsid; using (var session = Dmo.NewSession()) { session.Insert(dmo); session.Commit(); } }
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); } }
public static List <FrozenInStoreObj> GetFrozenInStore(bool?positiveNumber) { var bill = new JoinAlias(typeof(FrozenInStore)); var detail = new JoinAlias(typeof(FrozenInStore_Detail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "FrozenInStore_ID")); query.Columns.Add(DQSelectColumn.Field("ID", bill)); query.Columns.Add(DQSelectColumn.Field("Date", bill)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Number", detail)); query.Columns.Add(DQSelectColumn.Field("Client", bill)); query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID)); query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ(bill, "BillState", 单据状态.已审核), DQCondition.EQ(bill, "BillState", 单据状态.未审核))); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(bill, "ID", true)); OrganizationUtil.AddOrganizationLimit(query, typeof(FrozenInStore)); var list = new List <FrozenInStoreObj>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { if (positiveNumber == true) { if ((Money <decimal>?)reader[4] < 0) { continue; } } else { if ((Money <decimal>?)reader[4] >= 0) { continue; } } list.Add(new FrozenInStoreObj { ID = (long)reader[0], Date = (DateTime?)reader[1], Goods_ID = (long?)reader[2], Goods_Name = (string)reader[3], Number = (Money <decimal>?)reader[4], Client = (string)reader[5] }); } } } return(list); }
private bool ISExitSameRecord(long?accountingUnitID, long?goodsID) { var query = new DQueryDom(new JoinAlias(typeof(Goods_Accounting_Store))); query.Columns.Add(DQSelectColumn.Count()); query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountingUnitID)); query.Where.Conditions.Add(DQCondition.EQ("Goods_ID", goodsID)); using (var session = Dmo.NewSession()) { return(Convert.ToInt32(session.ExecuteScalar(query)) != 0); } }
public static string GetList() { using (var session = Dmo.NewSession()) { var query = new DmoQuery(typeof(ClientGoodsSet)); query.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); var list = session.ExecuteList(query).Cast <ClientGoodsSet>().ToList(); var prod = FromProductNotice(session); list.Add(prod); var json = JsonConvert.SerializeObject(list); return(json); } }
private static List <BaseInfoDto> GetBaseInfoDQueryDom(Type type, bool hasCode, BaseInfoQueryDto queryDto) { var list = new List <BaseInfoDto>(); var query = new DQueryDom(new JoinAlias(type)); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("Name")); if (hasCode) { query.Columns.Add(DQSelectColumn.Field("Code")); } query.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)); if (queryDto.PageSize > 0) { query.Range = new SelectRange(queryDto.PageIndex * queryDto.PageSize, queryDto.PageSize); } if (!string.IsNullOrWhiteSpace(queryDto.Input)) { if (hasCode) { query.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name", queryDto.Input), DQCondition.Like("Code", queryDto.Input))); } else { query.Where.Conditions.Add(DQCondition.Like("Name", queryDto.Input)); } } if (type == typeof(Department)) { OrganizationUtil.AddOrganizationLimit(query, typeof(Department)); } using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { list.Add(new BaseInfoDto() { ID = (long)reader[0], Name = (string)reader[1] }); } } } return(list); }
static List <GoodsInfoDto> GetListByDquery(DQueryDom query) { var list = new List <GoodsInfoDto>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GoodsInfoDto(); dto.Goods_ID = (long)reader[0]; dto.Goods_Name = (string)reader[1]; dto.Goods_MainUnit = (string)reader[2]; dto.Goods_SecondUnit = (string)reader[3]; dto.Goods_UnitConvertDirection = (NamedValue <主辅转换方向>?)reader[4]; dto.Goods_MainUnitRatio = (Money <decimal>?)reader[5]; dto.Goods_SecondUnitRatio = (Money <decimal>?)reader[6]; dto.Goods_Code = (string)reader[7]; if (dto.Goods_MainUnitRatio == null) { dto.Goods_MainUnitRatio = 1; } if (dto.Goods_SecondUnitRatio == null) { dto.Goods_SecondUnitRatio = 1; } dto.SecondUnitII = (string)reader[8]; dto.SecondUnitII_MainUnitRatio = Convert.ToDecimal(reader[9]); dto.SecondUnitII_SecondUnitRatio = Convert.ToDecimal(reader[10]); dto.GoodsProperty_ID = (long?)reader[11]; dto.GoodsProperty_Name = (string)reader[12]; dto.GoodsPropertyCatalog_Name = (string)reader[13]; // dto.GoodsPropertyCatalog_Sort = (int?)reader[14]; dto.Goods_Spell = (string)reader[14]; dto.Goods_Spec = (string)reader[15]; list.Add(dto); } } } return(list); }
public static string GetPlanNumber() { var lastday = DateTime.Today; var joinProduce = new JoinAlias(typeof(ProduceOutput)); var joinDetail = new JoinAlias(typeof(ProduceOutput_Detail)); var joinChengPin = new JoinAlias(typeof(ChengPinToBanChengPinConfig)); var joinNumber = new JoinAlias(typeof(ButcheryGoods)); var query = new DQueryDom(joinDetail); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinProduce), DQCondition.EQ(joinProduce, "ID", joinDetail, "ProduceOutput_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinChengPin), DQCondition.EQ(joinDetail, "Goods_ID", joinChengPin, "Goods2_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinNumber), DQCondition.EQ(joinChengPin, "Goods2_ID", joinNumber, "ID")); //主单位 query.Columns.Add(DQSelectColumn.Field("MainUnitRatio", joinNumber)); //辅单位 query.Columns.Add(DQSelectColumn.Field("SecondUnitRatio", joinNumber)); //成品数量 要做的操作是 成品数量/(主单位*辅单位) query.Columns.Add(DQSelectColumn.Field("Number", joinDetail)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(joinProduce, "Time", lastday.AddDays(-1))); query.Where.Conditions.Add(DQCondition.LessThan(joinProduce, "Time", lastday)); var list = new List <GetChengPin>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GetChengPin(); dto.MainUnitRatio = (decimal)reader[4]; dto.SecondUnitRatio = (decimal)reader[5]; dto.Number = (Money <decimal>)reader[6]; dto.PlanNumber = Convert.ToInt32(dto.Number / (dto.MainUnitRatio * dto.SecondUnitRatio)); list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
public virtual void GetDetail() { Details.Clear(); var prop = JoinAlias.Create("prop"); DQueryDom dom = mQueryContainer.Build(); // dom.Where.Conditions.Add(DQCondition.EQ(prop, "IsButchery", true)); var rootAlias = dom.From.RootSource.Alias; var goodsPropertyCatalog = new JoinAlias(typeof(GoodsPropertyCatalog)); dom.From.AddJoin(JoinType.Left, new DQDmoSource(goodsPropertyCatalog), DQCondition.EQ(prop, "GoodsPropertyCatalog_ID", goodsPropertyCatalog, "ID")); dom.Columns.Add(DQSelectColumn.Field("Code", rootAlias)); dom.Columns.Add(DQSelectColumn.Field("Name", rootAlias)); dom.Columns.Add(DQSelectColumn.Field("Spec", rootAlias)); dom.Columns.Add(DQSelectColumn.Field("MainUnit", rootAlias)); dom.Columns.Add(DQSelectColumn.Field("SecondUnit", rootAlias)); dom.Columns.Add(DQSelectColumn.Field("Name", prop)); dom.Columns.Add(DQSelectColumn.Field("Name", goodsPropertyCatalog)); dom.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); DomainUtil.AddDomainPermissionLimit(dom, typeof(GoodsProperty), prop); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(dom)) { while (reader.Read()) { var detail = new Goods(); detail.ID = (long)reader[0]; detail.Code = (string)reader[1]; detail.Name = (string)reader[2]; detail.Spec = (string)reader[3]; detail.MainUnit = (string)reader[4]; detail.SecondUnit = (string)reader[5]; detail.GoodsProperty_Name = (string)reader[6]; detail.GoodsPropertyCatalog_Name = (string)reader[7]; Details.Add(detail); } } } }
public static string GetFinishProductList() { var lastday = DateTime.Today; var joinProduce = new JoinAlias(typeof(ProduceOutput)); var joinDetail = new JoinAlias(typeof(ProduceOutput_Detail)); var joinChengPin = new JoinAlias(typeof(ChengPinToBanChengPinConfig)); var query = new DQueryDom(joinDetail); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinProduce), DQCondition.EQ(joinProduce, "ID", joinDetail, "ProduceOutput_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinChengPin), DQCondition.EQ(joinDetail, "Goods_ID", joinChengPin, "Goods2_ID")); query.Columns.Add(DQSelectColumn.Field("Goods_ID", joinDetail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", joinDetail)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", joinChengPin)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", joinChengPin)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(joinProduce, "Time", lastday.AddDays(-1))); query.Where.Conditions.Add(DQCondition.LessThan(joinProduce, "Time", lastday)); var list = new List <GetChengPin>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GetChengPin(); dto.Goods_ID = Convert.ToInt64(reader[0]); dto.Goods_Name = reader[1].ToString(); dto.Goods2_ID = Convert.ToInt64(reader[2]); dto.Goods2_Name = reader[3].ToString(); list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
public static string GetPackagingList() { var list = new List <PackagingDto>(); var bill = new JoinAlias(typeof(Packaging)); var detail = new JoinAlias(typeof(Packaging_Detail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "Packaging_ID")); query.Columns.Add(DQSelectColumn.Field("Name", bill)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Spec", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_ID", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Packing_Attr", bill)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new PackagingDto(); dto.Name = (string)reader[0]; dto.Goods_ID = (long?)reader[1]; dto.Goods_Name = (string)reader[2]; dto.Goods_Code = (string)reader[3]; dto.Goods_Spec = (string)reader[4]; dto.GoodsProperty_ID = (long?)reader[5]; dto.GoodsProperty_Name = (string)reader[6]; var attr = (NamedValue <包装属性>?)reader[7]; dto.Packing_Attr = attr == null ? "" : attr.Value.Name; list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
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); }
public static List <ProduceOutputObj> GetProduceOutput() { var bill = new JoinAlias(typeof(ProduceOutput)); var detail = new JoinAlias(typeof(ProduceOutput_Detail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProduceOutput_ID")); query.Columns.Add(DQSelectColumn.Field("ID", bill)); query.Columns.Add(DQSelectColumn.Field("Time", bill)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Number", detail)); query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID)); query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ(bill, "BillState", 单据状态.已审核), DQCondition.EQ(bill, "BillState", 单据状态.未审核))); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(bill, "ID", true)); OrganizationUtil.AddOrganizationLimit(query, typeof(ProduceOutput)); var list = new List <ProduceOutputObj>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { list.Add(new ProduceOutputObj { ID = (long)reader[0], Time = (DateTime?)reader[1], Goods_ID = (long?)reader[2], Goods_Name = (string)reader[3], Number = (Money <decimal>?)reader[4] }); } } } return(list); }
public static string GetAllGoods() { var list = new List <ProductInStoreTemplateGoodsDto>(); var bill = new JoinAlias(typeof(ProductInStoreTemplate)); var detail = new JoinAlias(typeof(ProductInStoreTemplate_GoodsDetail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Right, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProductInStoreTemplate_ID")); query.Distinct = true; query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Spec", detail)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new ProductInStoreTemplateGoodsDto(); dto.Goods_ID = (long)reader[0]; dto.Goods_Name = (string)reader[1]; dto.Goods_Code = (string)reader[2]; dto.Goods_Spec = (string)reader[3]; if (list.Any(x => x.Goods_ID == dto.Goods_ID)) { continue; } list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
private void AddQueryResult(VLayoutPanel vPanel) { var btn = vPanel.Add(new DialogButton { Text = "增加记录", Url = "AddSettingDialog.aspx" }, new VLayoutOption(HorizontalAlign.Left)); btn.Click += delegate { StartQuery(); }; _mGrid = vPanel.Add(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); _mGrid.Columns.Add(new DFBrowseGridCustomExtColumn(delegate(DFDataRow row, HtmlTableCell cell, int rowIndex) { var delBtn = new LinkButton { Text = "x" }; delBtn.Click += delegate { var id = (long?)_mGrid.CurrentData.Data.Rows[rowIndex]["ID"]; var dom = new DQDeleteDom(typeof(Goods_Accounting_Store)); dom.Where.Conditions.Add(DQExpression.EQ(DQExpression.Field("ID"), DQExpression.Value(id))); using (var session = Dmo.NewSession()) { session.ExecuteNonQuery(dom); session.Commit(); } StartQuery(); }; delBtn.OnClientClick = "return confirm('确定删除吗?')"; cell.Controls.Add(delBtn); })); _mGrid.Columns.Add(new DFBrowseGridAutoColumn()); }
public static List <BaseInfoDto> GetAllStoreList() { var list = new List <BaseInfoDto>(); var query = new DQueryDom(new JoinAlias(typeof(Store))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("Name")); query.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new BaseInfoDto(); dto.ID = (long)reader[0]; dto.Name = (string)reader[1]; list.Add(dto); } } } return(list); }
public static List <GoodsInfoDto> GetProductInStoreTemplate(string input) { var list = new List <GoodsInfoDto>(); var productInStore = new JoinAlias(typeof(ProductInStoreTemplate)); var productInStoreGoods = new JoinAlias(typeof(ProductInStoreTemplate_GoodsDetail)); var goods = new JoinAlias(typeof(Goods)); var query = new DQueryDom(productInStoreGoods); query.From.AddJoin(JoinType.Left, new DQDmoSource(productInStore), DQCondition.EQ(productInStore, "ID", productInStoreGoods, "ProductInStoreTemplate_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(productInStoreGoods, "Goods_ID", goods, "ID")); query.Range = SelectRange.Top(200); query.Where.Conditions.Add(DQCondition.EQ(productInStore, "Stopped", false)); if (!string.IsNullOrWhiteSpace(input)) { query.Where.Conditions.Add(DQCondition.Or(DQCondition.Like(goods, "Name", input), DQCondition.Like(goods, "Code", input), DQCondition.Like(goods, "Spell", input))); } query.OrderBy.Expressions.Add(DQOrderByExpression.Create(goods, "Name")); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(goods, "Code")); query.Columns.Add(DQSelectColumn.Field("ID", goods)); query.Columns.Add(DQSelectColumn.Field("Name", goods)); query.Columns.Add(DQSelectColumn.Field("MainUnit", goods)); query.Columns.Add(DQSelectColumn.Field("SecondUnit", goods)); query.Columns.Add(DQSelectColumn.Field("UnitConvertDirection", goods)); query.Columns.Add(DQSelectColumn.Field("MainUnitRatio", goods)); query.Columns.Add(DQSelectColumn.Field("SecondUnitRatio", goods)); query.Columns.Add(DQSelectColumn.Field("Code", goods)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_ID", goods)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_Name", goods)); query.Columns.Add(DQSelectColumn.Field("GoodsPropertyCatalog_Name", goods)); query.Columns.Add(DQSelectColumn.Field("SecondUnitII", goods)); query.Columns.Add(DQSelectColumn.Field("SecondUnitII_MainUnitRatio", goods)); query.Columns.Add(DQSelectColumn.Field("SecondUnitII_SecondUnitRatio", goods)); query.Columns.Add(DQSelectColumn.Field("Spec", goods)); query.Distinct = true; using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GoodsInfoDto(); dto.Goods_ID = (long)reader[0]; dto.Goods_Name = (string)reader[1]; dto.Goods_MainUnit = (string)reader[2]; dto.Goods_SecondUnit = (string)reader[3]; dto.Goods_UnitConvertDirection = (NamedValue <主辅转换方向>?)reader[4]; dto.Goods_MainUnitRatio = (Money <decimal>?)reader[5]; dto.Goods_SecondUnitRatio = (Money <decimal>?)reader[6]; dto.Goods_Code = (string)reader[7]; if (dto.Goods_MainUnitRatio == null) { dto.Goods_MainUnitRatio = 1; } if (dto.Goods_SecondUnitRatio == null) { dto.Goods_SecondUnitRatio = 1; } dto.GoodsProperty_ID = (long?)reader[8]; dto.GoodsProperty_Name = (string)reader[9]; dto.GoodsPropertyCatalog_Name = (string)reader[10]; dto.SecondUnitII = (string)reader[11]; dto.SecondUnitII_MainUnitRatio = Convert.ToDecimal(reader[12]); dto.SecondUnitII_SecondUnitRatio = Convert.ToDecimal(reader[13]); dto.Goods_Spec = (string)(reader[14]); list.Add(dto); } } } return(list); }
public static string GetPackingBagTypeList() { var list = new List <PackingBagTypeDto>(); var bill = new JoinAlias(typeof(PackingBagType)); var detail = new JoinAlias(typeof(PackingBagType_Detail)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "PackingBagType_ID")); query.Columns.Add(DQSelectColumn.Field("Name", bill)); query.Columns.Add(DQSelectColumn.Field("Department_ID", bill)); query.Columns.Add(DQSelectColumn.Field("Department_Name", bill)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Spec", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_ID", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_Name", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsPacking_ID", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsPacking_Name", detail)); query.Columns.Add(DQSelectColumn.Field("StandNumber", detail)); query.Columns.Add(DQSelectColumn.Field("DisplayMark", bill)); query.Columns.Add(DQSelectColumn.Field("Packing_Attr", bill)); query.Columns.Add(DQSelectColumn.Field("Packing_Pattern", bill)); query.Columns.Add(DQSelectColumn.Field("Abbreviation", bill)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new PackingBagTypeDto(); dto.Name = (string)reader[0]; dto.Department_ID = (long?)reader[1]; dto.Department_Name = (string)reader[2]; dto.Goods_ID = (long?)reader[3]; dto.Goods_Name = (string)reader[4]; dto.Goods_Code = (string)reader[5]; dto.Goods_Spec = (string)reader[6]; dto.GoodsProperty_ID = (long?)reader[7]; dto.GoodsProperty_Name = (string)reader[8]; dto.GoodsPacking_ID = (long?)reader[9]; dto.GoodsPacking_Name = (string)reader[10]; dto.StandNumber = (int?)reader[11]; dto.DisplayMark = (string)reader[12]; var attr = (NamedValue <包装属性>?)reader[13]; dto.Packing_Attr = attr == null ? "" : attr.Value.Name; var pattern = (NamedValue <包装模式>?)reader[14]; dto.Packing_Pattern = pattern == null ? "" : pattern.Value.Name; dto.Abbreviation = reader[15].ToString(); list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
public static List <GoodsInfoDto> GetAllSettingedGoods(int pageIndex, int pageSize) { var list = new List <GoodsInfoDto>(); var joinGoods = new JoinAlias(typeof(Goods)); // var goodsProperty = new JoinAlias(typeof(GoodsProperty)); // var goodsPropertyCatalog = new JoinAlias(typeof(GoodsPropertyCatalog)); var query = new DQueryDom(joinGoods); query.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Name")); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Code")); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("Name")); query.Columns.Add(DQSelectColumn.Field("MainUnit")); query.Columns.Add(DQSelectColumn.Field("SecondUnit")); query.Columns.Add(DQSelectColumn.Field("UnitConvertDirection")); query.Columns.Add(DQSelectColumn.Field("MainUnitRatio")); query.Columns.Add(DQSelectColumn.Field("SecondUnitRatio")); query.Columns.Add(DQSelectColumn.Field("Code")); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_ID")); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_Name")); query.Columns.Add(DQSelectColumn.Field("GoodsPropertyCatalog_Name")); query.Columns.Add(DQSelectColumn.Field("SecondUnitII")); query.Columns.Add(DQSelectColumn.Field("SecondUnitII_MainUnitRatio")); query.Columns.Add(DQSelectColumn.Field("SecondUnitII_SecondUnitRatio")); query.Columns.Add(DQSelectColumn.Field("Spec")); query.Where.Conditions.Add(DQCondition.InSubQuery(DQExpression.Field("ID"), GetAllSettingedGoodsSubQuery())); query.Range = new SelectRange(pageIndex * pageSize, pageSize); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GoodsInfoDto(); dto.Goods_ID = (long)reader[0]; dto.Goods_Name = (string)reader[1]; dto.Goods_MainUnit = (string)reader[2]; dto.Goods_SecondUnit = (string)reader[3]; dto.Goods_UnitConvertDirection = (NamedValue <主辅转换方向>?)reader[4]; dto.Goods_MainUnitRatio = (Money <decimal>?)reader[5]; dto.Goods_SecondUnitRatio = (Money <decimal>?)reader[6]; dto.Goods_Code = (string)reader[7]; if (dto.Goods_MainUnitRatio == null) { dto.Goods_MainUnitRatio = 1; } if (dto.Goods_SecondUnitRatio == null) { dto.Goods_SecondUnitRatio = 1; } dto.GoodsProperty_ID = (long?)reader[8]; dto.GoodsProperty_Name = (string)reader[9]; dto.GoodsPropertyCatalog_Name = (string)reader[10]; dto.SecondUnitII = (string)reader[11]; dto.SecondUnitII_MainUnitRatio = Convert.ToDecimal(reader[12]); dto.SecondUnitII_SecondUnitRatio = Convert.ToDecimal(reader[13]); dto.Goods_Spec = (string)(reader[14]); list.Add(dto); } } } return(list); }
public static List <GoodsInfoDto> GetByDepartPlan(long?departId, long?productionPlanId = null, string productionPlanNumber = "") { if (departId == null || departId == 0) { throw new Exception("员工档案上没有配置部门"); } var list = new List <GoodsInfoDto>(); var bill = new JoinAlias(typeof(ProductPlan)); var detail = new JoinAlias(typeof(ProductPlan_OutputDetail)); var goods = new JoinAlias(typeof(Goods)); var query = new DQueryDom(bill); query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "ProductPlan_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(goods, "ID", detail, "Goods_ID")); //query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(bill, "Date", DateTime.Today)); //query.Where.Conditions.Add(DQCondition.LessThan(bill, "Date", DateTime.Today.AddDays(1))); query.Where.Conditions.Add(DQCondition.EQ(bill, "BillState", 单据状态.已审核)); //if(productionPlanId!=null) // query.Where.Conditions.Add(DQCondition.EQ(bill, "ID", productionPlanId)); if (productionPlanNumber != "") { query.Where.Conditions.Add(DQCondition.EQ(bill, "PlanNumber", productionPlanNumber)); } // query.Where.Conditions.Add(B3ButcheryUtil.部门或上级部门条件(departId??0, bill)); OrganizationUtil.AddOrganizationLimit(query, typeof(ProductPlan)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_MainUnit", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnit", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_UnitConvertDirection", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_MainUnitRatio", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitRatio", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitII", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitII_MainUnitRatio", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitII_SecondUnitRatio", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_ID", goods)); query.Columns.Add(DQSelectColumn.Field("GoodsProperty_Name", goods)); query.Columns.Add(DQSelectColumn.Field("GoodsPropertyCatalog_Name", goods)); query.Distinct = true; query.Where.Conditions.Add(DQCondition.EQ(bill, "Domain_ID", DomainContext.Current.ID)); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GoodsInfoDto(); dto.Goods_ID = (long)reader[0]; dto.Goods_Name = (string)reader[1]; dto.Goods_MainUnit = (string)reader[2]; dto.Goods_SecondUnit = (string)reader[3]; dto.Goods_UnitConvertDirection = (NamedValue <主辅转换方向>?)reader[4]; dto.Goods_MainUnitRatio = (Money <decimal>?)reader[5]; dto.Goods_SecondUnitRatio = (Money <decimal>?)reader[6]; dto.Goods_Code = (string)reader[7]; if (dto.Goods_MainUnitRatio == null) { dto.Goods_MainUnitRatio = 1; } if (dto.Goods_SecondUnitRatio == null) { dto.Goods_SecondUnitRatio = 1; } dto.SecondUnitII = (string)reader[8]; dto.SecondUnitII_MainUnitRatio = Convert.ToDecimal(reader[9]); dto.SecondUnitII_SecondUnitRatio = Convert.ToDecimal(reader[10]); dto.GoodsProperty_ID = (long?)reader[11]; dto.GoodsProperty_Name = (string)reader[12]; dto.GoodsPropertyCatalog_Name = (string)reader[13]; list.Add(dto); } } } return(list); }
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); }