private void them() { try { if (txtMaNV.Text == "" || cmbMaPB.Text == "" || txtHoTen.Text == "" || txtTroCap.Text == "") { MessageBox.Show("Vui lòng điều đẩy đủ thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { XuLyThaiSan xl = new XuLyThaiSan(); if (xl.InsertTS(cmbMaPB.Text, txtMaNV.Text, txtHoTen.Text, long.Parse(txtTroCap.Text), DateTime.Parse(dtNgayVe.Text), DateTime.Parse(dtNgayTroLai.Text))) { MessageBox.Show("Thêm thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgvThaiSan.DataSource = xl.LoadTS(); } } catch (Exception) { MessageBox.Show("Vui lòng điều đúng thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void xoa() { try { if (txtMaNV.Text == "") { MessageBox.Show("Vui lòng điều mã nhân viên cần xóa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { XuLyThaiSan xl = new XuLyThaiSan(); if (xl.DeleteTS(txtMaNV.Text)) { MessageBox.Show("Xóa thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Xóa không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgvThaiSan.DataSource = xl.LoadTS(); } } catch (Exception) { MessageBox.Show("Vui lòng điều đúng thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FrmThaiSan_Load(object sender, EventArgs e) { XuLyThaiSan xl = new XuLyThaiSan(); dgvThaiSan.DataSource = xl.LoadTS(); btnLuu.Enabled = false; btnHuy.Enabled = false; //load comboBox cmbMaPB.DataSource = xl.LoadCmb("SELECT * FROM PhongBan"); cmbMaPB.DisplayMember = "MaPB"; }