示例#1
0
        /// <summary>
        /// 获取商品销售单视图
        /// </summary>
        /// <returns></returns>
        public IEnumerable <GoodsSellNoteVM> GetGoodsSellNote()
        {
            GoodsSellNote       note = new GoodsSellNote();
            Employee            emp  = new Employee();
            CustomerContactInfo cst  = new CustomerContactInfo();
            OQL joinQ = OQL.From(note)
                        .InnerJoin(emp).On(note.SalesmanID, emp.WorkNumber)
                        .InnerJoin(cst).On(note.CustomerID, cst.CustomerID)
                        .Select(note.NoteID, cst.CustomerName, note.ManchinesNumber, emp.EmployeeName, note.SalesType, note.SellDate)
                        .OrderBy(note.NoteID, "desc")
                        .END;

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            ec.Execute();
            //可以使用下面的方式获得各个成员元素列表
            //var noteList = ec.Map<GoodsSellNote>().ToList();
            //var empList = ec.Map<Employee>().ToList();
            //var cstList = ec.Map<CustomerContactInfo>().ToList();
            //直接使用下面的方式获得新的视图对象
            var result = ec.Map <GoodsSellNoteVM>(e =>
            {
                e.NoteID          = ec.GetItemValue <int>(0);
                e.CustomerName    = ec.GetItemValue <string>(1);
                e.ManchinesNumber = ec.GetItemValue <string>(2);
                e.EmployeeName    = ec.GetItemValue <string>(3);
                e.SalesType       = ec.GetItemValue <string>(4);
                e.SellDate        = ec.GetItemValue <DateTime>(5);
                return(e);
            }
                                                  );

            return(result);
        }
示例#2
0
        /// <summary>
        /// 获取商品销售价格信息
        /// </summary>
        /// <returns></returns>
        public IEnumerable <GoodsSaleInfoVM> GetGoodsSaleInfo()
        {
            GoodsBaseInfo bInfo = new GoodsBaseInfo();
            GoodsStock    stock = new GoodsStock();
            OQL           joinQ = OQL.From(bInfo)
                                  .Join(stock).On(bInfo.SerialNumber, stock.SerialNumber)
                                  .Select(bInfo.GoodsName, bInfo.Manufacturer, bInfo.SerialNumber, stock.GoodsPrice, stock.MakeOnDate, bInfo.CanUserMonth, stock.Stocks, stock.GoodsID)
                                  .OrderBy(bInfo.GoodsName, "asc")
                                  .END;

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            ec.Execute();
            var result = ec.Map <GoodsSaleInfoVM>(e =>
            {
                e.GoodsName    = ec.GetItemValue <string>(0);
                e.Manufacturer = ec.GetItemValue <string>(1);
                e.SerialNumber = ec.GetItemValue <string>(2);
                e.GoodsPrice   = ec.GetItemValue <decimal>(3);
                e.MakeOnDate   = ec.GetItemValue <DateTime>(4);
                e.CanUserMonth = ec.GetItemValue <int>(5);
                e.Stocks       = ec.GetItemValue <int>(6);
                e.GoodsID      = ec.GetItemValue <int>(7);
                return(e);
            }
                                                  );

            return(result);
        }
示例#3
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <AdminActionViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <AdminActionViewModel> rsp = new JsonRsp <AdminActionViewModel>();

            AdminAction action = new AdminAction();
            AdminMenu   menu   = new AdminMenu();
            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(action)
                        .Join(menu).On(action.MenuId, menu.ID)
                        .Select(action.ID, menu.MenuName, action.ActionKey, action.ActionName, action.Status, action.CreateTime)
                        .OrderBy(action.Sort, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <AdminActionViewModel>)ec.MapToList <AdminActionViewModel>(() => new AdminActionViewModel()
            {
                ID         = action.ID,
                MenuId     = menu.ID,
                MenuName   = menu.MenuName,
                ActionKey  = action.ActionKey,
                ActionName = action.ActionName,
                Status     = action.Status,
                CreateTime = action.CreateTime,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#4
0
        /// <summary>
        /// 获取列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <ChargeCardViewModel> GetPageList(int pageIndex, int pageSize, bool limit = true)
        {
            JsonRsp <ChargeCardViewModel> rsp = new JsonRsp <ChargeCardViewModel>();

            ChargeCardsModel c      = new ChargeCardsModel();
            CustomModel      custom = new CustomModel();
            TicketTypeModel  t      = new TicketTypeModel();
            OQL joinQ = OQL.From(c)
                        .Join(custom).On(c.CustomId, custom.ID)
                        .LeftJoin(t).On(c.TicketTypeID, t.ID)
                        .Select()
                        .OrderBy(c.Sort, "desc")
                        .END;

            //分页
            if (limit)
            {
                joinQ.Limit(pageSize, pageIndex, true);
            }
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <ChargeCardViewModel>)ec.MapToList <ChargeCardViewModel>(() => new ChargeCardViewModel()
            {
                ID               = c.ID,
                CustomId         = c.CustomId,
                CustomName       = custom.CustomName,
                TicketTypeID     = c.TicketTypeID,
                TicketTypeName   = t.TicketTypeName,
                MoneyType        = c.MoneyType,
                CurrentCount     = c.CurrentCount,
                FaceAmount       = c.FaceAmount,
                CurrentAmount    = c.CurrentAmount,
                ExpireDate       = c.ExpireDate,
                TicketBatchId    = c.TicketBatchId,
                TicketStart      = c.TicketStart,
                TicketEnd        = c.TicketEnd,
                Consumptionlevel = c.Consumptionlevel,
                IsCommonCard     = c.IsCommonCard,
                Sort             = c.Sort,
                CreateId         = c.CreateId,
                CreateUser       = c.CreateUser,
                CreateIP         = c.CreateIP,
                CreateTime       = c.CreateTime,
                UpdateBy         = c.UpdateUser,
                UpdateIP         = c.UpdateIP,
                UpdateTime       = c.UpdateTime,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#5
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <TicketViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <TicketViewModel> rsp = new JsonRsp <TicketViewModel>();


            TicketInfo      ticket     = new TicketInfo();
            TicketTypeModel ticketType = new TicketTypeModel();

            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(ticket)
                        .Join(ticketType).On(ticket.TicketTypeId, ticketType.ID)
                        .Select()
                        .OrderBy(ticket.Sort, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <TicketViewModel>)ec.MapToList <TicketViewModel>(() => new TicketViewModel()
            {
                ID               = ticket.ID,
                TicketCode       = ticket.TicketCode,
                TicketTypeId     = ticket.TicketTypeId,
                Consumptionlevel = BaseEnum.ConsumptionlevelEnum.初始化,
                MoneyTyp         = BaseEnum.MoneyTypeEnum.初始化,
                CustomID         = 0,
                InitialAmount    = 0,
                CostAmount       = 0,
                Balance          = 0,
                Status           = BaseEnum.CredentialEnum.未交付,
                IsExpire         = false,
                IsActivated      = false,
                //MakeTime=null,
                //ExpireDate=null,
                TicketBatchNo = ticket.TicketBatchNo,
                GrantBy       = 0,
                //GrantTime=null,
                CreateBy   = AdminName,
                CreateIP   = Util.GetLocalIP(),
                CreateTime = ticket.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                Sort       = ticket.Sort,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#6
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <MerchantViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <MerchantViewModel> rsp = new JsonRsp <MerchantViewModel>();


            MerchantModel     model        = new MerchantModel();
            MerchantTypeModel MerchantType = new MerchantTypeModel();

            model.TenantId = TenantId;
            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(model)
                        .Join(MerchantType).On(model.MerchantTypeId, MerchantType.ID)
                        .Select()
                        .OrderBy(model.Sort, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <MerchantViewModel>)ec.MapToList <MerchantViewModel>(() => new MerchantViewModel()
            {
                ID               = model.ID,
                MerchantTypeId   = model.MerchantTypeId,
                MerchantTypeName = MerchantType.MerchantTypeName,
                MerchantName     = model.MerchantName,
                LinkPhone        = model.LinkPhone,
                LinkName         = model.LinkName,
                LinkMobile       = model.LinkMobile,
                MerchantArea     = model.MerchantArea,
                MerchantAddress  = model.MerchantAddress,
                CreateId         = model.CreateId,
                CreateUser       = model.CreateUser,
                CreateIP         = model.CreateIP,
                CreateTime       = model.CreateTime,
                Sort             = model.Sort,
                Status           = model.Status,
                UpdateBy         = model.UpdateUser,
                UpdateIP         = model.UpdateIP,
                UpdateTime       = model.UpdateTime,
            });

            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#7
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <ProductTypeViewModel> GetPageList(string searchTxt, int pageIndex, int pageSize)
        {
            JsonRsp <ProductTypeViewModel> rsp = new JsonRsp <ProductTypeViewModel>();

            ProductTypeModel  pt = new ProductTypeModel();
            MerchantTypeModel mt = new MerchantTypeModel();
            OQLCompareFunc <ProductTypeModel> cmpFun = (cmp, u) =>
            {
                OQLCompare cmpResult = null;
                //and 条件
                cmpResult = cmpResult & cmp.Comparer(pt.ProductTypeName, OQLCompare.CompareType.Like, "%" + searchTxt + "%");
                //or
                cmpResult = cmpResult | cmp.Comparer(pt.TenantId, OQLCompare.CompareType.Equal, TenantId);
                return(cmpResult);
            };
            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(pt)
                        .Join(mt).On(pt.MerchantTypeId, mt.ID)
                        .Select(pt.ID, pt.ProductTypeName, mt.MerchantTypeName, pt.Status, pt.CreateTime)
                        .Where(cmpFun)
                        .OrderBy(pt.Sort, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <ProductTypeViewModel>)ec.MapToList <ProductTypeViewModel>(() => new ProductTypeViewModel()
            {
                ID = pt.ID,
                ProductTypeName  = pt.ProductTypeName,
                MerchantTypeId   = mt.ID,
                MerchantTypeName = mt.MerchantTypeName,
                CreateId         = pt.CreateId,
                CreateUser       = pt.CreateUser,
                CreateIP         = pt.CreateIP,
                CreateTime       = pt.CreateTime,
                Status           = pt.Status,
            });

            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#8
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <ContractViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <ContractViewModel> rsp = new JsonRsp <ContractViewModel>();


            ContractModel   contract   = new ContractModel();
            CustomModel     custom     = new CustomModel();
            CustomTypeModel customType = new CustomTypeModel();

            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(contract)
                        .Join(custom).On(contract.CustomId, custom.ID)
                        .Join(customType).On(custom.CustomTypeId, customType.ID)
                        .Select()
                        .OrderBy(contract.Sort, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <ContractViewModel>)ec.MapToList <ContractViewModel>(() => new ContractViewModel()
            {
                ID             = contract.ID,
                CustomId       = contract.CustomId,
                CustomName     = custom.CustomName,
                CustomTypeName = customType.CustomTypeName,
                ContractNo     = contract.ContractNo,
                ContractAmount = contract.ContractAmount,
                Deductions     = contract.Deductions,
                Balance        = contract.Balance,
                Remark         = contract.Remark,
                Sort           = contract.Sort,
                Status         = contract.Status,
                CreateId       = contract.CreateId,
                CreateUser     = contract.CreateUser,
                CreateIP       = contract.CreateIP,
                CreateTime     = contract.CreateTime,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <TicketBatchViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <TicketBatchViewModel> rsp = new JsonRsp <TicketBatchViewModel>();


            TicketBatchModel ticket     = new TicketBatchModel();
            TicketTypeModel  ticketType = new TicketTypeModel();

            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(ticket)
                        .Join(ticketType).On(ticket.TicketTypeId, ticketType.ID)
                        .Select()
                        .OrderBy(ticket.ID, "desc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <TicketBatchViewModel>)ec.MapToList <TicketBatchViewModel>(() => new TicketBatchViewModel()
            {
                ID              = ticket.ID,
                TicketTypeId    = ticket.TicketTypeId,
                TicketTypeIdStr = ticketType.TicketTypeName,
                TicketBatchNo   = ticket.TicketBatchNo,
                TicketPrefix    = ticket.TicketPrefix,
                DataFrom        = ticket.DataFrom,
                Count           = ticket.Count,
                TicketBatchName = ticket.TicketBatchName,
                CreateId        = ticket.CreateId,
                CreateUser      = ticket.CreateUser,
                CreateIP        = ticket.CreateIP,
                CreateTime      = ticket.CreateTime,
                Status          = ticket.Status,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#10
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <BankAccountViewModel> GetPageList(int pageIndex, int pageSize, bool limit = true)
        {
            JsonRsp <BankAccountViewModel> rsp = new JsonRsp <BankAccountViewModel>();

            BankAccountModel ba = new BankAccountModel();
            BankModel        b  = new BankModel();
            OQL joinQ           = OQL.From(ba)
                                  .Join(b).On(ba.BankId, b.ID)
                                  .Select()
                                  .OrderBy(ba.Sort, "desc")
                                  .END;

            //分页
            if (limit)
            {
                joinQ.Limit(pageSize, pageIndex, true);
            }
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <BankAccountViewModel>)ec.MapToList <BankAccountViewModel>(() => new BankAccountViewModel()
            {
                ID = ba.ID,
                BankAccountName = ba.BankAccountName,
                BankName        = b.BankName,
                BankId          = ba.BankId,
                BankAccountCode = ba.BankAccountCode,
                CreateId        = ba.CreateId,
                CreateUser      = ba.CreateUser,
                CreateIP        = ba.CreateIP,
                CreateTime      = ba.CreateTime,
                Sort            = ba.Sort,
                Status          = ba.Status,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
        /// <summary>
        /// 获取列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <CustomAccReceiptViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <CustomAccReceiptViewModel> rsp = new JsonRsp <CustomAccReceiptViewModel>();
            CustomAccReceiptModel CustomAccReceipt  = new CustomAccReceiptModel();
            CustomModel           custom            = new CustomModel();

            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(CustomAccReceipt)
                        .Join(custom).On(CustomAccReceipt.CustomId, custom.ID)
                        .Select()
                        .OrderBy(CustomAccReceipt.CreateTime, "asc")
                        .END;

            joinQ.Limit(pageSize, pageIndex, true);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            rsp.data = (List <CustomAccReceiptViewModel>)ec.MapToList <CustomAccReceiptViewModel>(() => new CustomAccReceiptViewModel()
            {
                ID            = CustomAccReceipt.ID,
                CustomId      = CustomAccReceipt.CustomId,
                CustomName    = custom.CustomName,
                ChargeCardNo  = CustomAccReceipt.ChargeCardNo,
                CurrentAmount = CustomAccReceipt.CurrentAmount,
                Remark        = CustomAccReceipt.Remark,
                Status        = CustomAccReceipt.Status,
                CreateId      = CustomAccReceipt.CreateId,
                CreateUser    = CustomAccReceipt.CreateUser,
                CreateIP      = CustomAccReceipt.CreateIP,
                CreateTime    = CustomAccReceipt.CreateTime,
            });
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = joinQ.PageWithAllRecordCount;
            return(rsp);
        }
示例#12
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Add(ChargeCardsModel model)
        {
            model.ChargeCardNo = "H" + model.CustomId + DateTime.Now.ToString("yyyyMMddHHmmss");
            //开启事务
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();

            int returnvalue = 0;

            try
            {
                db.BeginTransaction();
                //客户财务信息操作

                //获取当前客户财务信息
                CustomFinancialModel financialModel = OQL.FromObject <CustomFinancialModel>().Select().Where((cmp, m) => cmp.Comparer(m.CustomId, "=", model.CustomId) & cmp.Comparer(m.TenantId, "=", TenantId)).END.ToObject(db);
                if (financialModel == null)
                {
                    db.Rollback();
                    return(new JsonRsp {
                        success = false, retmsg = "获取客户合同信息失败"
                    });
                }
                decimal amount = model.CurrentAmount;
                string  remark = "客户充卡";
                if (model.MoneyType == (int)MoneyTypeEnum.应收)
                {
                    if (financialModel.MoneyTypeOneAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeOneAmount + ""
                        });
                    }
                    financialModel.MoneyTypeOneAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeOneAmount;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.赠送)
                {
                    if (financialModel.MoneyTypeTwoAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeTwoAmount + ""
                        });
                    }
                    financialModel.MoneyTypeTwoAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeTwoAmount;;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.置换)
                {
                    if (financialModel.MoneyTypeThreeAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeThreeAmount + ""
                        });
                    }
                    financialModel.MoneyTypeThreeAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeThreeAmount;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                returnvalue += Update <CustomFinancialModel>(financialModel, db);
                returnvalue += Add <ChargeCardsModel>(model, db);

                //新增客户应付
                CustomAccReceiptModel customAR = new CustomAccReceiptModel();
                customAR.CustomId      = model.CustomId;
                customAR.ChargeCardNo  = model.ChargeCardNo;
                customAR.CurrentAmount = model.MoneyType == (int)MoneyTypeEnum.应收 ? model.CurrentAmount : 0;
                customAR.Status        = (int)ARStatusEnum.已确认;
                customAR.CreateId      = AdminId;
                customAR.CreateUser    = AdminName;
                customAR.CreateIP      = Util.GetLocalIP;
                customAR.CreateTime    = DateTime.Now;
                returnvalue           += Add <CustomAccReceiptModel>(customAR, db);

                //事务提交
                if (returnvalue == 4)
                {
                    db.Commit();
                }
                else
                {
                    returnvalue = 0;
                    db.Rollback();
                }
            }
            catch (Exception ex)
            {
                //事务回滚
                db.Rollback();
                return(new JsonRsp {
                    success = false, retmsg = ex.Message.ToString()
                });
            }
            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });
        }
示例#13
0
        /// <summary>
        /// 获取商品销售价格信息
        /// </summary>
        /// <returns></returns>
        public IEnumerable <GoodsSaleInfoVM> GetGoodsSaleInfo()
        {
            GoodsBaseInfo bInfo = new GoodsBaseInfo();
            GoodsStock    stock = new GoodsStock();

            /*
             * Select采用指定详细实体类属性的方式:
             * OQL joinQ = OQL.From(bInfo)
             *  .Join(stock).On(bInfo.SerialNumber, stock.SerialNumber)
             *  .Select(
             *          bInfo.GoodsName,
             *          bInfo.Manufacturer,
             *          bInfo.SerialNumber,
             *          stock.GoodsPrice,
             *          stock.MakeOnDate,
             *          bInfo.CanUserMonth,
             *          stock.Stocks,
             *          stock.GoodsID)
             *  .OrderBy(bInfo.GoodsName, "asc")
             *  .END;
             */

            //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定
            OQL joinQ = OQL.From(bInfo)
                        .Join(stock).On(bInfo.SerialNumber, stock.SerialNumber)
                        .Select()
                        .OrderBy(bInfo.SerialNumber, "asc").OrderBy(bInfo.GoodsName, "asc")
                        .END;

            joinQ.Limit(3, 3);

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            /*
             * 如果OQL的Select方法指定了详细的实体类属性,那么映射结果,可以采取下面的方式:
             * var result = ec.Map<GoodsSaleInfoVM>(e =>
             *  {
             *      e.GoodsName = ec.GetItemValue<string>(0);
             *      e.Manufacturer = ec.GetItemValue<string>(1);
             *      e.SerialNumber  = ec.GetItemValue<string>(2);
             *      e.GoodsPrice  = ec.GetItemValue<decimal>(3);
             *      e.MakeOnDate = ec.GetItemValue<DateTime>(4);
             *      e.CanUserMonth = ec.GetItemValue<int>(5);
             *      e.Stocks = ec.GetItemValue<int>(6);
             *      e.GoodsID = ec.GetItemValue<int>(7);
             *      return e;
             *  }
             * );
             */
            var result = ec.MapToList <GoodsSaleInfoVM>(() => new GoodsSaleInfoVM()
            {
                GoodsName    = bInfo.GoodsName,
                Manufacturer = bInfo.Manufacturer,
                SerialNumber = bInfo.SerialNumber,
                GoodsPrice   = stock.GoodsPrice,
                MakeOnDate   = stock.MakeOnDate,
                CanUserMonth = bInfo.CanUserMonth,
                Stocks       = stock.Stocks,
                GoodsID      = stock.GoodsID,
                ExpireDate   = stock.MakeOnDate.AddMonths(bInfo.CanUserMonth)
            });

            return(result);
        }
示例#14
0
        /// <summary>
        /// 获取用户权限菜单
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="menuType"></param>
        /// <returns></returns>
        public List <MenuViewModel> GetMenuListByAccountId(long accountId, long menuType)
        {
            AdminRole        role = new AdminRole();
            AdminAccountRole ar   = new AdminAccountRole();

            ar.AccountID = accountId;
            OQL joinQ = OQL.From(role)
                        .Join(ar).On(role.ID, ar.RoleID)
                        .Select(role.MenuIds)
                        .Where(ar.AccountID)
                        .OrderBy(role.Sort, "desc")
                        .END;

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer  ec       = new EntityContainer(joinQ, db);
            List <AdminRole> roleList = (List <AdminRole>)ec.MapToList <AdminRole>(() => new AdminRole()
            {
                MenuIds = role.MenuIds,
            });

            StringBuilder sbMenuIds = new StringBuilder();

            foreach (AdminRole item in roleList)
            {
                sbMenuIds.Append(item.MenuIds);
            }

            //long[] roleArr = Array.ConvertAll(sbMenuIds.ToString().Split(','), long.Parse);


            JsonRsp <MenuViewModel> rsp = new JsonRsp <MenuViewModel>();
            AdminMenu model             = new AdminMenu();
            OQL       q = new OQL(model);

            if (menuType > 0)
            {
                q.Select()
                .Where(q.Condition.AND(model.MenuType, "=", menuType).AND(model.Status, ">", -1))
                .OrderBy(model.Sort, "desc");
            }
            else
            {
                q.Select()
                .Where(q.Condition.AND(model.Status, ">", -1))
                .OrderBy(model.Sort, "desc");
            }

            List <AdminMenu> list = q.ToList <AdminMenu>();//使用OQL扩展

            return(list.ConvertAll <MenuViewModel>(o =>
            {
                return new MenuViewModel()
                {
                    ID = o.ID,
                    ParentID = o.ParentID,
                    MenuKey = o.MenuKey,
                    MenuName = o.MenuName,
                    MenuUrl = o.MenuUrl,
                    MenuType = o.MenuType,
                    Sort = o.Sort,
                    Status = o.Status,
                    CreateTime = o.CreateTime,
                };
            }
                                                   ));
        }
示例#15
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Audit(long[] Ids, int status)
        {
            #region
            if (Ids == null)
            {
                return(new JsonRsp {
                    success = false, retmsg = "请选择要操作的数据"
                });
            }

            int returnvalue = 0;
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            try
            {
                //开始事务
                db.BeginTransaction();

                //更新状态
                ContractModel model = new ContractModel();
                OQL           qList = OQL.From(model)
                                      .Select()
                                      .OrderBy(model.Sort, "asc")
                                      .END;
                List <ContractModel> items = qList.ToList <ContractModel>();
                foreach (ContractModel item in items)
                {
                    if (item.Status != 0)
                    {
                        return(new JsonRsp {
                            success = false, retmsg = "只能审核待审核合同,该合同当前状态为:" + Util.getStatus(item.Status, typeof(BaseEnum.ProtocolTypeEnum))
                        });
                    }
                    //更新合同状态
                    item.Status  = status;
                    returnvalue += Update <ContractModel>(item, db, false);

                    string remark = "合同/协议号:" + item.ContractNo + "审核通过";
                    //获取当前客户财务信息
                    CustomFinancialModel financialModel = OQL.FromObject <CustomFinancialModel>().Select().Where((cmp, m) => cmp.Comparer(m.CustomId, "=", item.CustomId) & cmp.Comparer(m.TenantId, "=", item.TenantId)).END.ToObject(db);
                    if (financialModel == null)
                    {
                        financialModel = new CustomFinancialModel();
                        //客户财务信息初始化
                        financialModel.CustomId                  = item.CustomId;
                        financialModel.MoneyTypeOneAmount        = item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeOneTotalAmount   = item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeTwoAmount        = item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeTwoTotalAmount   = item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeThreeAmount      = item.MoneyTypeThreeAmount;
                        financialModel.MoneyTypeThreeTotalAmount = item.MoneyTypeThreeAmount;
                        financialModel.Status = 1;
                        returnvalue          += Add <CustomFinancialModel>(financialModel, db);
                    }
                    else
                    {
                        //客户财务信息修改
                        financialModel.CustomId                   = item.CustomId;
                        financialModel.MoneyTypeOneAmount        += item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeOneTotalAmount   += item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeTwoAmount        += item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeTwoTotalAmount   += item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeThreeAmount      += item.MoneyTypeThreeAmount;
                        financialModel.MoneyTypeThreeTotalAmount += item.MoneyTypeThreeAmount;
                        financialModel.Status = 1;
                        returnvalue          += Update <CustomFinancialModel>(financialModel, db);
                    }

                    //新增客户财务信息日志
                    //应收明细
                    CustomFinancialDetailModel financialDetailOne = new CustomFinancialDetailModel();
                    financialDetailOne.CustomFinancialId = financialModel.ID;
                    financialDetailOne.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailOne.CurrentAmount    += item.MoneyTypeOneAmount;
                    financialDetailOne.Balance          += item.MoneyTypeOneAmount;
                    financialDetailOne.Remark            = remark;
                    financialDetailOne.Status            = 1;
                    financialDetailOne.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailOne, db);
                    //赠送明细
                    CustomFinancialDetailModel financialDetailTwo = new CustomFinancialDetailModel();
                    financialDetailTwo.CustomFinancialId = financialModel.ID;
                    financialDetailTwo.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailTwo.CurrentAmount    += item.MoneyTypeTwoAmount;
                    financialDetailTwo.Balance          += item.MoneyTypeTwoAmount;
                    financialDetailTwo.Remark            = remark;
                    financialDetailTwo.Status            = 1;
                    financialDetailTwo.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailTwo, db);
                    //置换明细
                    CustomFinancialDetailModel financialDetailThree = new CustomFinancialDetailModel();
                    financialDetailThree.CustomFinancialId = financialModel.ID;
                    financialDetailThree.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailThree.CurrentAmount    += item.MoneyTypeThreeAmount;
                    financialDetailThree.Balance          += item.MoneyTypeThreeAmount;
                    financialDetailThree.Remark            = remark;
                    financialDetailThree.Status            = 1;
                    financialDetailThree.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailThree);
                    //事务提交
                    if (returnvalue == 5)
                    {
                        db.Commit();
                    }
                    else
                    {
                        returnvalue = 0;
                        db.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                //事务回滚
                db.Rollback();
                return(new JsonRsp {
                    success = false, retmsg = ex.Message.ToString()
                });
            }
            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });

            #endregion
        }