public RoomStatePage(Window window, out Pg_RoomStateViewModel viewmodel) { InitializeComponent(); fatherwindow = window; viewmodel = new Pg_RoomStateViewModel(this); this.DataContext = viewmodel; this.Height = window.Height - 70; this.Width = window.Width - 80; this.scrollview.Height = window.Height - 70; this.scrollview.Width = window.Width - 330; }
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(); }
//再修改有房客的房间为维修房和锁房时执行的退房操作 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(); }
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(); } }
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(); } }