public void ThemSuatChieu(SuatChieu suatchieu)
 {
     string query = "";
     query = "Insert into SuatChieu (NgayChieu, GioChieu, PhongChieu, MaRap, MaPhim) " +
              "values ('"+  suatchieu.NgayChieu + "','" + suatchieu.GioChieu + "'," +
                            suatchieu.PhongChieu + "," + suatchieu.MaRap + "," + suatchieu.MaPhim + ")" ;
     try
     {
         this.addRow(query);
     }
     catch (OracleException ex)
     {
         throw ex;
     }
 }
 //thong tin
 public SuatChieu ThongTinSuatChieu(int maSuatChieu)
 {
     SuatChieu suatchieu = new SuatChieu();
     DataTable data = new DataTable();
     string query = "";
     if (maSuatChieu >= 0)
     {
         query = @"select [SuatChieu].*
                   from [SuatChieu]
                   where [SuatChieu].MaSuatChieu = " + maSuatChieu;
         try
         {
             data = this.getRows(query);
             if (data.Rows.Count>0)
             {
                 DataRow row = data.Rows[0];
                 suatchieu.MaSuatChieu = (int)row[0];
                 suatchieu.NgayChieu = (DateTime)row[1];
                 suatchieu.GioChieu = (int)row[2];
                 suatchieu.PhongChieu = (int)row[3];
                 suatchieu.MaRap = (int)row[4];
                 suatchieu.MaPhim = (int)row[5];
                 return suatchieu;
             }
             else
             {
                 return suatchieu;
             }
         }
         catch (OracleException ex)
         {
             throw ex;
         }
     }
     else
     {
         return suatchieu;
     }
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (themmoi)
     {
         suatchieu = new SuatChieu();
         try
         {
             PutSuatChieuData(suatchieu);
             suatchieuDB.ThemSuatChieu(suatchieu);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         //SuatChieu newSuatChieu = new SuatChieu();
         //newSuatChieu.MaSuatChieu = suatchieu.MaSuatChieu;
         //try
         //{
         //    this.PutSuatChieuData(newSuatChieu);
         //    suatchieuDB.CapNhatSuatChieu(newSuatChieu);
         //}
         //catch (Exception ex)
         //{
         //    MessageBox.Show(ex.Message);
         //}
     }
     DanhSachSuatChieu();
     //this.EnabledControl(false);
     this.EnabledButton(true);
 }
        private void PutSuatChieuData(SuatChieu suatchieu)
        {
            int phongChieu=0;
            int gioChieu=0;
            int maPhim=0;
            this.thongtinLichChieu(ref phongChieu, ref gioChieu, ref maPhim);

            suatchieu.NgayChieu = dtpNgayChieu.Value;
            suatchieu.MaRap = (int)cboRapChieu.SelectedValue;

            suatchieu.PhongChieu = phongChieu;
            suatchieu.GioChieu = gioChieu;
            suatchieu.MaPhim = maPhim;
        }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     MessageBox.Show(maSuatChieu.ToString());
     suatchieu = suatchieuDB.ThongTinSuatChieu(maSuatChieu);
     string thongbao = "Bạn có chắc muốn xóa Suất chiếu vào " + tinSuatChieu;
     DialogResult button = MessageBox.Show(thongbao, "Xac nhan xoa", MessageBoxButtons.YesNo);
     if (button == DialogResult.Yes)
     {
         suatchieuDB.XoaSuatChieu(suatchieu);
         DanhSachSuatChieu();
     }
     //this.EnabledControl(false);
 }
 //public void CapNhatSuatChieu(SuatChieu suatchieu)
 //{
 //    string query = "";
 //    query = "Update [SuatChieu] " +
 //            "Set [SuatChieu].NgayChieu = '" + suatchieu.NgayChieu + "'," +
 //                "[SuatChieu].GioChieu = '" + suatchieu.GioChieu + "'," +
 //                "[SuatChieu].PhongChieu = " + suatchieu.PhongChieu + "," +
 //                "[SuatChieu].MaRap = " + suatchieu.MaRap + "," +
 //                "[SuatChieu].MaPhim = " + suatchieu.MaPhim + "" +
 //           " Where [SuatChieu].MaSuatChieu = " + suatchieu.MaSuatChieu ;
 //    try
 //    {
 //        this.editRow(query);
 //    }
 //    catch (OracleException ex)
 //    {
 //        throw ex;
 //    }
 //}
 ///xoa 
 public void XoaSuatChieu(SuatChieu suatchieu)
 {
     string query = "";
     if (suatchieu.MaSuatChieu > 0)
     {
         query = "Delete [SuatChieu] "+
                 " where [SuatChieu].MaSuatChieu = " + suatchieu.MaSuatChieu;
         try
         {
             this.deleteRow(query);
         }
         catch (OracleException ex)
         {
             throw ex;
         }
     }
 }
        public string TinSuatChieu(int maSuatChieu)
        {
            SuatChieu suatchieu = new SuatChieu();
            DataTable data = new DataTable();
            string tinSuatChieu = "";
            string query = "";
            if (maSuatChieu >= 0)
            {
                query = "select [SuatChieu].MaSuatChieu, [SuatChieu].NgayChieu, [SuatChieu].GioChieu, " +
                            "[SuatChieu].PhongChieu, [SuatChieu].MaRap, [SuatChieu].MaPhim, " +
                            "[RapChieu].TenRap, [Phim].TuaDePhim " +
                        "from ([RapChieu] join [SuatChieu] on [RapChieu].MaRap = [SuatChieu].MaRap) " +
                                             " join [Phim] on [SuatChieu].MaPhim = [Phim].MaPhim " +
                          "where [SuatChieu].MaSuatChieu = " + maSuatChieu;
                try
                {
                    data = this.getRows(query);
                    if (data.Rows.Count > 0)
                    {
                        DataRow row = data.Rows[0];

                        tinSuatChieu = "NgayChieu: " + (DateTime)row[1] +
                                        "\n GioChieu: " + (int)row[2] +
                                        "\n PhongChieu: " + (int)row[3] +
                                        "\n TenRap: " + row[6].ToString() +
                                        "\n TenPhim: " + row[7].ToString();
                        return tinSuatChieu;
                    }
                    else
                    {
                        return tinSuatChieu;
                    }
                }
                catch (OracleException ex)
                {
                    throw ex;
                }
            }
            else
            {
                return tinSuatChieu;
            }
        }
Exemplo n.º 8
0
 //ngay chieu phim cua Suat chieu
 private DateTime NgayChieuPhim(int pMaSuatChieu)
 {
     DateTime ngay;
     SuatChieu sc = new SuatChieu();
     SuatChieuDB scDB = new SuatChieuDB();
     sc = scDB.ThongTinSuatChieu(pMaSuatChieu);
     ngay = sc.NgayChieu;
     return ngay;
 }