public void SuaThongTinMonHoc(MonHoc monHoc) { if (connection.State != ConnectionState.Open) { connection.Open(); } SqlCommand command = new SqlCommand("SuaThongTinMonHoc", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@MaMH", monHoc.MaMH); command.Parameters.AddWithValue("@TenMH", monHoc.TenMH); command.ExecuteNonQuery(); connection.Close(); }
public void SuaThongTinMonHoc(MonHoc monHoc) { monHocObject.SuaThongTinMonHoc(monHoc); }
private void btOk_Click(object sender, EventArgs e) { if (type == "Them") { if (txtMaMH.Text != "" && txtTenMH.Text != "") { MonHoc mh = new MonHoc(txtMaMH.Text.Trim(), txtTenMH.Text.Trim(), int.Parse(cbHeSo.SelectedItem.ToString())); if (dal_mh.Them(mh) == true) { FormatData(); ShowData(); EnableMethod(true); MessageBox.Show("Thêm thành công"); } else { Exception ex = dal_mh.GetEx(); MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban"); } } else if (type == "Sua") { if (txtMaMH.Text != "" && txtTenMH.Text != "") { MonHoc mh = new MonHoc(txtMaMH.Text.Trim(), txtTenMH.Text.Trim(), int.Parse(cbHeSo.SelectedItem.ToString())); if (dal_mh.Sua(mh) == true) { FormatData(); ShowData(); MessageBox.Show("Sửa thành công"); EnableMethod(true); } else { Exception ex = dal_mh.GetEx(); MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban"); } } else if (type == "Xoa") { if (txtMaMH.Text != "" && txtTenMH.Text != "") { DialogResult dr = MessageBox.Show("Lớp học liên quan đến Bảng điểm và Thông tin giảng dạy, bạn vẫn muốn xóa?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { dal_mh.Xoa(txtMaMH.Text); EnableMethod(true); ShowData(); } else { EnabledData(false); EnableMethod(true); } } } }