private void btnLuu_Click(object sender, EventArgs e) { lockControl(); SoQDKhenThuongKyLuat soQDKTKL = new SoQDKhenThuongKyLuat(txtSoQDKhenThuongKyLuat.Text, txtSoQDKhenThuongKyLuat.Text, txtHinhThuc.Text); if (kt == true) { if (txtSoQDKhenThuongKyLuat.Text == null) { MessageBox.Show("Bạn chưa điền đủ thông tin!"); } else { try { addSoQDKTKL.AddProc(soQDKTKL); MessageBox.Show("Lưu Thông tin Thành công!"); } catch (Exception a) { new Exception("Error: " + a.Message); MessageBox.Show("Thêm thông tin không thành công!", "ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { SoQDKTKL_Controller soQDKTKL_Controller = new SoQDKTKL_Controller(); soQDKTKL_Controller.EditSQDKTKL(soQDKTKL); } loadList(); }
public void ExcuteProc(SoQDKhenThuongKyLuat soQDKhenThuongKyLuat) { //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("EditSoQuyetDinhKhenThuongKyLuat", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@soQuyetDinhCu", SqlDbType.Char, 10)).Value = this.soQuyetDinhCu; cmd.Parameters.Add(new SqlParameter("@soQuyetDinh", SqlDbType.Char, 10)).Value = soQDKhenThuongKyLuat.SoQD; cmd.Parameters.Add(new SqlParameter("@lyDo", SqlDbType.Text)).Value = soQDKhenThuongKyLuat.LyDo; cmd.Parameters.Add(new SqlParameter("@hinhThuc", SqlDbType.Text)).Value = soQDKhenThuongKyLuat.HinhThuc; //excute proc cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { conn.Close(); conn.Dispose(); } }
public void EditSQDKTKL(SoQDKhenThuongKyLuat soQDKhenThuongKyLuat) { try { openConnection(); string query = "update SOQUYETDINHKHENTHUONG_KYLUAT set LyDo = @lydo, HinhThuc = @hinhthuc where SoQD = @soqd"; SqlCommand cmd = new SqlCommand(query, Conn); cmd.Parameters.AddWithValue("@hinhthuc", soQDKhenThuongKyLuat.HinhThuc); cmd.Parameters.AddWithValue("@lydo", soQDKhenThuongKyLuat.LyDo); cmd.Parameters.AddWithValue("@soqd", soQDKhenThuongKyLuat.SoQD); cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { closeConnection(); } }
public void AddProc(SoQDKhenThuongKyLuat soQDKTKL) { SqlConnection conn = new SqlConnection("Server=.;Database=QuanLyNhanSu;Integrated Security=true"); try { conn.Open(); SqlCommand cmd = new SqlCommand("insert into SOQUYETDINHKHENTHUONG_KYLUAT(SoQD, LyDo, HinhThuc) values (@SoQD, @LyDo, @HinhThuc)", conn); cmd.Parameters.Add(new SqlParameter("@SoQD", SqlDbType.Char, 10)).Value = soQDKTKL.SoQD; cmd.Parameters.Add(new SqlParameter("@LyDo", SqlDbType.Text)).Value = soQDKTKL.LyDo; cmd.Parameters.Add(new SqlParameter("@HinhThuc", SqlDbType.Text)).Value = soQDKTKL.HinhThuc; cmd.ExecuteNonQuery(); } catch (Exception e) { throw; } finally { conn.Close(); conn.Dispose(); } }
public void AddProc(SoQDKhenThuongKyLuat soqdktkl)