public bool insertPhongBan(DTO_PhongBan phongBan) { try { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_InsertDataIntoPhongBan"; cmd.Parameters.AddWithValue("maPB", phongBan.maPB); cmd.Parameters.AddWithValue("tenPB", phongBan.maPB); cmd.Parameters.AddWithValue("truongPhong", phongBan.truongPhong); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { } finally { conn.Close(); } return(false); }
//SUA private void btnSua_Click(object sender, EventArgs e) { try { DTO_PhongBan sv = new DTO_PhongBan(txtMaPB.Text, txtTenPB.Text, txtMaTP.Text, txtDiaDiemPB.Text, txtDienThoaiPB.Text, txtEmailPB.Text); BUS_PhongBan.Sua_phongban(sv); DialogResult dr = MessageBox.Show("Sua thanh Cong", "Thông Báo", MessageBoxButtons.OK); loaddata(); if (dr == DialogResult.OK) { loaddata(); } } catch (Exception ex) { MessageBox.Show("Sua không thành công!\n" + ex.Message); } }
private void btLuu_Click(object sender, EventArgs e) { if (txtMaPB.Text != "" && txtTenPB.Text != "" && txtTruongPhong.Text != "") { DTO_PhongBan phongBan = new DTO_PhongBan(txtMaPB.Text, txtTenPB.Text, txtTruongPhong.Text);; if (busPhongBan.insertPhongBan(phongBan)) { MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGridView_Phong(); CloseTextbox(); } else { MessageBox.Show("Thêm không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Xin hãy nhập đầy đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btSua_Click(object sender, EventArgs e) { if (txtMaPB.Text != "" && txtTenPB.Text != "" && txtTruongPhong.Text != "") { DTO_PhongBan phongBan = new DTO_PhongBan(txtMaPB.Text, txtTenPB.Text, txtTruongPhong.Text);; if (MessageBox.Show("Bạn có chắc muốn sửa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (busPhongBan.updatePhongBan(phongBan)) { MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGridView_Phong(); CloseTextbox(); } else { MessageBox.Show("Sửa không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Xin hãy nhập đầy đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool updatePhongBan(DTO_PhongBan phongBan) { return(dalPhongBan.updatePhongBan(phongBan)); }
public bool insertPhongBan(DTO_PhongBan phongBan) { return(dalPhongBan.insertPhongBan(phongBan)); }
public static void Sua_phongban(DTO_PhongBan nv) { con = DAO_KetNoiDB.OpenConnect(); SqlHelper.ExecuteNonQuery(con, "PR_SUA_PHONGBAN", nv.MaPB, nv.TenPB, nv.MaTP, nv.DiaDiem, nv.DienThoai, nv.Email); DAO_KetNoiDB.CloseConnect(con); }
public static void Sua_phongban(DTO_PhongBan nv) { DAO_PhongBan.Sua_phongban(nv); }
public static void Them_phongban(DTO_PhongBan nv) { DAO_PhongBan.Them_phongban(nv); }