示例#1
0
 public bool UpdatePhong(PhongChieuDTO pc)
 {
     try
     {
         using (var context = new QLRPContext())
         {
             var phong = context.PhongChieus.SingleOrDefault(p => p.MaPhong == pc.MaPhong);
             if (phong != null)
             {
                 if (Utils.ValidateRowversion(phong.RowVersion, pc.RowVersion))
                 {
                     phong.TenPhong = pc.TenPhong;
                     phong.SoHang   = pc.SoHang;
                     phong.SoCot    = pc.SoCot;
                     phong.NguoiSua = CurrentUser.Username;
                     phong.NgaySua  = DateTime.Now;
                     context.SaveChanges();
                     return(true);
                 }
                 throw new Exception("Có ai đó đã update đối tượng này trước đó. Danh sách sẽ được load lại.");
             }
             throw new Exception("Phòng này đã bị xóa bởi ai đó. Danh sách sẽ được load lại.");
         }
     }
     catch (DbUpdateConcurrencyException)
     {
         throw new Exception("Hiện tại, có ai đó cũng đang update đối tượng này. Danh sách sẽ được load lại.");
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //bool flag_pc = false;
            PhongChieuBUS pcBUS = new PhongChieuBUS();
            PhongChieuDTO pc    = new PhongChieuDTO();

            pc.TenPhongChieu = tbTenPC.Text;
            pc.SoLuongGhe    = Convert.ToInt32(tbSoLuongCho.Text);
            pc.TinhTrang     = (tbTinhTrang.SelectedValue == "Hoạt động");

            pcBUS.ThemPhongChieu(pc);

            //if (flag_pc == false)
            //{
            //    string strBuilder = "<script language='javascript'>alert('" + "Ma Phong Chieu da ton tai" + "')</script>";
            //    Response.Write(strBuilder);
            //    tbMaPC.Text = "";
            //    tbSoLuongCho.Text = "";
            //    tbLoaiMC.Text = "";
            //    tbLoaiAT.Text = "";
            //    tbTinhTrang.Text = "";
            //    return;
            //}
            tbTenPC.Text      = "";
            tbSoLuongCho.Text = "";
            tbTinhTrang.Text  = "";
            string strBuilder = "<script language='javascript'>alert('" + "Thêm thành công" + "')</script>";

            Response.Write(strBuilder);
            FilGVDanhSachPhongChieu();
        }
示例#3
0
 public bool ThemPhong(PhongChieuDTO pc)
 {
     try
     {
         using (QLRPContext context = new QLRPContext())
         {
             context.PhongChieus.Add(new PhongChieu()
             {
                 MaPhong  = pc.MaPhong,
                 TenPhong = pc.TenPhong,
                 SoHang   = pc.SoHang,
                 SoCot    = pc.SoCot,
                 NguoiTao = CurrentUser.Username,
                 NgayTao  = DateTime.Now,
                 NgaySua  = DateTime.Now,
                 NguoiSua = CurrentUser.Username
             });
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public bool ThemPhongChieu(PhongChieuDTO pc)
        {
            //String test_mapc = string.Format("SELECT * FROM PhongChieu WHERE MaPhongChieu = '{0}'", pc.MaPhongChieu);
            //DataTable dt_mapc = DataProvider.ExecuteQuery(test_mapc);
            //if (dt_mapc.Rows.Count > 0)
            //    return false;
            String query = string.Format(@"INSERT INTO PhongChieu VALUES ('N{0}', {1},  '{2}')",
                                         pc.TenPhongChieu, pc.SoLuongGhe, pc.TinhTrang);

            DataProvider.ExecuteQuery(query);
            return(true);
        }
        public PhongChieuDTO LayThongTin(int mapc)
        {
            PhongChieuDTO phongChieuDTO = null;

            String    query = string.Format("SELECT * FROM PhongChieu WHERE MaPhongChieu = {0}", mapc);
            DataTable dt    = DataProvider.ExecuteQuery(query);

            foreach (DataRow dr in dt.Rows)
            {
                phongChieuDTO = new PhongChieuDTO();
                phongChieuDTO.MaPhongChieu  = Convert.ToInt32(dr["MaPhongChieu"]);
                phongChieuDTO.TenPhongChieu = dr["TenPhongChieu"].ToString();
                phongChieuDTO.SoLuongGhe    = Convert.ToInt32(dr["SoLuongGhe"]);
                phongChieuDTO.TinhTrang     = Convert.ToBoolean(dr["TinhTrang"]);
            }
            return(phongChieuDTO);
        }
        public List <PhongChieuDTO> LayDanhSach()
        {
            List <PhongChieuDTO> listPhongChieuDTO = new List <PhongChieuDTO>();

            String    query = "SELECT * FROM PhongChieu";
            DataTable dt    = DataProvider.ExecuteQuery(query);

            foreach (DataRow dr in dt.Rows)
            {
                PhongChieuDTO phongChieuDTO = new PhongChieuDTO();
                phongChieuDTO.MaPhongChieu  = Convert.ToInt32(dr["MaPhongChieu"]);
                phongChieuDTO.TenPhongChieu = dr["TenPhongChieu"].ToString();
                phongChieuDTO.SoLuongGhe    = Convert.ToInt32(dr["SoLuongGhe"]);
                phongChieuDTO.TinhTrang     = Convert.ToBoolean(dr["TinhTrang"]);
                listPhongChieuDTO.Add(phongChieuDTO);
            }
            return(listPhongChieuDTO);
        }
        private void dtgDSPC_MouseUp(object sender, MouseButtonEventArgs e)
        {
            int index = dtgDSPC.SelectedIndex;

            if (index >= 0) // tránh lỗi click vẫn trong datagrid nhưng mà click chỗ k có dòng nào
            {
                Selected = true;
                PhongChieuDTO nv = dtgDSPC.SelectedItem as PhongChieuDTO;
                txtMaPC.Text     = nv.MaPC;
                txtTenPC.Text    = nv.TenPC;
                txtSoCho.Text    = nv.SoCho.ToString();
                txtMayChieu.Text = nv.MayChieu;

                txtLoa.Text              = nv.Loa;
                txtDienTich.Text         = nv.DienTich.ToString();
                txtTinhTrang.Text        = nv.TinhTrang;
                txtTrangThietBiKhac.Text = nv.TrangThietBiKhac;
            }
        }
示例#8
0
        public static void Sua(PhongChieuDTO phongchieu)
        {
            // mở kết nối
            SqlConnection connection = SQLConnectionData.HamKetNoi();

            connection.Open();

            // tạo câu lệnh Sửa
            SqlCommand command = connection.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "EXEC SuaPhongChieu @MAPC,@TENPC,@SOCHO,@MAYCHIEU,@LOA,@DIENTICH,@TINHTRANG,@TRANGTHIETBIKHAC";

            command.Parameters.Add("@MAPC", SqlDbType.VarChar, 10);
            command.Parameters.Add("@TENPC", SqlDbType.NVarChar, 40);
            command.Parameters.Add("@SOCHO", SqlDbType.Int);
            command.Parameters.Add("@MAYCHIEU", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@LOA", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@DIENTICH", SqlDbType.Int);
            command.Parameters.Add("@TINHTRANG", SqlDbType.NVarChar, 20);
            command.Parameters.Add("@TRANGTHIETBIKHAC", SqlDbType.NVarChar, 100);


            // gán giá trị
            command.Parameters["@MAPC"].Value             = phongchieu.MaPC;
            command.Parameters["@TENPC"].Value            = phongchieu.TenPC;
            command.Parameters["@MAYCHIEU"].Value         = phongchieu.MayChieu;
            command.Parameters["@SOCHO"].Value            = phongchieu.SoCho;
            command.Parameters["@LOA"].Value              = phongchieu.Loa;
            command.Parameters["@DIENTICH"].Value         = phongchieu.DienTich;
            command.Parameters["@TINHTRANG"].Value        = phongchieu.TinhTrang;
            command.Parameters["@TRANGTHIETBIKHAC"].Value = phongchieu.TrangThietBiKhac;

            // thực hiện câu lệnh
            command.ExecuteNonQuery();

            // đóng kết nối
            connection.Close();
        }
示例#9
0
        public static void Them(PhongChieuDTO phongchieu)
        {
            // mở kết nối
            SqlConnection connection = SQLConnectionData.HamKetNoi();

            connection.Open();

            // tạo câu lệnh Thêm
            SqlCommand command = connection.CreateCommand();

            command.CommandType = CommandType.Text;
            //command.CommandText = "INSERT INTO NHANVIEN VALUES(@MAPC,@TENPC,@CHUCVU,@SDT,@GIOITINH,@NGAYSINH,@DIACHI,@LUONG,@NGAYVL)";
            command.CommandText = "EXEC ThemPhongChieu @MAPC,@TENPC,@SOCHO,@MAYCHIEU,@LOA,@DIENTICH,@TINHTRANG,@TRANGTHIETBIKHAC";

            command.Parameters.Add("@MAPC", SqlDbType.VarChar, 10);
            command.Parameters.Add("@TENPC", SqlDbType.NVarChar, 40);
            command.Parameters.Add("@SOCHO", SqlDbType.Int);
            command.Parameters.Add("@MAYCHIEU", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@LOA", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@DIENTICH", SqlDbType.Int);
            command.Parameters.Add("@TINHTRANG", SqlDbType.NVarChar, 20);
            command.Parameters.Add("@TRANGTHIETBIKHAC", SqlDbType.NVarChar, 100);


            // gán giá trị
            command.Parameters["@MAPC"].Value             = phongchieu.MaPC;
            command.Parameters["@TENPC"].Value            = phongchieu.TenPC;
            command.Parameters["@MAYCHIEU"].Value         = phongchieu.MayChieu;
            command.Parameters["@SOCHO"].Value            = phongchieu.SoCho;
            command.Parameters["@LOA"].Value              = phongchieu.Loa;
            command.Parameters["@DIENTICH"].Value         = phongchieu.DienTich;
            command.Parameters["@TINHTRANG"].Value        = phongchieu.TinhTrang;
            command.Parameters["@TRANGTHIETBIKHAC"].Value = phongchieu.TrangThietBiKhac;

            command.ExecuteNonQuery();

            // đóng kết nối
            connection.Close();
        }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String        MaVe          = Request.QueryString["id"];
            VeBUS         veBUS         = new VeBUS();
            SuatChieuBUS  suatChieuBUS  = new SuatChieuBUS();
            PhimBUS       phimBUS       = new PhimBUS();
            PhongChieuBUS phongChieuBUS = new PhongChieuBUS();

            VeDTO         veDTO         = veBUS.LayThongTin(Convert.ToInt32(MaVe));
            SuatChieuDTO  suatChieuDTO  = suatChieuBUS.LayThongTin(veDTO.MaSuatChieu);
            PhimDTO       phimDTO       = phimBUS.LayThongTin(suatChieuDTO.MaPhim);
            PhongChieuDTO phongChieuDTO = phongChieuBUS.LayThongTin(suatChieuDTO.MaPhongChieu);

            VeID.Text       += veDTO.MaVe.ToString();
            Phim.Text       += phimDTO.Ten;
            PhongChieu.Text += phongChieuDTO.TenPhongChieu;
            NgayChieu.Text  += suatChieuDTO.NgayChieu;
            SuatCHieu.Text  += suatChieuDTO.GioChieu;
            SoGhe.Text      += veDTO.Ghe;
            LoaiVe.Text     += (veDTO.LoaiVe) ? "VIP" : "Thường";
            GiaVe.Text      += veDTO.GiaVe.ToString() + " VNĐ";
        }
示例#11
0
        private void GhesDraw()
        {
            ghes       = datVeBLL.LayDSGhe(lichChieu.MaPhong);
            gheDaDat   = datVeBLL.LayVeDaDat(lichChieu.MaLichChieu);
            phongChieu = datVeBLL.LayKieuPhong(lichChieu.MaPhong);
            int r = phongChieu.SoHang;
            int c = phongChieu.SoCot;

            GhesPanel.RowStyles.Clear();
            GhesPanel.ColumnStyles.Clear();
            GhesPanel.ColumnCount = c;
            GhesPanel.RowCount    = r;
            for (int i = 0; i < c; i++)
            {
                GhesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 * 1f / c));
            }
            for (int i = 0; i < r; i++)
            {
                GhesPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 * 1f / r));
            }
            for (char i = 'A'; i < 'A' + r; i++)
            {
                for (int j = 1; j <= c; j++)
                {
                    Button b = new Button();
                    b.Text      = i + "" + j;
                    b.Dock      = DockStyle.Fill;
                    b.Margin    = new Padding(3, 3, 3, 3);
                    b.BackColor = Color.White;
                    if (gheDaDat.Contains(b.Text))
                    {
                        b.BackColor = Color.Red;
                    }
                    b.Click += new EventHandler(button_Click);
                    GhesPanel.Controls.Add(b);
                }
            }
        }
示例#12
0
 public static void Sua(PhongChieuDTO pc)
 {
     PhongChieuDAO.Sua(pc);
 }
示例#13
0
 public static void Them(PhongChieuDTO pc)
 {
     PhongChieuDAO.Them(pc);
 }
 public bool ThemPhongChieu(PhongChieuDTO pc)
 {
     return(phongChieuDAO.ThemPhongChieu(pc));
 }
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            bool TrungMaPC = false;

Nhaplai:
            string mapc = null;

            if (txtMaPC.Text.Length != 0)
            {
                mapc = txtMaPC.Text;
            }
            string tenpc = null;

            if (txtTenPC.Text.Length != 0)
            {
                tenpc = txtTenPC.Text;
            }

            string socho = null;

            if (txtSoCho.Text.Length != 0)

            {
                socho = txtSoCho.Text;
            }

            string maychieu = null;

            if (cbbMayChieu.Text.Length != 0)
            {
                maychieu = cbbMayChieu.Text;
            }
            string loa = null;

            if (cbbLoa.Text.Length != 0)
            {
                loa = cbbLoa.Text;
            }
            string dientich = null;

            if (txtDienTich.Text.Length != 0)
            {
                dientich = txtDienTich.Text;
            }
            string tinhtrang = null;

            if (txtTinhTrang.Text.Length != 0)
            {
                tinhtrang = txtTinhTrang.Text;
            }
            string trangthietbikhac = null;

            if (txtTrangThietBiKhac.Text.Length != 0)
            {
                trangthietbikhac = txtTrangThietBiKhac.Text;
            }


            PhongChieuDTO pc = new PhongChieuDTO(mapc, tenpc, Int32.Parse(socho), maychieu, loa, Int32.Parse(dientich), tinhtrang, trangthietbikhac);

            // báo lỗi nếu chưa nhập theo thứ tự trừ trên xuống , trái sang phải

            if (mapc == null)
            {
                if (TrungMaPC == false)
                {
                    MessageBox.Show("Chưa nhập mã phòng chiếu");
                    txtMaPC.Focus();
                }
                else
                {
                    MessageBox.Show("Mã phòng chiếu trùng");
                    txtMaPC.Focus();
                }
            }
            else if (tenpc == null)
            {
                MessageBox.Show("Chưa nhập tên phòng chiếu");
                txtTenPC.Focus();
            }
            else if (socho == null)
            {
                MessageBox.Show("Chưa nhập số chỗ");
                txtSoCho.Focus();
            }
            else if (maychieu == null)
            {
                MessageBox.Show("Chưa nhập máy chiếu");
                cbbMayChieu.Focus();
            }
            else if (loa == null)
            {
                MessageBox.Show("Chưa chọn loa");
                cbbLoa.Focus();
            }
            else if (dientich == null)
            {
                MessageBox.Show("Chưa nhập diện tích");
                txtDienTich.Focus();
            }

            else if (tinhtrang == null)
            {
                MessageBox.Show("Chưa nhập tình trạng");
                txtTinhTrang.Focus();
            }
            else if (trangthietbikhac == null)
            {
                MessageBox.Show("Chưa nhập trang thiết bị khác");
                txtTrangThietBiKhac.Focus();
            }
            else
            {
                try
                {
                    PhongChieuBUS.Them(pc);
                }
                catch
                {
                    txtMaPC.Clear();
                    TrungMaPC = true;
                    goto Nhaplai;
                }

                MessageBox.Show("Thêm phòng chiếu mới thành công", "Thông báo");
                this.Close();
            }
        }
        private void btnLuu_Sua_Click(object sender, RoutedEventArgs e)

        {
            bool TrungMaPC = false;

SuaLai:
            string mapc = null;

            if (txtMaPC.Text.Length != 0)
            {
                mapc = txtMaPC.Text;
            }
            string tenpc = null;

            if (txtTenPC.Text.Length != 0)
            {
                tenpc = txtTenPC.Text;
            }
            string socho = null;

            if (txtSoCho.Text.Length != 0)
            {
                socho = txtSoCho.Text;
            }
            string maychieu = null;

            if (txtMayChieu.Text.Length != 0)
            {
                maychieu = txtMayChieu.Text;
            }
            string loa = null;

            if (txtLoa.Text.Length != 0)
            {
                loa = txtLoa.Text;
            }
            string dientich = null;

            if (txtDienTich.Text.Length != 0)
            {
                dientich = txtDienTich.Text;
            }
            string tinhtrang = null;

            if (txtTinhTrang.Text.Length != 0)
            {
                tinhtrang = txtTinhTrang.Text;
            }
            string trangthietbikhac = null;

            if (txtTrangThietBiKhac.Text.Length != 0)
            {
                trangthietbikhac = txtTrangThietBiKhac.Text;
            }


            PhongChieuDTO nv = new PhongChieuDTO(mapc, tenpc, Int32.Parse(socho), maychieu, loa, Int32.Parse(dientich), tinhtrang, trangthietbikhac);


            if (mapc == null)
            {
                if (TrungMaPC == false)
                {
                    MessageBox.Show("Mã số phòng chiếu không được để trống");
                }
                else
                {
                    MessageBox.Show("Mã số phòng chiếu bị trùng");
                }
                txtMaPC.Focus();
            }
            else if (tenpc == null)
            {
                MessageBox.Show("Họ tên không được để trống");
                txtTenPC.Focus();
            }
            else if (socho == null)
            {
                MessageBox.Show("Số chỗ không được để trống");
                txtSoCho.Focus();
            }
            else if (maychieu == null)
            {
                MessageBox.Show("Máy chiếu không được để trống");
                txtMayChieu.Focus();
            }
            else if (loa == null)
            {
                MessageBox.Show("Loa không được để trống");
                txtLoa.Focus();
            }
            else if (dientich == null)
            {
                MessageBox.Show("Diện tích không được để trống");
                txtDienTich.Focus();
            }

            else if (tinhtrang == null)
            {
                MessageBox.Show("Tình trạng không được để trống");
                txtTinhTrang.Focus();
            }
            else if (trangthietbikhac == null)
            {
                MessageBox.Show("Trang thiết bị khác không được để trống");
                txtTrangThietBiKhac.Focus();
            }
            else
            {
                try
                {
                    PhongChieuBUS.Sua(nv);
                }
                catch
                {
                    txtMaPC.Clear();
                    TrungMaPC = true;
                    goto SuaLai;
                }
                MessageBox.Show("Sửa thông tin phòng chiếu  thành công", "Thông báo");

                DataTable dataTable = new DataTable();
                dataTable = PhongChieuBUS.LoadDSPC();
                Load_Data(dataTable);

                KhongChoNhap();
                btnLuu_Sua.Visibility = Visibility.Hidden;
                btnSua.Visibility     = Visibility.Visible;
                btnThem.IsEnabled     = btnXoa.IsEnabled = true;
                dtgDSPC.IsEnabled     = true;
                Selected = false;
            }
        }