private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            //编辑
            dynamic m = MemberList.SelectedItem;

            if (string.IsNullOrWhiteSpace(card.CardNo))
            {
                throw new ArgumentNullException("卡号", "请输入卡号");
            }
            if (card.CardLevel == Guid.Empty || card.CardLevel == null)
            {
                throw new ArgumentNullException("卡级别", "请选择卡级别");
            }

            DXInfo.Models.aspnet_CustomProfile user = App.MyIdentity.oper;
            if (user == null)
            {
                throw new ArgumentException("操作员信息错误");
            }
            Guid userId = user.UserId;

            if (!user.DeptId.HasValue || user.DeptId == Guid.Empty)
            {
                throw new ArgumentException("部门信息错误");
            }

            var c = uow.Cards.GetAll().Where(w => w.CardNo == card.CardNo).FirstOrDefault();

            if (c != null)
            {
                throw new ArgumentException("卡号已存在");
            }
            StringBuilder sb = new StringBuilder(33);

            sb.Append(card.CardNo);
            int st = CardRef.CoolerPutCard(sb);

            if (st == 0)
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    card.Member     = m.Id;
                    card.DeptId     = user.DeptId.Value;
                    card.UserId     = userId;
                    card.CreateDate = DateTime.Now;
                    uow.Cards.Add(card);
                    uow.Commit();
                    Common.AddCardsLog(uow, card);
                    uow.Commit();
                    transaction.Complete();
                }
                card = new DXInfo.Models.Cards();
                MessageBox.Show("发卡成功");
            }
            else
            {
                MessageBox.Show(CardRef.GetStr(st));
            }
        }
Beispiel #2
0
 //private int _iDiscount;
 public MyIdentity(DXInfo.Models.aspnet_CustomProfile oper,
                   DXInfo.Models.aspnet_Users user, DXInfo.Models.Depts dept, string authenticationType)
 {
     this._oper = oper;
     this._AuthenticationType = authenticationType;
     //this._iDiscount = discount;
     this._dept = dept;
     this._user = user;
 }
Beispiel #3
0
        private void login()
        {
            string userName = this.UserName;
            string passwd   = this.Password;

            if (string.IsNullOrWhiteSpace(userName))
            {
                MessageBox.Show("请输入用户名");
                return;
            }
            if (string.IsNullOrWhiteSpace(passwd))
            {
                MessageBox.Show("请输入密码");
                return;
            }
            if (!Membership.ValidateUser(userName, passwd))
            {
                MessageBox.Show("用户名或密码错误,多次错误后此用户将被锁定");
                return;
            }
            MembershipUser user = Membership.GetUser(userName);

            if (user == null)
            {
                throw new ArgumentException("操作员信息错误");
            }
            Guid userId = Guid.Parse(user.ProviderUserKey.ToString());

            DXInfo.Models.aspnet_CustomProfile oper = Uow.aspnet_CustomProfile.GetById(g => g.UserId == userId);
            if (oper == null)
            {
                throw new ArgumentException("操作员信息错误");
            }

            DXInfo.Models.aspnet_Users auser = Uow.aspnet_Users.GetById(g => g.UserId == userId);

            var nc = Uow.NameCode.GetAll().Where(w => w.Type == "LocalDept").FirstOrDefault();

            if (nc == null)
            {
                MessageBox.Show("请首先设置本地门店", "设置本地门店", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(nc.Value))
            {
                MessageBox.Show("本地门店信息错误", "设置本地门店", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Guid deptId = Guid.Parse(nc.Value);

            if (!oper.DeptId.HasValue)
            {
                MessageBox.Show("请设置操作员门店信息");
                return;
            }
            if (oper.DeptId.Value != deptId && userName != "admin")
            {
                MessageBox.Show("不是这个门店操作员,不能登录");
                return;
            }
            DXInfo.Models.Depts dept = Uow.Depts.GetById(g => g.DeptId == deptId);
            if (dept == null)
            {
                throw new ArgumentException("门店信息错误");
            }

            DXInfo.Principal.MyIdentity mi = new DXInfo.Principal.MyIdentity(oper, auser, dept, "MyIdentity");

            List <DXInfo.Models.aspnet_Sitemaps> lFunc = GetAllSitemapKeys(oper.UserId, auser.UserName);

            DXInfo.Principal.MyPrincipal mp = new DXInfo.Principal.MyPrincipal(mi, lFunc);

            if (Thread.CurrentPrincipal == null)
            {
                AppDomain.CurrentDomain.SetThreadPrincipal(mp);
            }
            else
            {
                Thread.CurrentPrincipal = mp;
            }
            //Uow.Dispose();
            this.UserName = null;
            this.Password = null;
            var rmw = ServiceLocator.Current.GetInstance <RibbonMainWindow>();

            App.Current.MainWindow = rmw;
            rmw.Show();
            Messenger.Default.Send(new CloseViewMessageToken());
        }
Beispiel #4
0
        public OrderInfo GetOrder(string userName, string passwd, string deskNo)
        {
            OrderInfo orderInfo = new OrderInfo();

            if (!LogOn(userName, passwd))
            {
                return(null);
            }
            DXInfo.Models.aspnet_Users user = (from d in uow.aspnet_Users.GetAll() where d.UserName == userName select d).FirstOrDefault();
            if (user == null)
            {
                throw new WebFaultException <string>("无“" + userName + "”操作员信息", HttpStatusCode.MethodNotAllowed);
            }
            orderInfo.OrderDesk.UserId = user.UserId;
            DXInfo.Models.aspnet_CustomProfile userProfile = uow.aspnet_CustomProfile.GetById(g => g.UserId == user.UserId);
            if (userProfile == null)
            {
                throw new WebFaultException <string>("无“" + userName + "”操作员信息", HttpStatusCode.MethodNotAllowed);
            }
            orderInfo.OrderDesk.UserName = user.UserName;
            orderInfo.OrderDesk.FullName = userProfile.FullName;
            //判断桌台是否可用
            DXInfo.Models.Desks curdesk = uow.Desks.GetAll().Where(w => w.Code == deskNo).FirstOrDefault();
            if (curdesk == null)
            {
                //throw new Exception("桌台错误");
                throw new WebFaultException <string>(deskNo + "无此桌台", HttpStatusCode.MethodNotAllowed);
            }
            if (curdesk.Status != 1)
            {
                //throw new Exception("桌台不在用");
                throw new WebFaultException <string>(deskNo + "不在用", HttpStatusCode.MethodNotAllowed);
            }
            orderInfo.OrderDesk.DeskId = curdesk.Id;
            orderInfo.OrderDesk.DeskNo = deskNo;

            //判断桌台是否使用
            DXInfo.Models.OrderDeskes od = (from d in uow.OrderDeskes.GetAll() where d.DeskId == curdesk.Id && d.Status == 0 select d).FirstOrDefault();
            if (od == null)
            {
                //throw new Exception("订单错误");
                throw new WebFaultException <string>(deskNo + "未开台", HttpStatusCode.MethodNotAllowed);
            }
            orderInfo.OrderDesk.OrderDeskId = od.Id;

            DXInfo.Models.OrderDishes orderDish = (from d in uow.OrderDishes.GetAll() where d.Id == od.OrderId select d).FirstOrDefault();
            if (orderDish == null)
            {
                throw new WebFaultException <string>("无此订单", HttpStatusCode.MethodNotAllowed);
            }
            if (!(orderDish.Status == 0 || orderDish.Status == 3))
            {
                throw new WebFaultException <string>("已结账或已撤销", HttpStatusCode.MethodNotAllowed);
            }
            orderInfo.OrderDesk.OrderDishId = orderDish.Id;

            var q = from d in uow.OrderMenus.GetAll()
                    where d.OrderId == od.OrderId && !(d.Status == 1 || d.Status == 7)
                    join i in uow.Inventory.GetAll() on d.InventoryId equals i.Id into di
                    from dis in di.DefaultIfEmpty()

                    join p in uow.OrderPackages.GetAll() on d.PackageId equals p.Id into dp
                    from dps in dp.DefaultIfEmpty()
                    orderby d.Id
                    select new OrderMenuInfo()
            {
                OrderMenuId = d.Id,
                InvId       = d.InventoryId,
                InvCode     = dis.Code,
                InvName     = dis.Name,
                Amount      = d.Amount,
                Quantity    = d.Quantity,
                SalePrice   = d.Price,
                EnglishName = dis.EnglishName,
                Comment     = d.Comment,
                IsAdd       = false,
                IsDelete    = false,
                IsPackage   = d.IsPackage,
                PackageId   = d.PackageId,
                PackageSn   = d.PackageSn,
                Status      = d.Status,
            };

            orderInfo.lOrderMenu = q.ToList();

            List <DXInfo.Models.MenuStatus> lLackMenu = (from d in uow.MenuStatus.GetAll()
                                                         where d.Dept == localDeptId &&
                                                         d.Status == (int)DXInfo.Models.OrderMenuStatus.Lack
                                                         select d).ToList();

            orderInfo.lLackMenu = lLackMenu;

            return(orderInfo);
        }
Beispiel #5
0
        public OrderInfo OpenBookDesk(string userName, string passwd, int quantity,
                                      OrderBookDeskInfo orderBookDesk)
        {
            if (quantity == 0)
            {
                throw new WebFaultException <string>("请输入人数", HttpStatusCode.MethodNotAllowed);
            }
            if (!LogOn(userName, passwd))
            {
                return(null);
            }

            DXInfo.Models.aspnet_Users user = uow.aspnet_Users.GetAll().Where(w => w.UserName == userName).FirstOrDefault();
            if (user == null)
            {
                throw new WebFaultException <string>("无“" + userName + "”操作员信息", HttpStatusCode.MethodNotAllowed);
            }
            Guid userId = user.UserId;

            DXInfo.Models.aspnet_CustomProfile userProfile = uow.aspnet_CustomProfile.GetById(g => g.UserId == userId);
            if (userProfile == null)
            {
                throw new WebFaultException <string>("无“" + userName + "”操作员信息", HttpStatusCode.MethodNotAllowed);
            }
            //判断桌台是否可用
            DXInfo.Models.Desks curdesk = uow.Desks.GetAll().Where(w => w.Id == orderBookDesk.DeskId &&
                                                                   w.Status == (int)DXInfo.Models.DeskStatus.InUse).FirstOrDefault();
            if (curdesk == null)
            {
                throw new WebFaultException <string>("桌台不可用", HttpStatusCode.MethodNotAllowed);
            }
            if (localDeptId == Guid.Empty)
            {
                throw new WebFaultException <string>("未获得本地部门信息", HttpStatusCode.MethodNotAllowed);
            }

            DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(uow, localDeptId, userId);
            DateTime dtOperDate = DateTime.Now;

            dmf.dtOperDate = dtOperDate;
            DXInfo.Models.OrderDishes orderDish = new Models.OrderDishes();
            DXInfo.Models.OrderDeskes orderDesk = new Models.OrderDeskes();
            OrderInfo oi = new OrderInfo();

            try
            {
                dmf.OpenBook(orderBookDesk.OrderBookId, orderBookDesk.DeskId, quantity, true, ref orderDish, ref orderDesk);
                oi.OrderDesk.OrderDishId = orderDish.Id;
                oi.OrderDesk.OrderDeskId = orderDesk.Id;
                oi.OrderDesk.DeskNo      = orderBookDesk.DeskNo;
                oi.OrderDesk.DeskId      = orderBookDesk.DeskId;
                oi.OrderDesk.UserId      = userId;
                oi.OrderDesk.UserName    = userName;
                oi.OrderDesk.FullName    = userProfile.FullName;
                List <DXInfo.Models.MenuStatus> lLackMenu = (from d in uow.MenuStatus.GetAll()
                                                             where d.Dept == localDeptId &&
                                                             d.Status == (int)DXInfo.Models.OrderMenuStatus.Lack
                                                             select d).ToList();
                oi.lLackMenu = lLackMenu;
            }
            catch (Exception ex)
            {
                throw new WebFaultException <string>(ex.Message, HttpStatusCode.MethodNotAllowed);
            }
            return(oi);
        }
Beispiel #6
0
 public MyIdentity()
 {
     this._oper = new Models.aspnet_CustomProfile();
     this._AuthenticationType = "MyIdentity";
     this._dept = new Models.Depts();
 }