private void btnLuu_Click(object sender, EventArgs e) { phimcr = new PhimChieuRap(); PhimDB phimDB = new PhimDB(); Phim phim = new Phim(); DataRow row; try { for (int i = 0; i < listPhimChon.Items.Count; i++) { row = (listPhimChon.Items[i] as DataRowView).Row; phimcr.MaRap = (int)cboRapChieu.SelectedValue; //MessageBox.Show(row.Field<string>("MaPhim")); phimcr.MaPhim = Convert.ToInt16(row.Field<string>("MaPhim")); phim = phimDB.ThongTinPhim(phimcr.MaPhim); phimcr.NgayCongChieu = phim.NgayCongChieu; phimcr.NgayKetThuc = phim.NgayKetThuc; phimcrDB.ThemPhimChieuRap(phimcr); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } EmptyControl(); this.EnabledControl(true); }
public void ThemPhimChieuRap(PhimChieuRap phimchieurap) { string query = ""; query = "Insert into PhimChieuRap (MaRap, MaPhim, NgayCongChieu, NgayKetThuc) " + "values (" + phimchieurap.MaRap + "," + phimchieurap.MaPhim + ",'" + phimchieurap.NgayCongChieu + "','" + phimchieurap.NgayKetThuc + "')" ; try { this.addRow(query); } catch (OracleException ex) { throw ex; } }
//thong tin public PhimChieuRap ThongTinPhimChieuRap(int maRap, int maPhim) { PhimChieuRap phimchieurap = new PhimChieuRap(); DataTable data = new DataTable(); string query = ""; if (maRap >= 0) { query = "select [PhimChieuRap].* " + " from [PhimChieuRap] " + "where [PhimChieuRap].MaRap = " + maRap + " and [PhimChieuRap].MaPhim = " + maPhim; try { data = this.getRows(query); if (data.Rows.Count > 0) { DataRow row = data.Rows[0]; phimchieurap.MaRap = (int)row[0]; phimchieurap.MaPhim = (int)row[1]; phimchieurap.NgayCongChieu = (DateTime)row[2]; phimchieurap.NgayKetThuc = (DateTime)row[3]; return phimchieurap; } else { return phimchieurap; } } catch (OracleException ex) { throw ex; } } else { return phimchieurap; } }
private void btnXoa_Click(object sender, EventArgs e) { int maRap = (int)cboRapChieu.SelectedValue; int maPhim = Convert.ToInt16(listPhimChon.SelectedValue); phimcr = phimcrDB.ThongTinPhimChieuRap(maRap,maPhim); //lay ten rap RapChieuDB rapchieuDB = new RapChieuDB(); RapChieu rapchieu = rapchieuDB.ThongTinRapChieu(phimcr.MaRap); //lay ten phim PhimDB phimDB = new PhimDB(); Phim phim = phimDB.ThongTinPhim(phimcr.MaPhim); string thongbao = "Ban co chac chan muon xoa Phim: " + phim.TuaDePhim + " chieu Rap: " + rapchieu.TenRap; DialogResult button = MessageBox.Show(thongbao, "Xac nhan xoa", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { phimcrDB.XoaPhimChieuRap(phimcr); } EmptyControl(); }
//public void CapNhatPhimChieuRap(PhimChieuRap phimchieurap) //{ // string query = ""; // query = "Update [PhimChieuRap] " + // "Set [PhimChieuRap].MaRap = " + phimchieurap.MaRap+ "'," + // "[PhimChieuRap].MaPhim = " + phimchieurap.MaPhim + // " Where [PhimChieuRap].MaRap = " + phimchieurap.MaRap ; // try // { // this.editRow(query); // } // catch (OracleException ex) // { // throw ex; // } //} ///xoa public void XoaPhimChieuRap(PhimChieuRap phimchieurap) { string query = ""; if (phimchieurap.MaRap > 0 && phimchieurap.MaPhim>0) { query = "Delete [PhimChieuRap] "+ " where [PhimChieuRap].MaRap = " + phimchieurap.MaRap + " and [PhimChieuRap].MaPhim = " + phimchieurap.MaPhim; try { this.deleteRow(query); } catch (OracleException ex) { throw ex; } } }