private void btnThem_Click(object sender, EventArgs e) { if (txtTenHangVe.Text.Trim() != "") { try { dtoHangVe = new DTO_HangVe(txtMaHangVe.Text, txtTenHangVe.Text); if (busHangVe.Add(dtoHangVe)) { MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception a) { MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { TaoLai(); } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool Update(DTO_HangVe dto) { try { _con.Open(); string sqlQuery = string.Format("UPDATE HANGVE SET TENHANGVE=N'{0}' WHERE MAHANGVE='{1}'", dto.TenHangVe, dto.MaHangVe); SqlCommand cmd = new SqlCommand(sqlQuery, _con); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception a) { } finally { _con.Close(); } return(false); }
public bool Add(DTO_HangVe dto) { try { _con.Open(); string maHangVe = TaoMaHangVe(); string sqlQuery = string.Format("INSERT INTO HANGVE(MAHANGVE, TENHANGVE) VALUES('{0}', N'{1}')", maHangVe, dto.TenHangVe); SqlCommand cmd = new SqlCommand(sqlQuery, _con); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception a) { } finally { _con.Close(); } return(false); }
public bool Update(DTO_HangVe dto) { return(dal.Update(dto)); }
public bool Add(DTO_HangVe dto) { return(dal.Add(dto)); }