public static void UpdateLHP(tblLopHocPhan gv) { SqlConnection Conn = dbConnectionData.ketnoi(); SqlCommand command = new SqlCommand("pr_LopHocPhan_Update", Conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@MaLopHP", SqlDbType.NVarChar, 10); command.Parameters.Add("@PhongHoc", SqlDbType.NVarChar, 100); command.Parameters.Add("@TongSoSV", SqlDbType.NVarChar, 50); command.Parameters.Add("@TietBatDau", SqlDbType.Int, 10); command.Parameters.Add("@TietKetThuc", SqlDbType.Int, 100); command.Parameters.Add("@Thu", SqlDbType.NVarChar, 100); command.Parameters.Add("@MaHP", SqlDbType.NVarChar, 10); command.Parameters.Add("@MaGV", SqlDbType.NVarChar, 10); command.Parameters.Add("@MaHK", SqlDbType.NVarChar, 10); command.Parameters["@MaLopHP"].Value = gv.MaLopHP1; command.Parameters["@PhongHoc"].Value = gv.PhongHoc1; command.Parameters["@TongSoSV"].Value = gv.TongSoSV1; command.Parameters["@TietBatDau"].Value = gv.TietBatDau1; command.Parameters["@TietKetThuc"].Value = gv.TietKetThuc1; command.Parameters["@Thu"].Value = gv.Thu1; command.Parameters["@MaHP"].Value = gv.MaHP1; command.Parameters["@MaGV"].Value = gv.MaGV1; command.Parameters["@MaHK"].Value = gv.MaHK1; Conn.Open(); command.ExecuteNonQuery(); Conn.Close(); }
private void btnSua_Click(object sender, EventArgs e) { try { string ma = txtMaLHP.Text; string ph = txtPhongHoc.Text; string sv = txtTongSV.Text; int bd = int.Parse(cboTietBatDau.Text); int kt = int.Parse(cboTietKetThuc.Text); string th = cboThu.Text; string hp = cboTenHocPhan.Text; string gv = cboTenGV.Text; string hk = cboTenHK.Text; tblLopHocPhan lhp = new tblLopHocPhan(ma, ph, sv, bd, kt, th, hp, gv, hk); busLopHocPhan.InsertLopHocPhan(lhp); MessageBox.Show("them thanh cong"); this.Hide(); Form nk = new frmQLLHP(); nk.Show(); } catch { string ma = txtMaLHP.Text; string ph = txtPhongHoc.Text; string sv = txtTongSV.Text; int bd = int.Parse(cboTietBatDau.Text); int kt = int.Parse(cboTietKetThuc.Text); string th = cboThu.Text; string hp = cboTenHocPhan.Text; string gv = cboTenGV.Text; string hk = cboTenHK.Text; tblLopHocPhan lhp = new tblLopHocPhan(ma, ph, sv, bd, kt, th, hp, gv, hk); busLopHocPhan.UpdateLopHocPhan(lhp); MessageBox.Show("sua thanh cong"); dgvLHP.DataSource = busLopHocPhan.getLopHocPhan(); // dgvLHP.DataSource = busLopHocPhan.getLopHocPhan(); } }