public void ExcuteProc(TrinhDoHocVan trinhDoHocVan) { //SqlConnection conn = DBUtils.GetDBConnection(); SqlConnection conn = new SqlConnection("Server=DEVSERVER-WIN7\\SQLEXPRESS;Database=ThucTapNhom_QuanLyNhanSu;Integrated Security=true"); // conn.ConnectionString = "Server=DEVSERVER-WIN7\\SQLEXPRESS;Database=ThucTapNhom_QuanLyNhanSu;Integrated Security=true"; //Trusted_Connection=true"; try { conn.Open(); SqlCommand cmd = new SqlCommand("EditTrinhDoHocVan", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@maTrinhDoHocVanCu", SqlDbType.Char, 10)).Value = this.MaTrinhDoHocVanCu; cmd.Parameters.Add(new SqlParameter("@maTrinhDoHocVan", SqlDbType.Char, 10)).Value = trinhDoHocVan.MaTrinhDoHocVan; cmd.Parameters.Add(new SqlParameter("@tenTrinhDoHocVan", SqlDbType.Text)).Value = trinhDoHocVan.TenTrinhDoHocVan; cmd.Parameters.Add(new SqlParameter("@chuyenNganhHoc", SqlDbType.Text)).Value = trinhDoHocVan.ChuyenNganhHoc; //excute proc cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { conn.Close(); conn.Dispose(); } }
private void btnLuu_Click(object sender, EventArgs e) { lockControl(); txtMaTDHV.Focus(); TrinhDoHocVan trinhdohocvan = new TrinhDoHocVan(txtMaTDHV.Text, txtTenTDHV.Text, txtChuyenNganhHoc.Text); if (kt == true) { if (txtMaTDHV.Text == null || txtTenTDHV.Text == null) { MessageBox.Show("Bạn chưa điền đủ thông tin!"); } else { try { addTrinhdohocvan.AddProc(trinhdohocvan); MessageBox.Show("Lưu Thông tin Thành công!"); } catch (Exception a) { MessageBox.Show("Thêm thông tin không thành công!", "ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { TrinhDoHocVan_Controller trinhDoHocVan_Controller = new TrinhDoHocVan_Controller(); trinhDoHocVan_Controller.EditTrinhDoHocVan(trinhdohocvan); } loadList(); }
public static int UpdateHocVan(TrinhDoHocVan hocVan) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@" + config.HOC_VAN_MAHV, hocVan.MaTDHV), new SqlParameter("@" + config.HOC_VAN_TENHV, hocVan.TenTrinhDo), new SqlParameter("@" + config.HOC_VAN_CHUYENNGANH, hocVan.ChuyenNganh) }; return(DataProvider.ExecuteNonQuery(config.PROC_UPDATE_TDHV, para)); }
private TrinhDoHocVan getHocVanToAdd() { TrinhDoHocVan hocVan = new TrinhDoHocVan(); hocVan.TenTrinhDo = txtTenHocVan.Text; hocVan.ChuyenNganh = txtChuyenNganh.Text; hocVan.SoLuong = 0; hocVan.MaTDHV = txtMaHocVan.Text; return(hocVan); }
private TrinhDoHocVan getHocVanFromFRM() { TrinhDoHocVan hocVan = new TrinhDoHocVan(); hocVan.MaTDHV = txtMaHocVan.Text; hocVan.TenTrinhDo = txtTenHocVan.Text; hocVan.ChuyenNganh = txtChuyenNganh.Text; return(hocVan); }
public int SuaTDHV(TrinhDoHocVan obj) { SqlParameter[] para = { new SqlParameter("MaTDHV", obj.MaTDHV), new SqlParameter("TenTDHV", obj.TenTrinhDo), new SqlParameter("ChuyenNganh", obj.ChuyenNganh) }; return(kn.ExcuteSQL("SP_Sua_TDHV", para)); }
public static int AddHocVan(TrinhDoHocVan hocVan) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@" + config.HOC_VAN_MAHV, hocVan.MaTDHV), new SqlParameter("@" + config.HOC_VAN_TENHV, hocVan.TenTrinhDo), new SqlParameter("@" + config.HOC_VAN_SOLUONG, hocVan.SoLuong), new SqlParameter("@" + config.HOC_VAN_CHUYENNGANH, hocVan.ChuyenNganh) }; return(DataProvider.ExecuteNonQuery(config.PROC_INSERT_TDHV, para)); }
public void UpdateTrinhDoHocVan(TrinhDoHocVan trinhDoHocVanUpdate) { try { TrinhDoHocVan trinhDoHocVan = context.TrinhDoHocVans.Where(x => x.MaTrinhDoHocVan == trinhDoHocVanUpdate.MaTrinhDoHocVan).Single <TrinhDoHocVan>(); trinhDoHocVan.TenTrinhDoHocVan = trinhDoHocVanUpdate.TenTrinhDoHocVan; context.SaveChanges(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void DeleteTrinhDoHocVan(int maTrinhDoHocVan) { try { TrinhDoHocVan trinhDoHocVan = context.TrinhDoHocVans.Where(x => x.MaTrinhDoHocVan == maTrinhDoHocVan).Single <TrinhDoHocVan>(); context.TrinhDoHocVans.Remove(trinhDoHocVan); context.SaveChanges(); } catch (Exception e) { throw e; } }
public int AddTrinhDoHocVan(TrinhDoHocVan trinhDoHocVan) { try { context.TrinhDoHocVans.Add(trinhDoHocVan); context.SaveChanges(); int maTrinhDoHocVan = trinhDoHocVan.MaTrinhDoHocVan; return(maTrinhDoHocVan); } catch (Exception e) { throw e; } }
public void EditTrinhDoHocVan(TrinhDoHocVan trinhDoHocVan) { try { openConnection(); string query = "update TRINHDOHOCVAN set TenTDHV = @ten, ChuyenNganhHoc = @chuyennganh where MaTDHV = @matdhv"; SqlCommand cmd = new SqlCommand(query, Conn); cmd.Parameters.AddWithValue("@matdhv", trinhDoHocVan.MaTDHV); cmd.Parameters.AddWithValue("@ten", trinhDoHocVan.TenTDHV); cmd.Parameters.AddWithValue("@chuyennganh", trinhDoHocVan.ChuyenNganhHoc); cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { closeConnection(); } }
public void AddHocVan() { if (!checkEmpty()) { return; } TrinhDoHocVan hocVan = getHocVanToAdd(); int result = Bus.AddHocVan(hocVan); if (result != -1) { MessageBox.Show("Thêm học vấn thành công !", "Thông báo", MessageBoxButtons.OK); LoadData(); ClearTextBox(); enableToolBox(false); isAction = false; } else { MessageBox.Show("Không thành công !", "Thông báo", MessageBoxButtons.OK); } }
public void AddProc(TrinhDoHocVan trinhdohocvan) { SqlConnection conn = new SqlConnection("Server=.;Database=QuanLyNhanSu;Integrated Security=true"); try { conn.Open(); SqlCommand cmd = new SqlCommand("insert into TRINHDOHOCVAN(MaTDHV, TenTDHV, ChuyenNganhHoc) values (@MaTDHV, @TenTDHV, @ChuyenNganhHoc)", conn); cmd.Parameters.Add(new SqlParameter("@MaTDHV", SqlDbType.Char, 10)).Value = trinhdohocvan.MaTDHV; cmd.Parameters.Add(new SqlParameter("@TenTDHV", SqlDbType.Text)).Value = trinhdohocvan.TenTDHV; cmd.Parameters.Add(new SqlParameter("@ChuyenNganhHoc", SqlDbType.Text)).Value = trinhdohocvan.ChuyenNganhHoc; cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { conn.Close(); conn.Dispose(); } }
public int SuaTDHV(TrinhDoHocVan obj) { return(tdhvdal.SuaTDHV(obj)); }
public static int AddHocVan(TrinhDoHocVan hocVan) { return(Dao.AddHocVan(hocVan)); }
public int ThemTDHV(TrinhDoHocVan obj) { return(tdhvdal.ThemTDHV(obj)); }
public static int UpdateHocVan(TrinhDoHocVan hocVan) { return(Dao.UpdateHocVan(hocVan)); }