private static void ShowBookInfo(object sender, RoutedEventArgs e) { Image ig = sender as Image; Finishbook finishbook = ig.DataContext as Finishbook; Customer customer = finishbook.customID.GetCustomerbyID(); string message = string.Format("顾客姓名:{0}\n顾客身份证号:{2}\n预计入住时间:{1}\n定金:{3}", customer.Name, finishbook.expectstartime, customer.identification, finishbook.money); BookID = finishbook.transID; new MessageWindow(message, "预定信息", "取消预定", 200, 250, CancelBook).ShowDialog(); }
public void BookRoom() { 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}' union select customID from finishbooks where IsBook = 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 = "其他"; } Finishbook finishbook = new Finishbook() { transID = Guid.NewGuid(), roomID = thiswindow.thisroom.roomID.ConvertGuid(), customID = thiswindow.customIdentify.Text, opentype = openType, balance = thiswindow.money.Text, expectstartime = thiswindow.InTime.Text, expectendtime = thiswindow.OutTime.Text, money = thiswindow.money.Text, transtime = DateTime.Now.ToString("yy-MM-dd HH:mm:ss"), paytype = payType, IsBook = true, }; context.Finishbooks.Add(finishbook); //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(); } }