private void btn_Save_Room_Click(object sender, EventArgs e) { int status = 0; BLRoom blR = new BLRoom(); if (rbtn_Empty.Checked == true) { status = 0; } if (rbtn_Hired.Checked == true) { status = 1; } if (rbtn_Reserved.Checked == true) { status = 2; } if (SaveStatus == 1) { blR.CreateRoom(txt_Room_RoomTypeID.Text, txt_Room_OnFloor.Text, status); } else if (SaveStatus == 2) { blR.UpdateRoom(Convert.ToInt32(txt_Room_RoomID.Text), txt_Room_RoomTypeID.Text, txt_Room_OnFloor.Text, status); } SaveStatus = 0; dgv_Room.DataSource = blR.LoadRoom(); dgv_Room_CellClick(null, null); btn_Update_Room.Enabled = true; btn_Create_Room.Enabled = true; btn_Save_Room.Enabled = false; }
private void btn_Delete_Room_Click(object sender, EventArgs e) { BLRoom blR = new BLRoom(); blR.DeleteRoom(Convert.ToInt32(txt_Room_RoomID.Text)); dgv_Room.DataSource = blR.LoadRoom(); dgv_Room_CellClick(null, null); }
private void btnPaid_Click(object sender, EventArgs e) { if (dgvPurchase.Rows.Count > 0) { int r = dgvPurchase.CurrentCell.RowIndex; if (Convert.ToBoolean(this.dgvPurchase.Rows[r].Cells["Paid"].Value) == false) { BLPurchase blPurchase = new BLPurchase(); BLUseService blUseService = new BLUseService(); BLRoom blRoom = new BLRoom(); blPurchase.UpdatePurchase(this.txtPurchaseID.Text, decimal.Parse(this.txtTotal.Text), this.dtpPurchaseDate.Text, this.cmbRoomID.SelectedValue.ToString(), this.cmbStaffID.Text, 1, ref err); dbUseRoom.UpdateUseRoomStatus(this.cmbRoomID.SelectedValue.ToString(), ref err); blUseService.UpdateStatusUseService(this.cmbRoomID.SelectedValue.ToString(), ref err); blRoom.UpdateStatusRoom(this.cmbRoomID.SelectedValue.ToString(), ref err); LoadData(); MessageBox.Show("Paid", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btn_Room_Click(object sender, EventArgs e) { TabControl_Main.TabPages.Clear(); TabControl_Main.TabPages.Add(TabPage_Room); dgv_Room.AutoResizeColumns(); BLRoom dbR = new BLRoom(); var data = dbR.LoadRoom(); if (data != null) { dgv_Room.DataSource = data; } else { dgv_Room.DataSource = null; } dgv_Room_CellClick(null, null); txt_Room_RoomID.Enabled = false; }
private void pbSave_Click(object sender, EventArgs e) { // Mở kết nối // Thêm dữ liệu if (Them) { if (this.txtRoomID.Text == "" || this.cmbRoomType.Text == "") { if (this.txtRoomID.Text == "") { MessageBox.Show("Please fill in Room ID !"); pbCancel_Click(sender, e); return; } else { MessageBox.Show("Please fill in RoomType !"); pbCancel_Click(sender, e); return; } } for (int i = 0; i < dgvRoom.Rows.Count; i++) { if (txtRoomID.Text == dgvRoom.Rows[i].Cells["RoomID"].Value.ToString().Trim()) { MessageBox.Show("Existed '" + txtRoomID.Text + "', please type another one !"); txtRoomID.ResetText(); txtArea.ResetText(); txtNote.ResetText(); txtPrice.ResetText(); txtRoomID.Focus(); pbCancel_Click(sender, e); return; } } try { // Thực hiện lệnh BLRoom blRoom = new BLRoom(); if (this.txtRoomID.Text != "" && this.cmbRoomType.Text != "") { float Price = 0; if (this.txtPrice.Text != "") { Price = float.Parse(this.txtPrice.Text); } blRoom.AddRoom(this.txtRoomID.Text, this.cmbRoomType.SelectedValue.ToString(), this.cbStatus.Checked.ToString(), this.txtNote.Text, this.txtArea.Text, Price, ref err); // Load lại dữ liệu trên DataGridView LoadData(); // Thông báo MessageBox.Show("Added successfully!"); } } catch (SqlException) { this.gbInfor.Text = "Information"; MessageBox.Show("Cannot add data !"); } } else { if (this.txtRoomID.Text == "" || this.cmbRoomType.Text == "") { if (this.txtRoomID.Text == "") { MessageBox.Show("Please fill in Room ID !"); pbCancel_Click(sender, e); return; } else { MessageBox.Show("Please fill in RoomType !"); pbCancel_Click(sender, e); return; } } // Thực hiện lệnh BLRoom blRoom = new BLRoom(); blRoom.UpdateRoom(this.txtRoomID.Text, this.cmbRoomType.SelectedValue.ToString(), this.cbStatus.Checked.ToString(), this.txtNote.Text, this.txtArea.Text, float.Parse(this.txtPrice.Text), ref err); // Thông báo MessageBox.Show("Edited successfully!"); // Load lại dữ liệu trên DataGridView LoadData(); } // Đóng kết nối }