コード例 #1
0
        public List <KHUYEN_MAI> getAllKhuyenMai1(int id)
        {
            connectdb = new ConnectDb();
            List <KHUYEN_MAI> list = new List <KHUYEN_MAI>();

            SqlCommand cmd = new SqlCommand("getAllKhuyenMai", connectdb.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            sdr             = cmd.ExecuteReader();
            while (sdr.Read())
            {
                KHUYEN_MAI item_khuyenmai = new KHUYEN_MAI();
                if (id == (int)sdr["MAKHUYENMAI"])
                {
                    item_khuyenmai.MAKHUYENMAI      = (int)sdr["MAKHUYENMAI"];
                    item_khuyenmai.TIEUDEKHUYENMAI  = (string)sdr["TIEUDEKHUYENMAI"];
                    item_khuyenmai.NOIDUNGKHUYENMAI = (string)sdr["NOIDUNGKHUYENMAI"];
                    item_khuyenmai.URLANH           = (string)sdr["URLANH"];
                    item_khuyenmai.THOIGIANTAO      = (DateTime)sdr["THOIGIANTAO"];
                    item_khuyenmai.NGUOITAO         = (string)sdr["NGUOITAO"];

                    list.Add(item_khuyenmai);
                }
            }
            return(list);
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            KHUYEN_MAI kHUYEN_MAI = db.KHUYEN_MAI.Find(id);

            db.KHUYEN_MAI.Remove(kHUYEN_MAI);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "MA_KM,TEN_KM,SO_MON_DK,TIEN_GIAM")] KHUYEN_MAI kHUYEN_MAI)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kHUYEN_MAI).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kHUYEN_MAI));
 }
コード例 #4
0
        public ActionResult Create(FormCollection f)
        {
            KHUYEN_MAI km = new KHUYEN_MAI();

            km.MA_KM     = Guid.NewGuid();
            km.TEN_KM    = f["name"];
            km.SO_MON_DK = int.Parse(f["somon"]);
            km.TIEN_GIAM = int.Parse(f["phantramgiam"]);
            db.KHUYEN_MAI.Add(km);
            db.SaveChanges();
            return(View());
        }
コード例 #5
0
        // GET: Admin/KHUYEN_MAI/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KHUYEN_MAI kHUYEN_MAI = db.KHUYEN_MAI.Find(id);

            if (kHUYEN_MAI == null)
            {
                return(HttpNotFound());
            }
            return(View(kHUYEN_MAI));
        }