public bool InsertTONGIAO(TONGIAO_DTO tongiao) { string query = "INSERT INTO dbo.TONGIAO(MaTG,TenTG,GhiChu) " + "VALUES(N'" + tongiao.MaTG + "',N'" + tongiao.TenTG + "',N'" + tongiao.GhiChu + "') "; int result = DataProvider.Instance.ExecuteNonQuery(query); return(result > 0); }
public List <TONGIAO_DTO> LoadListTONGIAO() { List <TONGIAO_DTO> TonGiao = new List <TONGIAO_DTO>(); string query = "SELECT * FROM dbo.TONGIAO "; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { TONGIAO_DTO tongiao = new TONGIAO_DTO(item); TonGiao.Add(tongiao); } return(TonGiao); }
private void Btthem_Click(object sender, EventArgs e) { string matongiao = txtMaTonGiao.TextName; string tentongiao = txtTenTonGiao.TextName; string ghichu = txtGhiChu.TextName; TONGIAO_DTO tongiao = new TONGIAO_DTO(matongiao, tentongiao, ghichu); bool isExist = TONGIAO_DAL.Instance.checkIsExist(tongiao.MaTG); if (isExist) { MessageBox.Show("Mã Đã Tồn Tại, Thêm thất bại"); } else { TONGIAO_DAL.Instance.InsertTONGIAO(tongiao); MessageBox.Show("Thêm thành công" + ""); } }