//chinh sua DatCho public void CapNhatDatCho(DatCho datcho) { string query = ""; query = "Update [DatCho] " + "Set [DatCho].CMND = '" + datcho.CMND + "'," + "[DatCho].MaSuatChieu = " + datcho.MaSuatChieu + "," + "[DatCho].NgayDat = '" + datcho.NgayDat + "'," + "[DatCho].SoDienThoai = '" + datcho.SoDienThoai + "'," + "[DatCho].CacSoGhe = '" + datcho.CacSoGhe + "'," + "[DatCho].SoLuongCho = " + datcho.SoLuongCho + ", " + "[DatCho].MaTrangThai = " + datcho.MaTrangThai + " Where [DatCho].MaDatCho = " + datcho.MaDatCho; try { this.editRow(query); } catch (OracleException ex) { throw ex; } }
//them DatCho moi public void ThemDatCho(DatCho datcho) { string query = ""; query = "Insert into DatCho (CMND, MaSuatChieu, NgayDat, SoDienThoai, " + "CacSoGhe, SoLuongCho, MaTrangThai) " + "values ('" + datcho.CMND + "'," + datcho.MaSuatChieu + ",'" + datcho.NgayDat.ToShortDateString() + "','" + datcho.SoDienThoai + "','" + datcho.CacSoGhe + "'," + datcho.SoLuongCho + "," + datcho.MaTrangThai + ")"; try { this.addRow(query); } catch (OracleException ex) { throw ex; } }
//tim Dat Cho theo so CMND public DatCho TimDatCho(int cmnd, int soDienThoai) { DataTable data = new DataTable(); DatCho datcho = new DatCho(); string query = ""; if (cmnd > 0) { query = "select [DatCho].* " + "from [DatCho] " + " where [DatCho].MaSuatChieu = " + cmnd + " or [DatCho].MaTrangThai = " + soDienThoai; try { data = this.getRows(query); if (data.Rows.Count > 0) { DataRow row = data.Rows[0]; datcho.MaDatCho = (int)row[0]; datcho.CMND = row[1].ToString(); datcho.MaSuatChieu = (int)row[2]; datcho.NgayDat = (DateTime)row[3]; datcho.SoDienThoai = row[4].ToString(); datcho.CacSoGhe = row[5].ToString(); datcho.SoLuongCho = (int)row[6]; datcho.MaTrangThai = (int)row[7]; } else { datcho = null; } } catch (OracleException ex) { throw ex; } } else { datcho = null; } return datcho; }
private void PutDatChoData(DatCho datcho) { datcho.CMND = txtCMND.Text; datcho.MaSuatChieu = maSuatChieu; datcho.NgayDat = dtpNgayDatCho.Value; datcho.SoDienThoai = txtDienThoai.Text; datcho.CacSoGhe = txtCacSoGhe.Text; datcho.SoLuongCho = Convert.ToInt16(txtSoLuongCho.Text); datcho.MaTrangThai = (int)cboTrangThaiDatCho.SelectedValue; }
private void HienThiDatCho(DatCho datcho) { if (datcho!=null) { txtCMND.Text = datcho.CMND; txtDienThoai.Text = datcho.SoDienThoai; txtCacSoGhe.Text = datcho.CacSoGhe; txtSoLuongCho.Text = datcho.SoLuongCho.ToString(); dtpNgayDatCho.Text = datcho.NgayDat.ToString(); int matrangthai = 0; matrangthai = datcho.MaTrangThai; cboTrangThaiDatCho.SelectedValue = matrangthai; maSuatChieu = datcho.MaSuatChieu; SuatChieuDB suatchieuDB = new SuatChieuDB(); txtSuatChieu.Text = suatchieuDB.TinSuatChieu(maSuatChieu); DanhSachVePhim(txtCacSoGhe.Text); } else { MessageBox.Show("Ko co Ma DatCho nay!"); } }
private void btnTimDatCho_Click(object sender, EventArgs e) { //tim DatCho theo MaDatCho if (txtMaDatCho.Text!="") { int maDatCho = Convert.ToInt32(txtMaDatCho.Text); datcho = new DatCho(); datcho = datchoDB.TimDatCho(maDatCho); HienThiDatCho(datcho); } else { MessageBox.Show("Phap nhap Ma DatCho"); } //tim DatCho theo so CMND hoac DienThoai }
private void btnLuu_Click(object sender, EventArgs e) { if (themDatCho==true) { datcho = new DatCho(); try { PutDatChoData(datcho); datchoDB.ThemDatCho(datcho); MessageBox.Show("DatCho moi thanh cong!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (themDatCho==false) { DatCho newDatCho = new DatCho(); newDatCho.MaDatCho = datcho.MaDatCho; try { this.PutDatChoData(newDatCho); datchoDB.CapNhatDatCho(newDatCho); MessageBox.Show("DatCho cap nhat thanh cong!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.EnabledControlNhap(true); this.EnabledButton(true); groupVePhim.Enabled = false; //EmptyControl(); HienThiFormSoGhe(maSuatChieu); }