private void frmQuanLySanh_Load(object sender, EventArgs e) { SetDisplayControls(MODE.NORMAL); dgvQuanLySanh.DataSource = BUS_QuanLySanh.GetQLSanhTable(); dgvQuanLySanh.Columns[0].Visible = false; dgvQuanLySanh.Columns[1].HeaderText = "Tên sảnh"; dgvQuanLySanh.Columns[2].HeaderText = "Loại sảnh"; dgvQuanLySanh.Columns[3].HeaderText = "Số lượng bàn tối đa"; dgvQuanLySanh.Columns[4].HeaderText = "Đơn giá bàn tối thiểu"; dgvQuanLySanh.Columns[5].HeaderText = "Ghi chú"; cbbLoaiSanh.DataSource = BUS_QuanLySanh.GetListTenLoaiSanh(); cbbDonGiaBanTT.DataSource = BUS_QuanLySanh.GetListDonGiaBanTT(); }
private void btnXoa_Click(object sender, EventArgs e) { dgvQuanLySanh.Focus(); string tenSanh = dgvQuanLySanh.CurrentRow.Cells[1].Value.ToString(); DialogResult dr = MessageBox.Show("Bạn có muốn xóa sảnh '" + tenSanh + "' không?", "Xóa sảnh", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { int i = dgvQuanLySanh.CurrentCell.RowIndex; DTO_Sanh sanh = new DTO_Sanh(); sanh.maSanh = int.Parse(dgvQuanLySanh.CurrentRow.Cells["MaSanh"].Value.ToString()); BUS_QuanLySanh.DeleteSanh(sanh); dgvQuanLySanh.DataSource = BUS_QuanLySanh.GetQLSanhTable(); ClearAllInputs(); MessageBox.Show("Xóa thành công sảnh '" + tenSanh + "' !"); } }
private void btnLuu_Click(object sender, EventArgs e) { if (txtTenSanh.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenSanh.Focus(); return; } if (txtSoLuongBanTD.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoLuongBanTD.Focus(); return; } int temp; if (!int.TryParse(txtSoLuongBanTD.Text, out temp)) { MessageBox.Show("'Số lượng bàn tối đa' phải là số nguyên, vui lòng nhập lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoLuongBanTD.Focus(); txtSoLuongBanTD.SelectAll(); return; } //DialogResult dr = MessageBox.Show("Bạn có muốn lưu không?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); //if (dr == DialogResult.No) // return; switch (mCurrentMode) { case MODE.INSERT: { int maloaiSanh = int.Parse(BUS_QuanLySanh.GetListMaLoaiSanh()[cbbLoaiSanh.SelectedIndex]); DTO_Sanh sanh = new DTO_Sanh(txtTenSanh.Text, maloaiSanh, int.Parse(txtSoLuongBanTD.Text), txtGhiChu.Text); BUS_QuanLySanh.InsertSanh(sanh); dgvQuanLySanh.DataSource = BUS_QuanLySanh.GetQLSanhTable(); MessageBox.Show("Thêm thành công sảnh '" + sanh.tenSanh + "' !"); SetDisplayControls(MODE.NORMAL); mCurrentMode = MODE.NORMAL; break; } case MODE.EDIT: { int maloaiSanh = int.Parse(BUS_QuanLySanh.GetListMaLoaiSanh()[cbbLoaiSanh.SelectedIndex]); DTO_Sanh sanh = new DTO_Sanh(txtTenSanh.Text, maloaiSanh, int.Parse(txtSoLuongBanTD.Text), txtGhiChu.Text); sanh.maSanh = int.Parse(dgvQuanLySanh.CurrentRow.Cells["MaSanh"].Value.ToString()); BUS_QuanLySanh.UpdateSanh(sanh); dgvQuanLySanh.DataSource = BUS_QuanLySanh.GetQLSanhTable(); MessageBox.Show("Sửa thành công sảnh '" + sanh.tenSanh + "' !"); SetDisplayControls(MODE.NORMAL); mCurrentMode = MODE.NORMAL; break; } default: break; } ClearAllInputs(); dgvQuanLySanh.ClearSelection(); }