private void btnXoaHV_Click(object sender, EventArgs e) { if (flagHangVeCellClick) { try { DTO_TinhTrangVe dtoTinhTrangVe = new DTO_TinhTrangVe(txtMaChuyenBay.Text, cboMaHangVe.SelectedValue.ToString(), Convert.ToInt32(txtTongSoGhe.Text), Convert.ToInt32(txtTongSoGhe.Text)); if (busTinhTrangVe.Delete(dtoTinhTrangVe)) { MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Xóa không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception a) { MessageBox.Show("Xóa không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { TaoLaiHangVe(); } } else { MessageBox.Show("Vui lòng chọn một hàng trong danh sách!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnThemHV_Click(object sender, EventArgs e) { if (cboMaHangVe.Text != "" && txtTongSoGhe.Text != "") { try { dtoTinhTrangVe = new DTO_TinhTrangVe(txtMaChuyenBay.Text, cboMaHangVe.SelectedValue.ToString(), Convert.ToInt32(txtTongSoGhe.Text), Convert.ToInt32(txtTongSoGhe.Text)); if (busTinhTrangVe.Add(dtoTinhTrangVe)) { 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 { TaoLaiHangVe(); } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool Delete(DTO_TinhTrangVe dto) { try { _con.Open(); string sqlQuery = string.Format("DELETE FROM TINHTRANGVE WHERE MACHUYENBAY='{0}' AND MAHANGVE='{1}'", dto.MaChuyenBay, dto.MaHangVe); SqlCommand cmd = new SqlCommand(sqlQuery, _con); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception a) { } finally { _con.Close(); } return(false); }
public bool Update(DTO_TinhTrangVe dto) { try { _con.Open(); string sqlQuery = string.Format("UPDATE TINHTRANGVE SET TONGSOGHE='{0}' WHERE MACHUYENBAY='{1}' AND MAHANGVE='{2}'", dto.TongSoGhe, dto.MaChuyenBay, 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_TinhTrangVe dto) { try { _con.Open(); string sqlQuery = string.Format("INSERT INTO TINHTRANGVE(MACHUYENBAY, MAHANGVE, TONGSOGHE, SOGHETRONG) VALUES('{0}', '{1}', '{2}', '{3}')", dto.MaChuyenBay, dto.MaHangVe, dto.TongSoGhe, dto.TongSoGhe); SqlCommand cmd = new SqlCommand(sqlQuery, _con); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception a) { } finally { _con.Close(); } return(false); }
public bool Delete(DTO_TinhTrangVe dto) { return(dal.Delete(dto)); }
public bool Update(DTO_TinhTrangVe dto) { return(dal.Update(dto)); }
public bool Add(DTO_TinhTrangVe dto) { return(dal.Add(dto)); }