public bool ThemTinNhanQC(TinNhanQC pTinNhanQC) { string query = "INSERT INTO dbo.TINNHAN_QUANGCAO " + "(NOIDUNG, NGUOIGUI, NGAYGUI, NGUOINHAN) " + "VALUES (@noidung, @nguoigui, @ngaygui, @nguoinhan) "; SqlConnection conn = DBUtils.GetDBConnection(); try { conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.Add("@noidung", SqlDbType.Text).Value = pTinNhanQC.NoiDung; cmd.Parameters.Add("@nguoigui", SqlDbType.Int).Value = pTinNhanQC.NguoiGui; cmd.Parameters.Add("@ngaygui", SqlDbType.Date).Value = pTinNhanQC.NgayGui; cmd.Parameters.Add("@nguoinhan", SqlDbType.Int).Value = pTinNhanQC.NguoiNhan; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch { return(false); } }
private void btnGuiTin_Click(object sender, EventArgs e) { DateTime curDate = DateTime.Today; TinNhanQC tinnhanqc = new TinNhanQC(txtNoiDungTN.Text, Int32.Parse(txtMANV.Text), curDate.Date, Id); if (bus_nhantinqc.ThemTinNhanQC(tinnhanqc)) { HienThiTinNhan(); } else { MessageBox.Show("Đã xảy ra lỗi!"); } }
public bool ThemTinNhanQC(TinNhanQC pTinNhanQC) { return(dal_quanlyquangcao.ThemTinNhanQC(pTinNhanQC)); }