Exemplo n.º 1
0
        public MainMenuWindow(Window window, out MainMenuViewModel viewmodel)
        {
            InitializeComponent();
            isclosetrans      = 0;
            this.fatherwindow = window;

            mmbuttons.Add(ToBsManagerButton);
            mmbuttons.Add(ToRoomState);
            DomainTitleDocPanels.Add(BsManagerMenu);
            DomainTitleDocPanels.Add(RoomStateMenu);

            double x = SystemParameters.WorkArea.Width;  //得到屏幕工作区域宽度
            double y = SystemParameters.WorkArea.Height; //得到屏幕工作区域高度

            //this.ShowInTaskbar = false;
            this.Height = y;
            this.Width  = x;

            //获取当前用户并分配权限
            Person nowPerson      = XmlHelper.SelectNowPerson();
            string domains_string = "";

            using (RetailContext context = new RetailContext())
            {
                domains_string = context.PersonTypes.Where(t => t.Name == nowPerson.Type).SingleOrDefault().Domains;
            }
            string[] domains_strings = domains_string.Split(',');
            int      cnd             = 1;

            if (domains_string == "all")
            {
                for (int i = 0; i < mmbuttons.Count(); i++)
                {
                    mmbuttons[i].Visibility = Visibility.Visible;
                    mmbuttons[i].SetValue(Grid.RowProperty, cnd++);
                }
            }
            else
            {
                for (int i = 0; i < mmbuttons.Count(); i++)
                {
                    if (domains_strings.Contains((i + 1).ToString()))
                    {
                        mmbuttons[i].Visibility = Visibility.Visible;
                        mmbuttons[i].SetValue(Grid.RowProperty, cnd++);
                    }
                    else
                    {
                        mmbuttons[i].Visibility = Visibility.Hidden;
                    }
                }
            }

            //设置存在containerpage中的tancontroller的frame
            fatherframe.Width  = x - 80;
            fatherframe.Height = y - 70;

            viewmodel        = new MainMenuViewModel(this);
            this.DataContext = viewmodel;
        }
Exemplo n.º 2
0
 //通过房客ID得到房客信息
 public static Customer GetCustomerbyID(this string id)
 {
     using (RetailContext context = new RetailContext())
     {
         string sql = string.Format("select * from customers where identification = '{0}'", id);
         return(context.Database.SqlQuery <Customer>(sql).SingleOrDefault());
     }
 }
Exemplo n.º 3
0
 //得到预定房客信息
 public static List <Customer> GetHereBooksCustomers()
 {
     using (RetailContext context = new RetailContext())
     {
         string sql = string.Format("select * from customers where identification in (select customID from finishbooks where IsBook = true)");
         return(context.Database.SqlQuery <Customer>(sql).ToList());
     }
 }
Exemplo n.º 4
0
 public static List <Room> GetBookingRoom()
 {
     using (RetailContext context = new RetailContext())
     {
         string sql = string.Format("select * from rooms where UPPER(HEX([roomID])) in (select roomid from finishbooks where IsBook = true)");
         return(context.Database.SqlQuery <Room>(sql).ToList());
     }
 }
Exemplo n.º 5
0
 public List <Finishbook> checkIsBook(Guid roomid)
 {
     using (RetailContext context = new RetailContext())
     {
         string            sql         = string.Format("select * from finishbooks where IsBook = true and roomid = '{0}'", roomid.ConvertGuid());
         List <Finishbook> finishbooks = context.Database.SqlQuery <Finishbook>(sql).ToList();
         return(finishbooks);
     }
 }
Exemplo n.º 6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (RetailContext context = new RetailContext())
            {
                //List<Person> people = conetxt.Persons.ToList();
                //XmlHelper.WriteNowPerson(people[0]);
                PersonType personType = new PersonType()
                {
                    ID      = Guid.NewGuid(),
                    Name    = "超级管理员",
                    Domains = "all",
                };
                context.PersonTypes.Add(personType);
                context.SaveChanges();
            }
            //XmlHelper.SelectNowPerson();

            //ToServerDataHelper.SynchronizeRoomInfo();
            //string path = AppDomain.CurrentDomain.BaseDirectory;
            //string rootpath = path.Substring(0, path.LastIndexOf("bin"));
            //rootpath += "AppData\\xml\\XMLFile1.xml";
            //XmlHelper xmlHelper = new XmlHelper();
            //xmlHelper.SelectAttribute(rootpath);
            //double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度
            //double y = SystemParameters.WorkArea.Height;//得到屏幕工作区域高度
            //RetailContext context = new RetailContext();
            ////List<Room> list = context.Rooms.ToList();
            ////Guid test = list[0].roomID;
            ////string t = ConvertGuid(test);
            ////Room room = context.Database.SqlQuery<Room>(string.Format("SELECT * FROM Rooms WHERE UPPER(HEX([roomID]))='{0}'", "D606C4B8AA28DF4BA6D45E48750853A9")).ToList()[0];
            ////MessageBox.Show(room.roomname);
            ////string sql = string.Format("update Rooms  set roomstate = {1} where UPPER(HEX([roomID]))='{0}' ", "D606C4B8AA28DF4BA6D45E48750853A9", "1");
            ////context.Database.ExecuteSqlCommand(sql);
            ////context.SaveChanges();
            //for(int i = 2; i < 100; i++)
            //{
            //    ValueRule_fullday valueRule_Fullday = new ValueRule_fullday()
            //    {
            //        ID = Guid.NewGuid(),
            //        name = "test"+i,
            //        starthalfprice_time = i.ToString(),
            //        startprice_time = i.ToString(),
            //    };
            //    context.ValueRule_fulldays.Add(valueRule_Fullday);
            //}

            //context.SaveChanges();


            //context.RoomTypes.Add(new RoomType() { Cap = 1, Name = "单人间",ID=Guid.NewGuid(), CanChange=false, IsChecked=false });
            //context.RoomTypes.Add(new RoomType() { Cap = 2, Name = "双人间", ID = Guid.NewGuid(), CanChange = false, IsChecked = false });
            //context.RoomTypes.Add(new RoomType() { Cap = 3, Name = "三人间", ID = Guid.NewGuid(), CanChange = false, IsChecked = false });
            //context.RoomTypes.Add(new RoomType() { Cap = 1, Name = "大床间", ID = Guid.NewGuid(), CanChange = false, IsChecked = false });
            //context.RoomTypes.Add(new RoomType() { Cap = 1, Name = "套间", ID = Guid.NewGuid(), CanChange = false, IsChecked = false });
            //context.RoomTypes.Add(new RoomType() { Cap = 1, Name = "豪华间", ID = Guid.NewGuid(), CanChange = false, IsChecked = false });
            //context.SaveChanges();
        }
Exemplo n.º 7
0
 //动态加载的信息
 public void Initdata(Guid ID)
 {
     using (RetailContext context = new RetailContext())
     {
         string sql    = string.Format("select * from persons where UPPER(HEX([personID])) = '{0}'", ID.ConvertGuid());
         Person person = context.Database.SqlQuery <Person>(sql).SingleOrDefault();
         NameTB.Text     = person.Name;
         SexCB.Text      = person.sex;
         UserTypeCB.Text = person.Type;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 同步订单信息
 /// </summary>
 public static void SynchronizeTransInfo()
 {
     using (RetailContext context = new RetailContext())
     {
         Finishtrans[] finishtrans = context.Finishtranses.ToArray();
         string        data        = JsonConvert.SerializeObject(finishtrans);
         string        result      = httpRequestHelper.PostRequest(ApiPath + "/ClientToServer/SynchronizeTransInfo", data, "application/json");
         //当房间信息同步失败时的操作
         if (result != "ok")
         {
         }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 同步人员信息
 /// </summary>
 public static void SynchronizePersonInfo()
 {
     using (RetailContext context = new RetailContext())
     {
         Person[] people = context.Persons.ToArray();
         string   data   = JsonConvert.SerializeObject(people);
         string   result = httpRequestHelper.PostRequest(ApiPath + "/ClientToServer/SynchronizePersonInfo", data, "application/json");
         //当房间信息同步失败时的操作
         if (result != "ok")
         {
         }
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// 同步房间状态信息
 /// </summary>
 public static void SynchronizeRoomStateInfo()
 {
     using (RetailContext context = new RetailContext())
     {
         RoomStateModel[] roomStateModels = context.RoomStates.ToArray();
         string           data            = JsonConvert.SerializeObject(roomStateModels);
         string           result          = httpRequestHelper.PostRequest(ApiPath + "/ClientToServer/SynchronizeRoomStateInfo", data, "application/json");
         //当房间信息同步失败时的操作
         if (result != "ok")
         {
         }
     }
 }
        private void changeState(Guid roomid, int state)
        {
            string changeroom_sql = string.Format("update rooms set roomstate = {1} where  UPPER(HEX([roomID]))='{0}'", roomid.ConvertGuid(), state);

            using (RetailContext context = new RetailContext())
            {
                context.Database.ExecuteSqlCommand(changeroom_sql);
                context.SaveChanges();
            }
            Pg_RoomStateViewModel infoViewModel = thispage.DataContext as Pg_RoomStateViewModel;

            infoViewModel.ReFlashRoomInfo();
        }
Exemplo n.º 12
0
 private void PUButton_Click(object sender, RoutedEventArgs e)
 {
     using (RetailContext context = new RetailContext())
     {
         var need = context.RoomTypes.Add(new RoomType()
         {
             Name  = "test",
             Cap   = 2,
             Color = "sd",
             ID    = Guid.NewGuid()
         });
         context.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public void ReFlashTable()
 {
     pagenumber = 1;
     using (RetailContext context = new RetailContext())
     {
         //初始化总页数
         var list = context.Persons.ToList();
         pagesum = list.Count();
         //string sql = string.Format("select * from ValueRule_fulldays limit {0},{1}", everypagenumber * (pagenumber-1), everypagenumber * pagenumber);
         string sql      = string.Format("select * from Persons");
         var    needlist = context.Database.SqlQuery <Person>(sql).ToList();
         ItemsList = new ObservableCollection <Person>(needlist);
         thispage.datagrid.ItemsSource = ItemsList;
     }
 }
Exemplo n.º 14
0
        //再修改有房客的房间为维修房和锁房时执行的退房操作
        public static void exitRoom2(Guid roomid, int state)
        {
            string changefinishtrans_sql = string.Format("update finishtranses set IsDoing = false where roomid = '{0}'", roomid.ConvertGuid());
            string changeroom_sql        = string.Format("update rooms set roomstate = {1} where  UPPER(HEX([roomID]))='{0}'", roomid.ConvertGuid(), state);

            using (RetailContext context = new RetailContext())
            {
                context.Database.ExecuteSqlCommand(changefinishtrans_sql);
                context.Database.ExecuteSqlCommand(changeroom_sql);
                context.SaveChanges();
            }
            Pg_RoomStateViewModel infoViewModel = thispage.DataContext as Pg_RoomStateViewModel;

            infoViewModel.ReFlashRoomInfo();
        }
Exemplo n.º 15
0
 private void LoadRoomtypes()
 {
     using (RetailContext context = new RetailContext())
     {
         var roomtypes = context.RoomTypes.ToList();
         foreach (RoomType rt in roomtypes)
         {
             PUComboBoxItemModel item = new PUComboBoxItemModel()
             {
                 Header    = rt.Name,
                 CanDelete = false,
                 Value     = rt.Name,
             };
             rtypeitems.Add(item);
         }
         ComboBoxItemsList = new BindableCollection <PUComboBoxItemModel>(rtypeitems);
     }
 }
Exemplo n.º 16
0
 //设置页面基本功能及信息
 public void setDefaultValue()
 {
     using (RetailContext context = new RetailContext())
     {
         List <PersonType>          personTypes = context.PersonTypes.ToList();
         List <PUComboBoxItemModel> items       = new List <PUComboBoxItemModel>();
         for (int i = 0; i < personTypes.Count(); i++)
         {
             items.Add(new PUComboBoxItemModel()
             {
                 Header    = personTypes[i].Name,
                 CanDelete = false,
                 Value     = personTypes[i].Name,
             });
         }
         this.UserTypeCB.BindingItems = items;
     }
 }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            using (var db = new RetailContext())
            {
                var noUrut = 1;

                var daftarSupplier = db.Suppliers.ToList();
                foreach (var supplier in daftarSupplier)
                {
                    Console.WriteLine("{0}. {1}, {2}", noUrut, supplier.NamaSupplier, supplier.Jalan);

                    noUrut++;
                }
            }

            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
Exemplo n.º 18
0
        public static void exitRoom(Guid roomid)
        {
            string changefinishtrans_sql = string.Format("update finishtranses set IsDoing = false where roomid = '{0}'", roomid.ConvertGuid());
            string changeroom_sql        = string.Format("update rooms set roomstate = 4 where  UPPER(HEX([roomID]))='{0}'", roomid.ConvertGuid());

            using (RetailContext context = new RetailContext())
            {
                context.Database.ExecuteSqlCommand(changefinishtrans_sql);
                context.Database.ExecuteSqlCommand(changeroom_sql);
                context.SaveChanges();
            }
            MessageBoxResult dr = MessageBox.Show("确认退房吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (dr == MessageBoxResult.OK)
            {
                Pg_RoomStateViewModel infoViewModel = thispage.DataContext as Pg_RoomStateViewModel;
                infoViewModel.ReFlashRoomInfo();
            }
        }
Exemplo n.º 19
0
 public static void SaveChanges(Grid grid)
 {
     using (RetailContext context = new RetailContext())
     {
         rooms = context.Rooms.ToList();
         foreach (Room r in rooms)
         {
             context.Rooms.Remove(r);
         }
         foreach (Border bd in grid.Children)
         {
             DockPanel dp       = bd.Child as DockPanel;
             Grid      needgrid = dp.Children[0] as Grid;
             //(needgrid.DataContext as Room).roomID = Guid.NewGuid();
             context.Rooms.Add((needgrid.DataContext as Room));
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 20
0
        public OpenRoomWindow(Guid roomid, out OpenRoomViewModel viewModel, RoomStatePage page)
        {
            InitializeComponent();
            //viewmodel = new AddRoomViewModel(this);
            //this.DataContext = viewmodel;
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.roomid = roomid;
            this.normaltype.IsChecked = true;

            this.fatherpage = page;
            using (RetailContext context = new RetailContext())
            {
                string t    = roomid.ConvertGuid();
                Room   room = context.Database.SqlQuery <Room>(string.Format("SELECT * FROM Rooms WHERE UPPER(HEX([roomID]))='{0}'", t)).ToList()[0];
                this.thisroom = room;
            }
            this.roomname.Text    = thisroom.roomname;
            this.roomtype.Content = thisroom.roomtype;
            viewModel             = new OpenRoomViewModel(this);
            this.DataContext      = viewModel;
            isclosetrans          = 0;
        }
        public ChangeRoomStateWindow(Room room, RoomStatePage page)
        {
            InitializeComponent();
            isclosetrans = 0;
            thisroom     = room;
            thispage     = page;
            PUComboBoxItemModel selecteditem = new PUComboBoxItemModel();

            using (RetailContext context = new RetailContext())
            {
                List <RoomStateModel> roomstates         = context.RoomStates.ToList();
                List <int>            afterstates        = RoomHelper.NowState_AfterState[room.roomstate];
                List <string>         afterstates_string = new List <string>();
                foreach (int i in afterstates)
                {
                    afterstates_string.Add(RoomHelper.StateConfig[i]);
                }
                foreach (RoomStateModel rsm in roomstates)
                {
                    if (afterstates_string.Contains(rsm.Name))
                    {
                        PUComboBoxItemModel pUComboBoxItemModel = new PUComboBoxItemModel()
                        {
                            Header    = rsm.Name,
                            Value     = rsm.Name,
                            CanDelete = false,
                        };
                        StateList.Add(pUComboBoxItemModel);
                        if (rsm.Name == RoomHelper.StateConfig[thisroom.roomstate])
                        {
                            selecteditem = pUComboBoxItemModel;
                        }
                    }
                }
            }
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            StateCombobox.BindingItems = StateList;
            StateCombobox.Text         = selecteditem.Header;
        }
Exemplo n.º 22
0
        private static void CancelBook(object sender, RoutedEventArgs e)
        {
            MessageBoxResult dr = MessageBox.Show("确认取消预定吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (dr == MessageBoxResult.OK)
            {
                using (RetailContext context = new RetailContext())
                {
                    string sql = string.Format("update finishbooks set IsBook = false where UPPER(HEX([transID])) = '{0}'", BookID.ConvertGuid());
                    try
                    {
                        context.Database.ExecuteSqlCommand(sql);
                    }catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    context.SaveChanges();
                }
                ((thispage as RoomStatePage).DataContext as Pg_RoomStateViewModel).ReFlashRoomInfo();
                MessageBox.Show("修改成功");
            }
        }
Exemplo n.º 23
0
        public void UpdateData()
        {
            if (RoomStates[RoomStates.Count() - 1].Name == null && RoomStates[RoomStates.Count() - 1].Color == null)
            {
                new MessageWindow(thiswindow, "有空行还未填写").ShowDialog();
                return;
            }
            else if (RoomStates[RoomStates.Count() - 1].Name == null)
            {
                new MessageWindow(thiswindow, "房间状态不能为空").ShowDialog();
                return;
            }
            Guid[] names = new Guid[GetRoomStates.Count()];
            for (int i = 0; i < GetRoomStates.Count(); i++)
            {
                names[i] = GetRoomStates[i].StateID;
            }
            using (RetailContext context = new RetailContext())
            {
                foreach (RoomStateModel rs in RoomStates)
                {
                    if (names.Contains(rs.StateID))
                    {
                        string sql = string.Format("update RoomStates set Name = '{0}',Color = '{1}' where UPPER(HEX([StateID]))='{2}'", rs.Name, rs.Color, rs.StateID.ConvertGuid());
                        context.Database.ExecuteSqlCommand(sql);
                    }
                    else
                    {
                        context.RoomStates.Add(rs);
                    }
                }
                context.SaveChanges();
            }


            LoadData();
        }
Exemplo n.º 24
0
 public void Login()
 {
     using (RetailContext context = new RetailContext())
     {
         var list = context.Persons.Where(p => p.Name == thiswindow.UserName.Text && p.password == thiswindow.Password.Password).ToList();
         if (list.Count() > 0)
         {
             Person p = list[0];
             //new MessageWindow(thiswindow, "登陆成功").ShowDialog();
             XmlHelper.WriteNowPerson(p);
             thiswindow.ShowInTaskbar = false;
             thiswindow.Hide();
             MainMenuViewModel viewmodel;
             MainMenuWindow    window = new MainMenuWindow(this.thiswindow, out viewmodel);
             window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
             window.ShowDialog();
             thiswindow.Close();
         }
         else
         {
             new MessageWindow(thiswindow, "用户名或者密码错误").ShowDialog();
         }
     }
 }
Exemplo n.º 25
0
 public void LoadData()
 {
     GetRoomStates = new ObservableCollection <RoomStateModel>();
     using (RetailContext context = new RetailContext())
     {
         var rmtypes = context.RoomStates.ToList();
         foreach (RoomStateModel rt in rmtypes)
         {
             GetRoomStates.Add(rt);
         }
     }
     if (RoomStates != null)
     {
         RoomStates.Clear();
     }
     else
     {
         RoomStates = new ObservableCollection <RoomStateModel>();
     }
     foreach (RoomStateModel rs in GetRoomStates)
     {
         RoomStates.Add(rs);
     }
 }
Exemplo n.º 26
0
        public static void LoadRoomInfoByWhat(Page page, Grid grid, int edittype, string what, string row, string type, string state)
        {
            grid.RowDefinitions.Clear();
            grid.ColumnDefinitions.Clear();
            grid.Children.Clear();
            maingrid = grid;
            thispage = page;
            using (RetailContext context = new RetailContext())
            {
                int rows    = 0;
                int columns = 0;

                //List<Room> rooms = context.Rooms.OrderBy(p => p.row).ToList();
                if (edittype >= 0)
                {
                    if (row != "0")
                    {
                        if (state == "")
                        {
                            string sql = string.Format("select * from rooms where roomtype like '%{0}%' and row = {2} order by {3}", type, state, row, what);
                            rooms = context.Database.SqlQuery <Room>(sql).ToList();
                        }
                        else
                        {
                            string sql = string.Format("select * from rooms where roomtype like '%{0}%' and roomstate = {1} and row = {2} order by {3}", type, state, row, what);
                            rooms = context.Database.SqlQuery <Room>(sql).ToList();
                        }
                    }
                    else
                    {
                        if (state == "")
                        {
                            string sql = string.Format("select * from rooms where roomtype like '%{0}%' order by {3}", type, state, row, what);
                            rooms = context.Database.SqlQuery <Room>(sql).ToList();
                        }
                        else
                        {
                            string sql = string.Format("select * from rooms where roomtype like '%{0}%' and roomstate = {1}  order by {3}", type, state, row, what);
                            rooms = context.Database.SqlQuery <Room>(sql).ToList();
                        }
                    }
                }



                Dictionary <int, List <Room> > roomsbywhat = new Dictionary <int, List <Room> >();
                int cnd = 0;
                for (int i = 0; i < rooms.Count(); i++)
                {
                    if (i == 0)
                    {
                        cnd++;
                        roomsbywhat.Add(cnd, new List <Room>());
                        roomsbywhat[cnd].Add(rooms[i]);
                    }
                    else
                    {
                        switch (what)
                        {
                        case "row":
                            if (rooms[i].row != rooms[i - 1].row)
                            {
                                cnd++;
                                roomsbywhat.Add(cnd, new List <Room>());
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            else
                            {
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            break;

                        case "roomtype":
                            if (rooms[i].roomtype != rooms[i - 1].roomtype)
                            {
                                cnd++;
                                roomsbywhat.Add(cnd, new List <Room>());
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            else
                            {
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            break;

                        case "roomstate":
                            if (rooms[i].roomstate != rooms[i - 1].roomstate)
                            {
                                cnd++;
                                roomsbywhat.Add(cnd, new List <Room>());
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            else
                            {
                                roomsbywhat[cnd].Add(rooms[i]);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                rows = cnd;
                cnd  = 0;
                foreach (int key in roomsbywhat.Keys)
                {
                    if (roomsbywhat[key].Count() >= cnd)
                    {
                        cnd = roomsbywhat[key].Count();
                    }
                }
                columns = cnd;
                for (int i = 0; i < rows; i++)
                {
                    RowDefinition rowDefinition = new RowDefinition();
                    rowDefinition.Height = new GridLength(200);
                    grid.RowDefinitions.Add(rowDefinition); //添加行
                }
                for (int i = 0; i < columns; i++)
                {
                    ColumnDefinition columnDefinition = new ColumnDefinition();
                    columnDefinition.Width = new GridLength(150);
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }

                for (int i = 1; i <= rows; i++)
                {
                    roomsbywhat[i].Sort(new IcpColumn());
                    for (int j = 0; j < roomsbywhat[i].Count(); j++)
                    {
                        roomtypes  = context.RoomTypes.ToList();
                        roomstates = context.RoomStates.ToList();

                        if (edittype == 0)
                        {
                            FrameworkElement roominfogrid = MakeRoomInfoBasicCard(roomsbywhat[i][j], i - 1, j, roomstates);
                            grid.Children.Add(roominfogrid);
                        }
                        else if (edittype == 1)
                        {
                            FrameworkElement roominfogrid = MakeRoomInfoEditCard(roomsbywhat[i][j], i - 1, j, roomtypes);
                            grid.Children.Add(roominfogrid);
                        }
                        else if (edittype == 3)
                        {
                            string             getthistrans_sql = string.Format("select * from finishtranses where roomID = '{0}' and IsDoing = true", roomsbywhat[i][j].roomID.ConvertGuid());
                            List <Finishtrans> finishtranses    = context.Database.SqlQuery <Finishtrans>(getthistrans_sql).ToList();
                            string             getthisbook_sql  = string.Format("select * from finishbooks where roomID = '{0}' and IsBook = true", roomsbywhat[i][j].roomID.ConvertGuid());
                            List <Finishbook>  finishbooks      = context.Database.SqlQuery <Finishbook>(getthisbook_sql).ToList();
                            FrameworkElement   roominfogrid     = MakeRoomInfoMainCard(roomsbywhat[i][j], i - 1, j, roomstates, finishtranses, finishbooks);
                            grid.Children.Add(roominfogrid);
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        public OpenRoomViewModel(OpenRoomWindow window)
        {
            this.thiswindow = window;
            var comboList = new List <PUComboBoxItemModel>();

            comboList.Add(new PUComboBoxItemModel()
            {
                Header    = "男",
                CanDelete = false,
                Value     = "男",
            });
            comboList.Add(new PUComboBoxItemModel()
            {
                Header    = "女",
                CanDelete = false,
                Value     = "女",
            });
            ComboBoxItemsList = new BindableCollection <PUComboBoxItemModel>(comboList);
            Booktrans         = checkIsBook(thiswindow.thisroom.roomID);
            using (RetailContext context = new RetailContext())
            {
                if (Booktrans.Count() > 0)
                {
                    string          sql       = string.Format("select * from customers where identification = '{0}'", Booktrans[0].customID);
                    List <Customer> customers = context.Database.SqlQuery <Customer>(sql).ToList();
                    thiswindow.booktip.Margin              = new Thickness(0, 10, 0, 0);
                    thiswindow.booktip.Content             = "该房已被预定,信息如下";
                    thiswindow.booktip.HorizontalAlignment = HorizontalAlignment.Center;
                    thiswindow.booktip.Foreground          = Brushes.Red;
                    thiswindow.customname.Text             = customers[0].Name;
                    thiswindow.customname.IsReadOnly       = true;
                    thiswindow.customsex.Text              = customers[0].sex;
                    thiswindow.customsex.IsEnabled         = false;
                    thiswindow.customIdentify.Text         = customers[0].identification;
                    thiswindow.customIdentify.IsReadOnly   = true;
                    switch (Booktrans[0].opentype)
                    {
                    case "普通房":
                        thiswindow.normaltype.IsChecked = true;
                        break;

                    case "钟点房":
                        thiswindow.hourtype.IsChecked = true;
                        break;

                    case "凌晨房":
                        thiswindow.morningtype.IsChecked = true;
                        break;

                    case "半天房":
                        thiswindow.halfdaytype.IsChecked = true;
                        break;

                    default:
                        break;
                    }
                    switch (Booktrans[0].paytype)
                    {
                    case "支付宝":
                        thiswindow.alipay.IsChecked = true;
                        break;

                    case "微信":
                        thiswindow.wechat.IsChecked = true;
                        break;

                    case "现金":
                        thiswindow.chash.IsChecked = true;
                        break;

                    case "其他":
                        thiswindow.other.IsChecked = true;
                        break;

                    default:
                        break;
                    }
                    thiswindow.InTime.Text  = Booktrans[0].expectstartime;
                    thiswindow.OutTime.Text = Booktrans[0].expectendtime;
                    thiswindow.money.Text   = Booktrans[0].money;
                }
            }
        }
Exemplo n.º 28
0
 public TicketController()
 {
     ctx = new RetailContext();
 }
Exemplo n.º 29
0
 public ProductSupplierRepository(RetailContext context)
 {
     db = context;
 }
Exemplo n.º 30
0
        public void AddRoom()
        {
            string roomtype = thiswindow.roomtype.Text;

            if (thiswindow.roomnrow.Text == "")
            {
                new MessageWindow(thiswindow, "房间楼层不能为空!").ShowDialog();
            }
            else if (thiswindow.dayprice.Text == "")
            {
                new MessageWindow(thiswindow, "房间日单价不能为空!").ShowDialog();
            }
            else if (thiswindow.hourprice.Text == "")
            {
                new MessageWindow(thiswindow, "房间小时单价不能为空!").ShowDialog();
            }
            else if (thiswindow.roomname1.Text == "")
            {
                new MessageWindow(thiswindow, "起始房号不能为空!").ShowDialog();
            }
            else
            {
                int    roomrow   = int.Parse(thiswindow.roomnrow.Text);
                string roomname1 = thiswindow.roomname1.Text;
                string roomname2 = thiswindow.roomname2.Text;
                string dayprice  = thiswindow.dayprice.Text;
                string hourprice = thiswindow.hourprice.Text;
                Regex  re        = new Regex("[0-9]+");
                using (RetailContext context = new RetailContext())
                {
                    if (roomname2 != "")
                    {
                        if (!re.IsMatch(roomname1) || !re.IsMatch(roomname2))
                        {
                            new MessageWindow(thiswindow, "起始房号和结束房号必须均为数字!").ShowDialog();
                        }
                        else if (int.Parse(roomname1) > int.Parse(roomname2))
                        {
                            new MessageWindow(thiswindow, "起始房号不能大于结束房号!").ShowDialog();
                        }
                        else
                        {
                            for (int i = int.Parse(roomname1); i <= int.Parse(roomname2); i++)
                            {
                                Room room = new Room()
                                {
                                    roomID        = Guid.NewGuid(),
                                    roomname      = i + "",
                                    roomtype      = roomtype,
                                    roomdayprice  = dayprice,
                                    roomhourprice = hourprice,
                                    roomstate     = 0,
                                    row           = roomrow,
                                    column        = i,
                                    CanUse        = true,
                                };
                                context.Rooms.Add(room);
                            }
                            new MessageWindow(thiswindow, "添加成功").ShowDialog();
                        }
                    }
                    else
                    {
                        if (re.IsMatch(roomname1))
                        {
                            Room room = new Room()
                            {
                                roomID        = Guid.NewGuid(),
                                roomname      = roomname1,
                                roomtype      = roomtype,
                                roomdayprice  = dayprice,
                                roomhourprice = hourprice,
                                row           = roomrow,
                                column        = int.Parse(roomname1),
                                roomstate     = 0,
                                CanUse        = true,
                            };
                            context.Rooms.Add(room);
                        }
                        else
                        {
                            Room room = new Room()
                            {
                                roomID        = Guid.NewGuid(),
                                roomname      = roomname1,
                                roomtype      = roomtype,
                                roomdayprice  = dayprice,
                                roomhourprice = hourprice,
                                row           = roomrow,
                                column        = int.MaxValue,
                                roomstate     = 0,
                                CanUse        = true,
                            };
                            context.Rooms.Add(room);
                        }
                        new MessageWindow(thiswindow, "添加成功").ShowDialog();
                    }
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 31
0
        public void OpenRoom()
        {
            var check = checkedout();

            if (check == "ok")
            {
                using (RetailContext context = new RetailContext())
                {
                    string          getcustomer_sql1  = string.Format("select * from customers where identification in (select customID from finishtranses where IsDoing = true and customID = '{0}') ", this.thiswindow.customIdentify.Text);
                    List <Customer> customers_exists1 = context.Database.SqlQuery <Customer>(getcustomer_sql1).ToList();
                    bool            isexists1         = false;
                    if (customers_exists1.Count() > 0)
                    {
                        isexists1 = true;
                    }
                    if (isexists1)
                    {
                        new MessageWindow(this.thiswindow, "该客户还在本店有未完成订单", true).ShowDialog();
                    }

                    string          getcustomer_sql2  = string.Format("select * from customers where identification = '{0}'", this.thiswindow.customIdentify.Text);
                    List <Customer> customers_exists2 = context.Database.SqlQuery <Customer>(getcustomer_sql2).ToList();
                    bool            isexists2         = false;
                    foreach (Customer ct in customers_exists2)
                    {
                        if (ct.identification == this.thiswindow.customIdentify.Text)
                        {
                            isexists2 = true;
                            break;
                        }
                    }
                    if (!isexists2)
                    {
                        Customer customer = new Customer()
                        {
                            identification = this.thiswindow.customIdentify.Text,
                            Name           = this.thiswindow.customname.Text,
                            sex            = this.thiswindow.customsex.Text,
                        };
                        context.Customers.Add(customer);
                    }
                    string openType = "";
                    if (thiswindow.normaltype.IsChecked == true)
                    {
                        openType = "普通房";
                    }
                    if (thiswindow.hourtype.IsChecked == true)
                    {
                        openType = "钟点房";
                    }
                    if (thiswindow.morningtype.IsChecked == true)
                    {
                        openType = "凌晨房";
                    }
                    if (thiswindow.halfdaytype.IsChecked == true)
                    {
                        openType = "半天房";
                    }
                    string payType = "";
                    if (thiswindow.alipay.IsChecked == true)
                    {
                        payType = "支付宝";
                    }
                    if (thiswindow.wechat.IsChecked == true)
                    {
                        payType = "微信";
                    }
                    if (thiswindow.chash.IsChecked == true)
                    {
                        payType = "现金";
                    }
                    if (thiswindow.other.IsChecked == true)
                    {
                        payType = "其他";
                    }
                    Finishtrans finishtrans = new Finishtrans()
                    {
                        transID       = Guid.NewGuid(),
                        roomID        = thiswindow.thisroom.roomID.ConvertGuid(),
                        customID      = thiswindow.customIdentify.Text,
                        opentype      = openType,
                        balance       = thiswindow.money.Text,
                        startime      = thiswindow.InTime.Text,
                        expectendtime = thiswindow.OutTime.Text,
                        transtime     = DateTime.Now.ToString("yy-MM-dd HH:mm:ss"),
                        money         = thiswindow.money.Text,
                        paytype       = payType,
                        IsDoing       = true,
                    };
                    if (Booktrans.Count() > 0)
                    {
                        finishtrans.bookID = Booktrans[0].transID.ConvertGuid();
                        string changebooksql = "update finishbooks set IsBook = false,formalID = '" + finishtrans.transID.ConvertGuid() + "' where UPPER(HEX([transID]))='" + Booktrans[0].transID.ConvertGuid() + "'";
                        context.Database.ExecuteSqlCommand(changebooksql);
                    }
                    context.Finishtranses.Add(finishtrans);
                    string sql = string.Format("update Rooms  set roomstate = {1} where UPPER(HEX([roomID]))='{0}' ", thiswindow.thisroom.roomID.ConvertGuid(), "1");
                    context.Database.ExecuteSqlCommand(sql);

                    context.SaveChanges();
                }
                Pg_RoomStateViewModel infoViewModel = thiswindow.fatherpage.DataContext as Pg_RoomStateViewModel;
                infoViewModel.ReFlashRoomInfo();

                new MessageWindow(this.thiswindow, "开房成功", true).ShowDialog();
            }
            else
            {
                new MessageWindow(this.thiswindow, check).ShowDialog();
            }
        }