public RentRoomInfoWindow(int Type, RentRoom RR = null, int roomID = -1) { this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; InitializeComponent(); this.type = Type; this.roomID = roomID; if (RR != null) { this.rentRoom = RR; } else { this.rentRoom = new RentRoom(); } this.DataContext = this.bindingRentRoom; if (type == EDITACTION) { switchToEditAction(); } else if (type == ADDACTION) { switchToAddAction(); } else { switchToInfoAction(); } //this.DialogResult = false; }
private void btnDeleteRentRoom_Click(object sender, RoutedEventArgs e) { try { using (var db = new RoomManagerEntities2()) { this.IsEnabled = false; var screen = new ConfirmWindow($"Ban Co Chac Muon Xoa Rent Room {rentRoom.id}"); screen.ShowDialog(); if (screen.DialogResult == true) { var deleteItem = new RentRoom() { id = rentRoom.id }; db.RentRooms.Attach(deleteItem); db.RentRooms.Remove(deleteItem); db.SaveChanges(); var oldRoom = db.Rooms.SingleOrDefault(b => b.Id == this.rentRoom.roomID); oldRoom.Status = 1; db.SaveChanges(); this.Close(); } this.IsEnabled = true; } } catch (Exception ex) { this.IsEnabled = true; MessageBox.Show("delete failure"); switchToInfoAction(); } }
public void setDataToForm(RentRoom rentRoom) { tbxID.Text = rentRoom.id.ToString(); tbxRoomID.Text = rentRoom.roomID.ToString(); tbxRenterName.Text = rentRoom.renterName; tbxTel.Text = rentRoom.tel; tbxPrice.Text = rentRoom.price.ToString(); var dateString = rentRoom.date.ToString(); dpDate.SelectedDate = rentRoom.date; }
public RentRoom getDataFromForm() { RentRoom result = new RentRoom(); //result.id = 0;// int.Parse( tbxID.Text); result.roomID = int.Parse(tbxRoomID.Text); result.renterName = tbxRenterName.Text; result.tel = tbxTel.Text; result.price = float.Parse(tbxPrice.Text); result.date = dpDate.SelectedDate.Value; return(result); }
private void dgRentRoom_MouseDoubleClick(object sender, MouseButtonEventArgs e) { RentRoom rr = dgRentRoom.SelectedItem as RentRoom; if (rr != null) { var screen = new RentRoomInfoWindow(RentRoomInfoWindow.INFOACTION, rr); this.IsEnabled = false; screen.ShowDialog(); this.IsEnabled = true; } LoadDuLieu(); }
public void LoadData() { rentRoom = getRentRoomFromData(rentRoom.id); tbID.Text = rentRoom.id.ToString(); tbRoomID.Text = rentRoom.roomID.ToString(); tbRenterName.Text = rentRoom.renterName; tbTel.Text = rentRoom.tel; tbPrice.Text = rentRoom.price.ToString(); tbDate.Text = rentRoom.date.ToString(); UsDetailList = getUSDDetailFromData(); dgUSDDetails.ItemsSource = UsDetailList; var priceUsDetail = UsDetailList.Select(i => i.price).DefaultIfEmpty(0).Sum(); tbTotalPrice.Text = (priceUsDetail + rentRoom.price).ToString() + " USD"; }
private void btnImportRentRoom_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { var wookbook = new Workbook(openFileDialog.FileName); var tabs = wookbook.Worksheets; using (var db = new RoomManagerEntities2()) { foreach (var tab in tabs) { try { if (tab.Name == "RentRoom") { var col = 'B'; var row = 2; var cell = tab.Cells[$"{ col}{ row}"]; while (cell.Value != null) { var newRent = new RentRoom() { roomID = tab.Cells[$"B{row}"].IntValue, renterName = tab.Cells[$"C{row}"].StringValue, tel = tab.Cells[$"D{row}"].StringValue, price = tab.Cells[$"E{row}"].DoubleValue, date = tab.Cells[$"F{row}"].DateTimeValue, }; db.RentRooms.Add(newRent); db.SaveChanges(); row++; cell = tab.Cells[$"{ col}{ row}"]; } LoadRentRoomData(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
public void switchToInfoAction() { type = INFOACTION; lbTitle.Content = "Info Rent Room"; spRentRoomInfo.Visibility = Visibility.Visible; spRentRoomAE.Visibility = Visibility.Collapsed; //data if (type == INFOACTION) { rentRoom = getRentRoomFromData(rentRoom.id); tbID.Text = rentRoom.id.ToString(); tbRoomID.Text = rentRoom.roomID.ToString(); tbRenterName.Text = rentRoom.renterName; tbTel.Text = rentRoom.tel; tbPrice.Text = rentRoom.price.ToString(); tbDate.Text = rentRoom.date.ToString(); } }
public CheckOutWindow(RentRoom rr) { InitializeComponent(); rentRoom = rr; }