Exemple #1
0
 public ReportService(IReportRepo repo,
                      IVisitInteracting interacting,
                      VisitAssertion assertion,
                      MedicalRepVisitsHandlers visitsHandlers,
                      MedicalRepReportHandlers reportHandlers,
                      IUnitWork unitWork)
 {
     _repo           = repo;
     _interacting    = interacting;
     _assertion      = assertion;
     _visitsHandlers = visitsHandlers;
     _reportHandlers = reportHandlers;
     _unitWork       = unitWork;
 }
Exemple #2
0
 public FlowInstanceApp(IUnitWork <OpenAuthDBContext> unitWork,
                        IRepository <FlowInstance, OpenAuthDBContext> repository
                        , RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp,
                        IHttpClientFactory httpClientFactory, IAuth auth, IServiceProvider serviceProvider,
                        SysMessageApp messageApp)
     : base(unitWork, repository, auth)
 {
     _revelanceApp      = app;
     _flowSchemeApp     = flowSchemeApp;
     _formApp           = formApp;
     _httpClientFactory = httpClientFactory;
     _serviceProvider   = serviceProvider;
     _messageApp        = messageApp;
 }
Exemple #3
0
        /// <summary>
        /// 收取卡片的停车费
        /// </summary>
        /// <param name="info">缴费卡片,为空值时从数据库中获取,主要用于写卡模式时读取到卡片的数据</param>
        /// <param name="payment">缴费记录</param>
        /// <returns></returns>
        public CommandResult PayParkFee(CardInfo info, CardPaymentInfo payment)
        {
            CardInfo original = GetCardByID(payment.CardID).QueryObject;

            if (original != null)
            {
                CardInfo card = original.Clone();
                if (info != null)
                {
                    //复制卡片缴费信息
                    CardDateResolver.Instance.CopyPaidDataToCard(card, info);
                }

                IUnitWork uw = ProviderFactory.Create <IUnitWork>(_RepoUri);

                if (payment.PaymentMode == PaymentMode.Prepay)
                {
                    card.Balance -= payment.Paid;
                }

                //只有卡片在场或可重复出场,并且与缴费记录的进场时间相同,才会更新卡片信息
                if ((card.IsInPark || card.CanRepeatOut) &&
                    payment.EnterDateTime.HasValue &&
                    card.LastDateTime == payment.EnterDateTime.Value)
                {
                    //设置卡片缴费信息
                    card.SetPaidData(payment);

                    _Provider.Update(card, original, uw);
                }

                (ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri)).Insert(payment, uw);
                CommandResult result = uw.Commit();
                if (result.Result == ResultCode.Successful && info != null)
                {
                    //修改卡片实体类信息
                    CardDateResolver.Instance.CopyPaidDataToCard(info, card);
                    //info.Balance = card.Balance;
                    //info.ParkingStatus = card.ParkingStatus;
                    //info.ParkFee = card.ParkFee;
                    //info.PaidDateTime = card.PaidDateTime;
                    //info.TotalFee = card.TotalFee;
                }

                return(result);
            }

            return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)));
        }
Exemple #4
0
        public CommandResult Delete(TASheetGroup info)
        {
            TASheetSearchCondition con = new TASheetSearchCondition();

            con.SheetID = info.SheetID;
            ITASheetProvider provider = ProviderFactory.Create <ITASheetProvider>(_RepoUri);
            IUnitWork        unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            List <TASheet>   items    = provider.GetItems(con).QueryObjects;

            foreach (TASheet item in items)
            {
                provider.Delete(item);
            }
            return(unitWork.Commit());
        }
 public static IForm CreateForm(Form form, IUnitWork <OpenAuthDBContext> unitWork)
 {
     if (form.FrmType == 0)
     {
         return(new LeipiForm(unitWork));
     }
     else if (form.FrmType == 1)
     {
         throw new Exception("自定义表单不需要创建数据库表");
     }
     else
     {
         return(new DragForm(unitWork));
     }
 }
Exemple #6
0
 public RegisterModel(
     UserManager <IdentityUser> userManager,
     SignInManager <IdentityUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender,
     RoleManager <IdentityRole> roleManager,
     IUnitWork iUnitWork)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
     _roleManager   = roleManager;
     _iUnitWork     = iUnitWork;
 }
Exemple #7
0
        public CommandResult Delete(List <ShiftArrange> items)
        {
            IShiftArrangeProvider provider = ProviderFactory.Create <IShiftArrangeProvider>(_RepoUri);
            IUnitWork             unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            if (items != null && items.Count > 0)
            {
                foreach (ShiftArrange item in items)
                {
                    provider.Delete(item, unitWork);
                }
                return(unitWork.Commit());
            }
            return(new CommandResult(ResultCode.NoRecord, "没有记录"));
        }
Exemple #8
0
        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static bool Save(ParkOutDoorLedManager setting)
        {
            try
            {
                SysParaSettingsBll bll = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);
                CommandResult      ret = bll.SaveSetting <ParkOutDoorLedManager>(setting, "OutdoorLed_Park" + setting.ParkID.ToString());

                ParkCarPortSearchCondition con = new ParkCarPortSearchCondition()
                {
                    ParkID = setting.ParkID
                };
                IUnitWork          unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
                List <ParkCarPort> items    = ProviderFactory.Create <IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).GetItems(con).QueryObjects;
                //foreach (OutDoorLedArea area in setting.Areas)
                //{
                //    if (area.CardType != null)
                //    {
                //        ParkCarPort item = items.FirstOrDefault(it => it.CardType.Value == area.CardType && it.CarType.Value == area.CarType);
                //        if (item == null)
                //        {
                //            ParkCarPort pcp = new ParkCarPort()
                //            {
                //                ParkID = setting.ParkID,
                //                CardType = area.CardType,
                //                CarType = area.CarType,
                //                CarPort = (short)area.CarPort,
                //                Vacant = (short)area.Vacant
                //            };
                //            ProviderFactory.Create<IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).Insert(pcp, unitWork);
                //        }
                //        else
                //        {
                //            ParkCarPort pcp = item.Clone();
                //            item.CarPort = (short)area.CarPort;
                //            item.Vacant = (short)area.Vacant;
                //            ProviderFactory.Create<IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).Update(item, pcp, unitWork);
                //        }
                //    }
                //}
                ret = unitWork.Commit();
                return(ret.Result == ResultCode.Successful);
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                return(false);
            }
        }
Exemple #9
0
        public CommandResult ClearShiftArrange(int staffID, DateTime dt)
        {
            IShiftArrangeProvider       provider = ProviderFactory.Create <IShiftArrangeProvider>(_RepoUri);
            ShiftArrangeSearchCondition con      = new ShiftArrangeSearchCondition();

            con.StaffID   = staffID;
            con.ShiftDate = new DatetimeRange(dt, dt);
            List <ShiftArrange> items    = provider.GetItems(con).QueryObjects;
            IUnitWork           unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            foreach (ShiftArrange item in items)
            {
                provider.Delete(item, unitWork);
            }
            return(unitWork.Commit());
        }
Exemple #10
0
        public CommandResult Add(ShiftArrange info)
        {
            IShiftArrangeProvider provider = ProviderFactory.Create <IShiftArrangeProvider>(_RepoUri);
            ShiftArrangeID        id       = new ShiftArrangeID(info.StaffID, info.ShiftID, info.ShiftDate);
            ShiftArrange          item     = provider.GetByID(id).QueryObject;

            if (item == null)
            {
                IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
                provider.Insert(info, unitWork);
                return(unitWork.Commit());
            }
            else //如果已经存在则直接返回
            {
                return(new CommandResult(ResultCode.Successful, ResultCodeDecription.GetDescription(ResultCode.Successful)));
            }
        }
Exemple #11
0
        /// <summary>
        /// 修改数据库中的卡片,不会修改卡片的运行状态
        /// </summary>
        private bool UpdateCard(CardInfo info, IUnitWork unitWork)
        {
            QueryResult <CardInfo> result = _Provider.GetByID(info.CardID);

            if (result.Result == ResultCode.Successful)
            {
                CardInfo original = result.QueryObject;
                //卡片状态保持用数据库中的状态
                info.ParkingStatus = original.ParkingStatus;
                info.LastDateTime  = original.LastDateTime;
                info.LastEntrance  = original.LastEntrance;
                info.LastCarPlate  = original.LastCarPlate;
                _Provider.Update(info, original, unitWork);
                return(true);
            }
            return(false);
        }
        protected override void DoApprove(CustomerOtherReceivable info, IUnitWork unitWork, DateTime dt, string opt)
        {
            CustomerReceivable cr = new CustomerReceivable()
            {
                ID         = Guid.NewGuid(),
                ClassID    = CustomerReceivableType.CustomerOtherReceivable,
                SheetID    = info.ID,
                CustomerID = info.CustomerID,
                CreateDate = dt,
                Amount     = info.Amount,
                Haspaid    = 0,
                Memo       = info.Memo
            };

            ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork);
            base.DoApprove(info, unitWork, dt, opt);
        }
        private void InventoryIn(InventoryCheckRecord record, IUnitWork unitWork)
        {
            ProductInventoryItem pii = new ProductInventoryItem()
            {
                ID             = Guid.NewGuid(),
                ProductID      = record.ProductID,
                WareHouseID    = record.WarehouseID,
                Unit           = record.Unit,
                Price          = record.Price,
                Count          = record.CheckCount - record.Inventory,
                AddDate        = DateTime.Now,
                InventoryItem  = record.ID,
                InventorySheet = "盘盈",
            };

            ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Insert(pii, unitWork);
        }
Exemple #14
0
 /// <summary>
 /// 增加一个订单
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 protected virtual void DoAdd(TEntity info, IUnitWork unitWork, DateTime dt, string opt)
 {
     if (string.IsNullOrEmpty(info.ID))
     {
         info.ID = CreateSheetID(info);
     }
     if (!string.IsNullOrEmpty(info.ID))
     {
         info.LastActiveDate = dt;             //修改最后活动时间
         info.State          = SheetState.Add; //单据状态
         IProvider <TEntity, string> provider = ProviderFactory.Create <IProvider <TEntity, string> >(RepoUri);
         provider.Insert(info, unitWork);
     }
     else
     {
         throw new Exception("创建订单号失败,请重试");
     }
 }
Exemple #15
0
        /// <summary>
        /// 卡片发行
        /// </summary>
        /// <param name="info"></param>
        /// <param name="releaseMoney"></param>
        /// <param name="paymentMode"></param>
        /// <param name="memo"></param>
        /// <param name="keepParkingStatus">是否保持卡片运行状态</param>
        /// <returns></returns>
        public CommandResult CardRelease(CardInfo info, decimal releaseMoney, PaymentMode paymentMode, string memo, bool keepParkingStatus)
        {
            string            op       = OperatorInfo.CurrentOperator.OperatorName;
            string            station  = WorkStationInfo.CurrentStation.StationName;
            IUnitWork         unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); //工作单元
            CardReleaseRecord record   = new CardReleaseRecord
            {
                CardID          = info.CardID,
                OwnerName       = info.OwnerName,
                CardCertificate = info.CardCertificate,
                CarPlate        = info.CarPlate,
                ReleaseDateTime = DateTime.Now,
                CardType        = info.CardType,
                ReleaseMoney    = releaseMoney,
                PaymentMode     = paymentMode,
                Balance         = info.Balance,
                ActivationDate  = info.ActivationDate,
                ValidDate       = info.ValidDate,
                HolidayEnabled  = info.HolidayEnabled,
                Deposit         = info.Deposit,
                OperatorID      = op,
                StationID       = station,
                Memo            = memo
            };

            ProviderFactory.Create <ICardReleaseRecordProvider>(_RepoUri).Insert(record, unitWork);
            info.Release();
            ICardProvider icp     = ProviderFactory.Create <ICardProvider>(_RepoUri);
            CardInfo      origial = icp.GetByID(info.CardID).QueryObject;

            if (origial == null)
            {
                icp.Insert(info, unitWork);
            }
            else if (keepParkingStatus)
            {
                UpdateCard(info, unitWork);
            }
            else
            {
                UpdateCardAll(info, unitWork);
            }
            return(unitWork.Commit());
        }
 public CommandResult Add(CompanyInfo info, decimal prepayment, decimal receivables)
 {
     if (string.IsNullOrEmpty(info.ID))
     {
         info.ID = CreateCustomerID(info.ClassID);
     }
     if (!string.IsNullOrEmpty(info.ID))
     {
         IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);
         ProviderFactory.Create <IProvider <CompanyInfo, string> >(RepoUri).Insert(info, unitWork);
         if (receivables > 0) //增加一条客户应收项
         {
             CustomerReceivable cr = new CustomerReceivable()
             {
                 ID         = Guid.NewGuid(),
                 OrderID    = info.ID + "初始应收",
                 CreateDate = DateTime.Now,
                 CustomerID = info.ID,
                 Amount     = receivables,
                 Memo       = "初始应收",
             };
             ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork);
         }
         if (prepayment > 0)
         {
             CustomerPayment cp = new CustomerPayment()
             {
                 ID             = info.ID + "初始预付款",
                 CustomerID     = info.ID,
                 PaymentMode    = PaymentMode.Cash,
                 LastActiveDate = DateTime.Now,
                 Amount         = prepayment,
                 State          = SheetState.Add,
                 Memo           = "初始预付款"
             };
             ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).Insert(cp, unitWork);
         }
         return(unitWork.Commit());
     }
     else
     {
         return(new CommandResult(ResultCode.Fail, "创建客户编号失败,请重试"));
     }
 }
        public void Insert(TInfo info, IUnitWork unitWork)
        {
            if (unitWork == null)
            {
                throw new NullReferenceException("参数unitWork为空!");
            }
            LDB_UnitWork trans = unitWork as LDB_UnitWork;

            if (trans != null)
            {
                LDB_DataContext ldb = trans.LDB;
                InsertingItem(info, ldb);
            }
            else
            {
                throw new InvalidCastException("参数unitWork不能转换成类型Ralid.LinqDataProvider.UnitWork," +
                                               "请检查参数是否是一个Ralid.LinqDataProvider.UnitWork实例!");
            }
        }
Exemple #18
0
        public void Delete(TInfo info, IUnitWork unitWork)
        {
            if (unitWork == null)
            {
                throw new NullReferenceException("参数unitWork为空!");
            }
            UnitWork trans = unitWork as UnitWork;

            if (trans != null)
            {
                AttendanceDataContext attendance = trans.attendance;
                DeletingItem(info, attendance);
            }
            else
            {
                throw new InvalidCastException("参数unitWork不能转换成类型LJH.LinqDataProvider.UnitWork," +
                                               "请检查参数是否是一个LJH.LinqDataProvider.UnitWork实例!");
            }
        }
Exemple #19
0
        protected override void DoInventory(StackInSheet info, IUnitWork unitWork, DateTime dt, string opt)
        {
            if (info.Items == null || info.Items.Count == 0)
            {
                throw new Exception("单号为 " + info.ID + " 的收货单发货失败,没有收货单项");
            }

            StackInSheet sheet1 = info.Clone() as StackInSheet;

            info.State          = SheetState.Inventory;
            info.LastActiveDate = dt;
            ProviderFactory.Create <IProvider <StackInSheet, string> >(RepoUri).Update(info, sheet1, unitWork);

            AddToProductInventory(info, unitWork); //更新商品库存
            if (info.ClassID == StackInSheetType.InventorySheet)
            {
                AddReceivables(info, unitWork);                                                          //增加供应商的应收账款
            }
        }
 public CommandResult BatchChangeUploadFile(List <YCTBlacklist> records, string uploadFile)
 {
     try
     {
         IUnitWork             unitWork = ProviderFactory.Create <IUnitWork>(_RepoURI);
         IYCTBlacklistProvider provider = ProviderFactory.Create <IYCTBlacklistProvider>(_RepoURI);
         foreach (var item in records)
         {
             var newVal = item.Clone();
             newVal.UploadFile = uploadFile;
             provider.Update(newVal, item, unitWork);
         }
         return(unitWork.Commit());
     }
     catch (Exception ex)
     {
         return(new CommandResult(ResultCode.Fail, ex.Message));
     }
 }
        public void Update(TInfo newVal, TInfo originalVal, IUnitWork unitWork)
        {
            if (unitWork == null)
            {
                throw new NullReferenceException("参数unitWork为空!");
            }
            LDB_UnitWork trans = unitWork as LDB_UnitWork;

            if (trans != null)
            {
                LDB_DataContext ldb = trans.LDB;
                UpdatingItem(newVal, originalVal, ldb);
            }
            else
            {
                throw new InvalidCastException("参数unitWork不能转换成类型Ralid.LinqDataProvider.UnitWork," +
                                               "请检查参数是否是一个Ralid.LinqDataProvider.UnitWork实例!");
            }
        }
Exemple #22
0
        /// <summary>
        /// 卡片挂失,除了收取了卡片工本费还收取了卡片在场内的停车费用,并把卡片置为出场
        /// </summary>
        /// <param name="info"></param>
        /// <param name="reason"></param>
        /// <param name="lostCardCost"></param>
        /// <param name="paymode"></param>
        /// <param name="parkFee"></param>
        /// <returns></returns>
        public CommandResult CardLoss(CardInfo info, string reason, decimal lostCardCost, PaymentMode paymode, CardPaymentInfo parkFee)
        {
            string                op       = OperatorInfo.CurrentOperator.OperatorName;
            string                station  = WorkStationInfo.CurrentStation.StationName;
            IUnitWork             unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardLostRestoreRecord record   = new CardLostRestoreRecord
            {
                CardID          = info.CardID,
                OwnerName       = info.OwnerName,
                CardCertificate = info.CardCertificate,
                CarPlate        = info.CarPlate,
                CardStatus      = (byte)info.Status, //保存卡片的原有卡状态
                LostDateTime    = DateTime.Now,
                LostOperator    = op,
                LostStation     = station,
                LostMemo        = reason,
                LostCardCost    = lostCardCost,
                PaymentMode     = paymode
            };
            ICardLostRestoreRecordProvider lostProvider = ProviderFactory.Create <ICardLostRestoreRecordProvider>(_RepoUri);

            lostProvider.Insert(record, unitWork);

            if (parkFee != null)
            {
                parkFee.OperatorID  = op;
                parkFee.StationID   = station;
                parkFee.PaymentMode = paymode;
                parkFee.Memo        = "卡片挂失";
                ICardPaymentRecordProvider icpp = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri);
                icpp.Insert(parkFee, unitWork);
            }
            //卡片置为挂失并出场
            CardInfo original = info.Clone();

            info.Status        = CardStatus.Loss;
            info.ParkingStatus = ParkingStatus.Out;
            ICardProvider icp = ProviderFactory.Create <ICardProvider>(_RepoUri);

            icp.Update(info, original, unitWork);

            return(unitWork.Commit());
        }
Exemple #23
0
        public void Delete(TInfo info, IUnitWork unitWork)
        {
            if (unitWork == null)
            {
                throw new NullReferenceException("参数unitWork为空!");
            }
            UnitWork trans = unitWork  as UnitWork;

            if (trans != null)
            {
                ParkDataContext parking = trans.Parking;
                DeletingItem(info, parking);
            }
            else
            {
                throw new InvalidCastException("参数unitWork不能转换成类型Ralid.LinqDataProvider.UnitWork," +
                                               "请检查参数是否是一个Ralid.LinqDataProvider.UnitWork实例!");
            }
        }
 private void btnCancel_Click(object sender, EventArgs e)
 {//取消优惠的代码逻辑
     if (CheckInput())
     {
         IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
         //1.删除优惠信息表的此项数据
         IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect);
         preProvider.Delete(_CurrentPreInfo, unitWork);
         //2.将Card表的优惠时数减去
         ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect);
         CardInfo      card         = cardProvider.GetByID(_CurrentPreInfo.CardID).QueryObject;
         CardInfo      newVal       = card.Clone();
         newVal.DiscountHour -= _CurrentPreInfo.PreferentialHour;
         if (newVal.DiscountHour < 0)
         {
             newVal.DiscountHour = 0;
         }
         cardProvider.Update(newVal, card, unitWork);
         //3.保存优惠操作记录
         IPREPreferentialLogProvider preLogProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect);
         PREPreferentialLog          log            = _CurrentPreInfo.CreateLog();
         log.OperatorTime    = DateTime.Now;
         log.IsCancel        = 1;
         log.CancelReason    = this.txtCancelReason.Text.Trim();
         log.WorkstationID   = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstationID;
         log.WorkstationName = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstation;
         log.OperatorID      = PREOperatorInfo.CurrentOperator.OperatorID;
         preLogProvider.Insert(log, unitWork);
         CommandResult result = unitWork.Commit();
         if (result.Result == ResultCode.Successful)
         {
             MessageBox.Show("取消成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearCardInfo();
             ClearInput();
             btnCancel.Enabled = false;
         }
         else
         {
             MessageBox.Show(result.Message);
         }
     }
 }
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="bll"></param>
        /// <param name="email"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public CommandResult Register(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(new CommandResult(ResultCode.Fail, "用户名称不能为空"));
            }
            if (string.IsNullOrEmpty(password))
            {
                return(new CommandResult(ResultCode.Fail, "用户密码不能为空"));
            }
            Operator o = GetByID(userName).QueryObject;

            if (o != null)
            {
                return(new CommandResult(ResultCode.Fail, "用户名称已经被使用,请使用其它的名称"));
            }
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);

            o          = new Operator();
            o.ID       = userName;
            o.Name     = userName;
            o.Password = password;
            ProviderFactory.Create <IProvider <Operator, string> >(RepoUri).Insert(o, unitWork);
            DateTime now = DateTime.Now;

            for (int i = 0; i < 10; i++)
            {
                DateTime   from = new DateTime(now.Year, now.Month, now.Day).AddMonths(i);
                YouhuiQuan yh   = new YouhuiQuan()
                {
                    ID         = Guid.NewGuid().ToString(),
                    CreateDate = now,
                    User       = userName,
                    From       = from,
                    To         = from.AddMonths(1).AddDays(-1),
                    Amount     = 100,
                    Memo       = "注册即送优惠券",
                };
                ProviderFactory.Create <IProvider <YouhuiQuan, string> >(RepoUri).Insert(yh, unitWork);
            }
            return(unitWork.Commit());
        }
        protected override void DoNullify(Order info, IUnitWork unitWork, DateTime dt, string opt)
        {
            //首先取消订单的备货项
            ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();

            con.OrderID   = info.ID;
            con.UnShipped = true;
            List <ProductInventoryItem> items = ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (items != null && items.Count > 0)
            {
                foreach (ProductInventoryItem item in items)
                {
                    ProductInventoryItem clone = item.Clone();
                    item.OrderID   = null;
                    item.OrderItem = null;
                    ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Update(item, clone, unitWork);
                }
            }
            base.DoNullify(info, unitWork, dt, opt);
        }
Exemple #27
0
        private void AddReceivables(StackOutSheet sheet, IUnitWork unitWork)
        {
            List <CustomerReceivable> crs = new List <CustomerReceivable>();

            foreach (StackOutItem si in sheet.Items)  //每一个送货项生成一个应收项,因为一个送货单可能包括多个订单的货,所以分别统计
            {
                CustomerReceivable cr = null;
                if (string.IsNullOrEmpty(si.OrderID))
                {
                    cr = crs.SingleOrDefault(it => string.IsNullOrEmpty(it.OrderID));
                }
                if (!string.IsNullOrEmpty(si.OrderID))
                {
                    cr = crs.SingleOrDefault(it => it.OrderID == si.OrderID);
                }
                if (cr == null)
                {
                    DateTime dt = DateTime.Now;
                    cr = new CustomerReceivable()
                    {
                        ID         = Guid.NewGuid(),
                        CreateDate = dt,
                        ClassID    = CustomerReceivableType.CustomerReceivable,
                        CustomerID = sheet.CustomerID,
                        SheetID    = sheet.ID,
                        OrderID    = si.OrderID,
                        Amount     = si.Amount,
                    };
                    crs.Add(cr);
                }
                else
                {
                    cr.Amount += si.Amount;
                }
            }
            foreach (CustomerReceivable cr in crs)
            {
                ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork);
            }
        }
Exemple #28
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                PREPreferentialInfo info = GetItemFromInput();
                //1.插入优惠信息
                IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
                IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect);
                preProvider.Insert(info, unitWork);
                //2.更新卡片的优惠信息

                ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect);
                CardInfo      card         = cardProvider.GetByID(info.CardID).QueryObject;
                if (card == null)
                {
                    MessageBox.Show("没有此卡片!");
                    return;
                }
                CardInfo newCard = card.Clone();
                newCard.DiscountHour    += info.PreferentialHour;
                newCard.PreferentialTime = info.PreferentialTime;
                cardProvider.Update(newCard, card, unitWork);
                //3.保存优惠操作记录
                IPREPreferentialLogProvider logProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect);
                PREPreferentialLog          log         = info.CreateLog();
                log.OperatorTime = DateTime.Now;
                logProvider.Insert(log, unitWork);
                CommandResult result = unitWork.Commit();
                if (result.Result == ResultCode.Successful)
                {
                    MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearInput();
                }
                else
                {
                    MessageBox.Show(result.Message);
                }
            }
        }
Exemple #29
0
        protected override void DoNullify(CustomerPayment info, IUnitWork unitWork, DateTime dt, string opt)
        {
            List <CustomerPaymentAssign> assigns = (new CustomerPaymentBLL(RepoUri)).GetAssigns(info.ID).QueryObjects;

            if (assigns != null && assigns.Count > 0)
            {
                bool allSuccess = true;
                foreach (CustomerPaymentAssign assign in assigns)
                {
                    CommandResult ret = (new CustomerPaymentAssignBLL(RepoUri)).UndoAssign(assign);
                    if (ret.Result != ResultCode.Successful)
                    {
                        allSuccess = false;
                    }
                }
                if (!allSuccess)
                {
                    throw new Exception("某些应收核销项删除失败,请手动删除这些应收核销项后再继续\"作废\"的操作");
                }
            }
            base.DoNullify(info, unitWork, dt, opt);
        }
Exemple #30
0
        /// <summary>
        /// 增加商品信息,同时指定初始库存
        /// </summary>
        /// <param name="info"></param>
        /// <param name="wareHouseID"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public CommandResult AddProduct(Product info, string wareHouseID, decimal count)
        {
            WareHouse ws = ProviderFactory.Create <IProvider <WareHouse, string> >(RepoUri).GetByID(wareHouseID).QueryObject;

            if (ws == null)
            {
                return(new CommandResult(ResultCode.Fail, "指定的仓库 \"" + wareHouseID + "\" 不存在"));
            }
            if (info.Category != null && !string.IsNullOrEmpty(info.Category.Prefix))
            {
                info.ID = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber(info.Category.Prefix, UserSettings.Current.ProductSerialCount, "product");
            }
            else
            {
                info.ID = ProviderFactory.Create <IAutoNumberCreater>(RepoUri).CreateNumber("P", UserSettings.Current.ProductSerialCount, "product");
            }
            if (!string.IsNullOrEmpty(info.ID))
            {
                IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);
                ProviderFactory.Create <IProvider <Product, string> >(RepoUri).Insert(info, unitWork);
                ProductInventoryItem pii = new ProductInventoryItem()
                {
                    ID             = Guid.NewGuid(),
                    ProductID      = info.ID,
                    WareHouseID    = wareHouseID,
                    Unit           = info.Unit,
                    Price          = info.Price,
                    Count          = count,
                    AddDate        = DateTime.Now,
                    InventorySheet = "初始库存"
                };
                ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Insert(pii, unitWork);
                return(unitWork.Commit());
            }
            else
            {
                return(new CommandResult(ResultCode.Fail, "创建商品编号失败,请重试"));
            }
        }