예제 #1
0
        /// <summary>
        /// 获取用户信息 0:数据库操作失败, 1:成功, 2:账号或者密码错误
        /// </summary>
        public int GetEmployee(string userName, string password, out Employee employee)
        {
            int result = 0;

            try
            {
                _daoManager.OpenConnection();
                employee = _employeeDao.GetEmployee(userName, password);
                if (employee == null)
                {
                    result = 2;
                }
                else
                {
                    employee.RightsCodeList = _employeeDao.GetRightsCodeList(userName, password);
                    result = 1;
                }
            }
            catch (Exception exception)
            {
                employee = null;
                LogHelper.GetInstance().Error("[GetEmployee]参数:UserName_" + userName, exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 获取会员卡信息 0:数据库操作失败, 1:成功, 2:会员卡号或者密码错误
        /// </summary>
        public int GetVIPCard(string cardNo, string password, out VIPCard card)
        {
            int result = 0;

            try
            {
                _daoManager.OpenConnection();
                //加密的密码
                string str            = string.Empty;
                string saltedPassword = _vipCardDao.GetCardPassword(cardNo);
                if (!string.IsNullOrEmpty(saltedPassword))
                {
                    int    index = saltedPassword.IndexOf(Delim);
                    string salt  = saltedPassword.Substring(0, index);
                    str = salt + Delim + PasswordCryptographer.SaltPassword(password, salt);
                }
                card   = _vipCardDao.GetVIPCard(cardNo, str);
                result = card == null ? 2 : 1;
            }
            catch (Exception exception)
            {
                card = null;
                LogHelper.GetInstance().Error(string.Format("[GetVIPCard]参数:cardNo_{0}", cardNo), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(result);
        }
예제 #3
0
        public SalesOrder GetSalesOrder(Guid orderId)
        {
            SalesOrder salesOrder = null;

            try
            {
                _daoManager.OpenConnection();
                Order order = _orderDao.GetOrder(orderId);
                if (order != null)
                {
                    IList <OrderDetails> orderDetailsList = _orderDetailsDao.GetOrderDetailsList(orderId);
                    salesOrder = new SalesOrder
                    {
                        order            = order,
                        orderDetailsList = orderDetailsList
                    };
                }
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[GetSalesOrder]参数:orderId_{0}", orderId), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(salesOrder);
        }
예제 #4
0
        public IList <BizRegion> GetAllRegionAndDesk()
        {
            IList <BizRegion> regionList = null;

            try
            {
                _daoManager.OpenConnection();
                regionList = _regionDao.GetAllBizRegion();
                if (regionList != null && regionList.Count > 0)
                {
                    IList <BizDesk> deskList = _deskDao.GetAllBizDesks();
                    if (deskList != null && deskList.Count > 0)
                    {
                        foreach (BizRegion region in regionList)
                        {
                            IList <BizDesk> desks = deskList.Where(desk => desk.RegionID.Equals(region.RegionID)).ToList();
                            if (desks.Count > 0)
                            {
                                region.BizDeskList = desks;
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetAllRegionAndDesk]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(regionList);
        }
예제 #5
0
        public void TestOpenConnection()
        {
            IAccountDao accountDao = (IAccountDao)daoManager[typeof(IAccountDao)];


            Account account = NewAccount();

            try
            {
                daoManager.OpenConnection(daoManager.LocalDataSource.ConnectionString);
                accountDao.Create(account);

                account = accountDao.GetAccountById(1001);
            }
            catch (Exception e)
            {
                // Ignore
                Console.WriteLine("TestCreateAccount, error cause : " + e.Message);
            }
            finally
            {
                daoManager.CloseConnection();
            }

            Assert.IsNotNull(account);
            Assert.AreEqual("*****@*****.**", account.EmailAddress);
        }
예제 #6
0
 public void CreateOrderPayoff(OrderPayoff orderPayoff)
 {
     try
     {
         _daoManager.OpenConnection();
         _orderPayoffDao.CreateOrderPayoff(orderPayoff);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[CreateOrderPayoff]参数:orderPayoff_{0}", JsonConvert.SerializeObject(orderPayoff)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
 }
예제 #7
0
        public IList <GoodsCheckStock> GetGoodsCheckStock()
        {
            IList <GoodsCheckStock> goodsCheckStockList = null;

            try
            {
                _daoManager.OpenConnection();
                goodsCheckStockList = _goodsDao.GetGoodsCheckStock();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetGoodsCheckStock]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(goodsCheckStockList);
        }
예제 #8
0
        /// <summary>
        /// 创建客户信息 0:数据库操作失败, 1:成功, 2:手机号已存在
        /// </summary>
        public int CreateCustomerInfo(CustomerInfo customerInfo)
        {
            int result = 0;

            try
            {
                _daoManager.OpenConnection();
                result = _customerInfoDao.CreateCustomerInfo(customerInfo);
            }
            catch (Exception exception)
            {
                result = 0;
                LogHelper.GetInstance().Error(string.Format("[CreateCustomerInfo]参数:customerInfo_{0}", JsonConvert.SerializeObject(customerInfo)), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(result);
        }
예제 #9
0
        public string GetDailyStatementTimeInterval()
        {
            string timeInterval = string.Empty;

            try
            {
                _daoManager.OpenConnection();
                //日结号
                string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                if (!string.IsNullOrEmpty(dailyStatementNo))
                {
                    timeInterval = _dailyStatementDao.GetDailyStatementTimeInterval(dailyStatementNo);
                }
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetDailyStatementTimeInterval]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(timeInterval);
        }
예제 #10
0
        public Int32 GetVIPCardTradeList(string cardNo, DateTime beginDate, DateTime endDate, out VIPCardTradeRecord cardTradeRecord)
        {
            cardTradeRecord = new VIPCardTradeRecord();
            VIPCard card = null;

            try
            {
                _daoManager.OpenConnection();
                card = _vipCardDao.GetVIPCard(cardNo);
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[GetVIPCardTradeList]参数:cardNo_{0},beginDate_{1},endDate_{2}", cardNo, beginDate, endDate), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            int result = 0;

            if (card != null)
            {
                result = card.Status;
            }
            if (result == 1)
            {
                if (card != null)
                {
                    cardTradeRecord.Balance      = card.Balance;
                    cardTradeRecord.Integral     = card.Integral;
                    cardTradeRecord.DiscountRate = card.DiscountRate;
                }
                cardTradeRecord.VIPCardTradeList = _vipCardTradeDao.GetVIPCardTradeList(cardNo, beginDate, endDate);
            }
            return(result);
        }
예제 #11
0
        public IList <ButtonStyle> GetButtonStyleList()
        {
            IList <ButtonStyle> buttonStyleList = null;

            try
            {
                _daoManager.OpenConnection();
                buttonStyleList = _buttonStyleDao.GetButtonStyleList();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetButtonStyleList]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(buttonStyleList);
        }
예제 #12
0
        public void MultipleContext()
        {
            DomDaoManagerBuilder builder = new DomDaoManagerBuilder();

            builder.Configure("dao_Multiple_Context.config");
            IDaoManager daoManager1 = DaoManager.GetInstance("Contex1");
            IDaoManager daoManager2 = DaoManager.GetInstance("Contex2");

            Assert.IsNotNull(daoManager1);
            Assert.IsNotNull(daoManager2);
            Assert.IsTrue(daoManager2.LocalDataSource.ConnectionString != daoManager1.LocalDataSource.ConnectionString);
            Assert.IsTrue(daoManager2.LocalDataSource.DbProvider.Name != daoManager1.LocalDataSource.DbProvider.Name);

            daoManager1.OpenConnection();
            daoManager2.OpenConnection();

            daoManager1.CloseConnection();
            daoManager2.CloseConnection();
        }
예제 #13
0
        public Shop GetSingleShop()
        {
            Shop shop = null;

            try
            {
                _daoManager.OpenConnection();
                shop = _shopDao.GetSingleShop();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetSingleShop]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(shop);
        }
예제 #14
0
        public IList <Notice> GetAllNotice()
        {
            IList <Notice> noticeList = null;

            try
            {
                _daoManager.OpenConnection();
                noticeList = _noticeDao.GetAllNotice();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetAllNotice]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(noticeList);
        }
예제 #15
0
        public bool CreateReminderOrder(ReminderOrder reminderOrder)
        {
            if (reminderOrder == null || reminderOrder.OrderDetailsIDList == null || reminderOrder.OrderDetailsIDList.Count <= 0)
            {
                return(false);
            }
            bool returnValue = false;

            try
            {
                _daoManager.OpenConnection();
                //添加打印任务
                SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo();
                if (systemConfig.IncludeKitchenPrint)
                {
                    Order order = _orderDao.GetOrder(reminderOrder.OrderID);
                    if (order != null)
                    {
                        SalesOrder salesOrder = new SalesOrder
                        {
                            order            = order,
                            orderDetailsList = _orderDetailsDao.GetOrderDetailsList(reminderOrder.OrderDetailsIDList)
                        };
                        IList <PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 3, reminderOrder.ReasonName);
                        foreach (PrintTask printTask in printTaskList)
                        {
                            _printTaskDao.InsertPrintTask(printTask);
                        }
                    }
                }
                returnValue = true;
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[CreateReminderOrder]参数:reminderOrder_{0}", JsonConvert.SerializeObject(reminderOrder)), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(returnValue);
        }
예제 #16
0
        /// <summary>
        /// 获取交班记录
        /// </summary>
        /// <param name="dailyStatementNo">日结号</param>
        /// <returns></returns>
        public IList <EmployeeHandoverRecord> GetHandoverRecord(string dailyStatementNo)
        {
            IList <EmployeeHandoverRecord> handoverRecordList = null;

            try
            {
                _daoManager.OpenConnection();
                if (!string.IsNullOrEmpty(dailyStatementNo))
                {
                    handoverRecordList = _handoverRecord.GetHandoverRecord(dailyStatementNo);
                }
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetHandoverRecord]参数:dailyStatementNo_" + dailyStatementNo, exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(handoverRecordList);
        }
예제 #17
0
        public IList <BizDesk> GetAllBizDeskByRegion(Guid regionId)
        {
            IList <BizDesk> deskList = null;

            try
            {
                _daoManager.OpenConnection();
                deskList = _deskDao.GetAllBizDeskByRegion(regionId);
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[GetAllBizDeskByRegion]参数:regionId_{0}", regionId), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(deskList);
        }
예제 #18
0
        //获得实体类
        public virtual T GetObject(object keyId)
        {
            T t = default(T);

            try
            {
                _daoManager.OpenConnection();
                t = dao.GetObject(keyId);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write(e.Message);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(t);
        }
예제 #19
0
        public SysBasicData GetSysBasicData()
        {
            SysBasicData basicData = null;

            try
            {
                _daoManager.OpenConnection();
                basicData = new SysBasicData();
                // region
                IList <BizRegion> regionList = _regionDao.GetAllBizRegion();
                if (regionList != null && regionList.Count > 0)
                {
                    IList <BizDesk> deskList = _deskDao.GetAllBizDesks();
                    if (deskList != null && deskList.Count > 0)
                    {
                        foreach (BizRegion region in regionList)
                        {
                            IList <BizDesk> desks = deskList.Where(desk => desk.RegionID.Equals(region.RegionID)).ToList();
                            if (desks.Count > 0)
                            {
                                region.BizDeskList = desks;
                            }
                        }
                    }
                }
                // goodsGroup
                IList <GoodsGroup> goodsGroupList = _goodsGroupDao.GetAllGoodsGroup();
                if (goodsGroupList != null && goodsGroupList.Count > 0)
                {
                    foreach (GoodsGroup item in goodsGroupList)
                    {
                        IList <Goods> goodsList = _goodsDao.GetGoodsListInGroup(item.GoodsGroupID);
                        if (goodsList != null && goodsList.Count > 0)
                        {
                            IList <GoodsDetailsGroup> goodsDetailsGroupList = _goodsDao.GetDetailsGroupIdsInGoods();
                            if (goodsDetailsGroupList != null && goodsDetailsGroupList.Count > 0)
                            {
                                foreach (Goods goods in goodsList)
                                {
                                    IList <Guid> detailsGroupIds = goodsDetailsGroupList.Where(detail => detail.GoodsID.Equals(goods.GoodsID)).Select(detail => detail.DetailsGroupID).ToList();
                                    if (detailsGroupIds.Count > 0)
                                    {
                                        goods.DetailsGroupIDList = detailsGroupIds;
                                    }
                                }
                            }
                        }
                        item.GoodsList = goodsList;
                    }
                }
                // detailsGroup
                IList <DetailsGroup> detailsGroupList = _detailsGroupDao.GetAllDetailsGroup();
                if (detailsGroupList != null && detailsGroupList.Count > 0)
                {
                    IList <Details> detailsInfoList = _detailsDao.GetAllDetails();
                    if (detailsInfoList != null && detailsInfoList.Count > 0)
                    {
                        foreach (DetailsGroup item in detailsGroupList)
                        {
                            IList <Details> detailsList = detailsInfoList.Where(detail => detail.DetailsGroupID.Equals(item.DetailsGroupID)).ToList();
                            if (detailsList.Count > 0)
                            {
                                IList <DetailsDetailsGroup> detailsDetailsGroups = _detailsDao.GetDetailsGroupIdsInDetails();
                                if (detailsDetailsGroups != null && detailsDetailsGroups.Count > 0)
                                {
                                    foreach (Details details in detailsList)
                                    {
                                        IList <Guid> detailsGroupIdList = detailsDetailsGroups.Where(ddg => ddg.DetailsID.Equals(details.DetailsID)).Select(ddg => ddg.DetailsGroupID).ToList();
                                        if (detailsGroupIdList.Count > 0)
                                        {
                                            details.DetailsGroupIDList = detailsGroupIdList;
                                        }
                                    }
                                }
                                item.DetailsList = detailsList;
                            }
                        }
                    }
                }
                // SysBasicData
                basicData.NoticeList               = _noticeDao.GetAllNotice();
                basicData.RegionList               = regionList;
                basicData.DiscountList             = _discountDao.GetAllDiscount();
                basicData.PayoffWayList            = _payoffWayDao.GetAllPayoffWay();
                basicData.ReasonList               = _reasonDao.GetAllReason();
                basicData.GoodsGroupList           = goodsGroupList;
                basicData.DetailsGroupList         = detailsGroupList;
                basicData.GoodsSetMealList         = _goodsSetMealDao.GetAllGoodsSetMeal();
                basicData.GoodsCronTriggerList     = _goodsGroupDao.GetAllGoodsCronTrigger();
                basicData.ButtonStyleList          = _buttonStyleDao.GetButtonStyleList();
                basicData.SysConfig                = _sysConfigDao.GetSystemConfigInfo();
                basicData.PromotionList            = _promotionDao.GetPromotionList();
                basicData.PromotionConditionList   = _promotionDao.GetPromotionConditionList();
                basicData.PromotionCronTriggerList = _promotionDao.GetPromotionCronTriggerList();
                basicData.PromotionPresentList     = _promotionDao.GetPromotionPresentList();
                //限时特价
                basicData.TotalLimitedTimeSaleList = _goodsGroupDao.GetAllGoodsLimitedTimeSale();
                //组合销售
                basicData.TotalCombinedSaleList = _goodsGroupDao.GetAllGoodsCombinedSale();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetSysBasicData]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(basicData);
        }
예제 #20
0
        public void TestCreateUser()
        {
            IUserDao userDao = (IUserDao)daoManager2[typeof(IUserDao)];

            User newUser = new User();

            newUser.Id           = "joe_cool";
            newUser.UserName     = "******";
            newUser.Password     = "******";
            newUser.EmailAddress = "*****@*****.**";
            newUser.LastLogon    = DateTime.Now;

            try
            {
                daoManager2.OpenConnection();
                userDao.Create(newUser);
            }
            catch (Exception e)
            {
                // Ignore
                Console.WriteLine("TestCreateUser, error cause : " + e.Message);
            }
            finally
            {
                daoManager2.CloseConnection();
            }

            DateTime stamp   = DateTime.Now;
            User     joeCool = null;

            try
            {
                // open another session to retrieve the just inserted user
                daoManager2.OpenConnection();

                //The User object you get back is live!
                joeCool = userDao.Load("joe_cool");

                Assert.IsNotNull(joeCool);
                Assert.AreEqual("Joseph Cool", joeCool.UserName);

                //Change its properties and it will get persisted to the database on Close.
                // set Joe Cool's Last Login property
                joeCool.LastLogon = stamp;
            }
            catch (Exception e)
            {
                // Ignore
                Console.WriteLine("TestCreateUser, error cause : " + e.Message);
            }
            finally
            {
                // flush the changes from the Session to the Database
                daoManager2.CloseConnection();
            }

            daoManager2.OpenConnection();
            //The User object you get back is live!
            joeCool = userDao.Load("joe_cool");
            daoManager2.CloseConnection();

            Assert.IsNotNull(joeCool);
            Assert.AreEqual("Joseph Cool", joeCool.UserName);
            Assert.AreEqual(stamp.ToString(), joeCool.LastLogon.ToString());
        }
예제 #21
0
        /// <summary>
        /// 获取营业额统计
        /// </summary>
        /// <param name="deviceNo">设备号</param>
        /// <returns></returns>
        public BusinessReport GetReportDataByHandover(string deviceNo)
        {
            BusinessReport reportData = null;

            try
            {
                _daoManager.OpenConnection();
                //日结
                string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                if (!string.IsNullOrEmpty(dailyStatementNo))
                {
                    BusinessReport           businessReport       = _businessReportDao.GetTurnoverByHandover(dailyStatementNo, deviceNo);
                    int                      workSequence         = businessReport.WorkSequence;
                    IList <OrderDiscountSum> orderDiscountSumList = _businessReportDao.GetOrderDiscountSumByHandover(dailyStatementNo, workSequence);
                    IList <OrderPayoffSum>   orderPayoffSumList   = _businessReportDao.GetOrderPayoffSumByHandover(dailyStatementNo, workSequence);
                    IList <ItemsPrice>       itemsPriceList       = _businessReportDao.GetItemsPriceByHandover(dailyStatementNo, workSequence);

                    IList <SalesPriceByDepart> priceByDepartList = new List <SalesPriceByDepart>();
                    if (itemsPriceList.Count > 0)
                    {
                        string             curDepartName      = itemsPriceList[0].DepartName;
                        decimal            totalDepartPrice   = 0;
                        decimal            totalItemsNum      = 0;
                        IList <ItemsPrice> tempItemsPriceList = new List <ItemsPrice>();
                        foreach (ItemsPrice item in itemsPriceList)
                        {
                            if (item.DepartName != curDepartName)
                            {
                                SalesPriceByDepart salesPrice = new SalesPriceByDepart();
                                salesPrice.DepartName       = curDepartName;
                                salesPrice.TotalDepartPrice = totalDepartPrice;
                                salesPrice.TotalItemsNum    = totalItemsNum;
                                salesPrice.ItemsPriceList   = tempItemsPriceList;
                                priceByDepartList.Add(salesPrice);

                                curDepartName      = item.DepartName;
                                totalDepartPrice   = item.ItemsTotalPrice;
                                totalItemsNum      = item.ItemsTotalQty;
                                tempItemsPriceList = new List <ItemsPrice>();
                            }
                            else
                            {
                                totalDepartPrice += item.ItemsTotalPrice;
                                totalItemsNum    += item.ItemsTotalQty;
                            }
                            tempItemsPriceList.Add(item);
                        }
                        SalesPriceByDepart tempSalesPrice = new SalesPriceByDepart
                        {
                            DepartName       = curDepartName,
                            TotalDepartPrice = totalDepartPrice,
                            TotalItemsNum    = totalItemsNum,
                            ItemsPriceList   = tempItemsPriceList
                        };
                        priceByDepartList.Add(tempSalesPrice);
                    }
                    reportData = new BusinessReport
                    {
                        WorkSequence           = businessReport.WorkSequence,
                        LastHandoverTime       = businessReport.LastHandoverTime,
                        TotalRevenue           = businessReport.TotalRevenue,
                        CutOffTotalPrice       = businessReport.CutOffTotalPrice,
                        DiscountTotalPrice     = businessReport.DiscountTotalPrice,
                        ActualTotalIncome      = businessReport.ActualTotalIncome,
                        TotalServiceFee        = businessReport.TotalServiceFee,
                        BillTotalQty           = businessReport.BillTotalQty,
                        PeopleTotalNum         = businessReport.PeopleTotalNum,
                        orderDiscountSumList   = orderDiscountSumList,
                        orderPayoffSumList     = orderPayoffSumList,
                        salesPriceByDepartList = priceByDepartList
                    };
                }
            }
            catch (Exception exception)
            {
                reportData = null;
                LogHelper.GetInstance().Error("[GetReportDataByHandover]参数:deviceNo_" + deviceNo, exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(reportData);
        }