예제 #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (btnThem.Text == "Thêm")
            {
                UnlockControl();
                EmptyControl();
                btnThem.Text   = "Lưu";
                btnSua.Enabled = false;
                btnXoa.Text    = "Hủy";
            }
            else
            {
                PhongChieu item = new PhongChieu();
                item.TenPhongChieu = txbTen.Text;
                item.ViTri         = txbViTri.Text;
                item.TongSoGhe     = Convert.ToInt32(txbSoGhe.Text);

                if (new PhongChieuDAO().AddPhongChieu(item))
                {
                    MessageBox.Show("Thêm thành công");
                }
                else
                {
                    MessageBox.Show("Không thành công");
                }
                LockControl();
                loadPhongChieu();
            }
        }
예제 #2
0
 public bool AddPhongChieu(PhongChieu item)
 {
     try
     {
         db.PhongChieux.Add(item);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #3
0
        // GET: Admin/PhongChieux/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PhongChieu phongChieu = db.Database.SqlQuery <PhongChieu>("exec sp_loadChiTietPhongChieu {0}", id).First <PhongChieu>();

            if (phongChieu == null)
            {
                return(HttpNotFound());
            }
            return(View(phongChieu));
        }
예제 #4
0
        public bool EditPhongChieu(PhongChieu item)
        {
            try
            {
                PhongChieu temp = db.PhongChieux.Find(item.ID);
                temp.TenPhongChieu = item.TenPhongChieu;
                temp.ViTri         = item.ViTri;
                temp.TongSoGhe     = item.TongSoGhe;

                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #5
0
        public ActionResult Edit([Bind(Include = "maphong,tenphong,soghebandau")] PhongChieu phongChieu)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //db.Entry(phongChieu).State = EntityState.Modified;
                    db.Database.SqlQuery <PhongChieu>("exec sp_editPhongChieu {0},{1},{2}", phongChieu.maphong, phongChieu.tenphong, phongChieu.soghebandau).ToList();
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (EntityCommandExecutionException ex)
            {
                return(RedirectToAction("Index"));
            }

            return(View(phongChieu));
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "maphong,tenphong,soghebandau")] PhongChieu phongChieu)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //db.PhongChieux.Add(phongChieu);
                    db.Database.SqlQuery <PhongChieu>("exec sp_addPhongChieu {0}", phongChieu.tenphong).ToList();
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (EntityCommandExecutionException ex)
            {
                return(RedirectToAction("Index"));
            }

            return(View(phongChieu));
        }