Пример #1
0
        public ActionResult NapTien(string mang, string code)
        {
            var gv  = new GiangVienDAO().FindByTDN(User.Identity.Name);
            var dao = new LichSuGDDAO();

            if (!(((code.Length == 13 || code.Length == 15) && mang == "Viettel") || (code.Length == 12 && mang == "Mobifone") || ((code.Length == 12 || code.Length == 14) && mang == "Vinaphone")))
            {
                return(RedirectToAction("ThongBao", "Info", new { mes = "Mã thẻ cào không chính xác vui lòng thử lại.", type = 0 }));
            }
            try
            {
                var GD = new LichSuGD();
                GD.idVT        = gv.TaiKhoan.ViTiens.FirstOrDefault().iD;
                GD.LoaiGD      = 0; //0:nạp; 1:mơ
                GD.SoTienGD    = 100000;
                GD.ThoiGiangGD = DateTime.Now;
                string tien = String.Format("{0:#,##0}", GD.SoTienGD);
                GD.TenGD = tien + " VNĐ vào ví tiền bằng thẻ cào " + mang + ".";


                gv.TaiKhoan.ViTiens.FirstOrDefault().SoDu    += 100000;
                gv.TaiKhoan.ViTiens.FirstOrDefault().TongNap += 100000;
                dao.Insert(GD);
                var vt = new ViTienDAO().Update(gv.TaiKhoan.ViTiens.FirstOrDefault());
                TempData["testmsg"] = "Bạn đã nạp thành công " + tien + " VNĐ vào ví của mình.";
                //return RedirectToAction("ThongBao", "Info", new { mes = "Bạn đã nạp thành công " + tien + " VNĐ vào ví của mình." ,type=1});
                return(RedirectToAction("Index", "Info"));
            }
            catch (Exception ex)
            {
                TempData["testmsg"] = "Có lỗi trong quá trình nạp: " + ex.Message.ToString();
                return(RedirectToAction("Index", "Info"));
                //return RedirectToAction("ThongBao", "Info",new { mes= "Có lỗi trong quá trình nạp: " + ex.Message.ToString(), type=-1});
            }
        }
        public IHttpActionResult PutLichSuGD(int id, LichSuGD lichSuGD)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lichSuGD.MaGD)
            {
                return(BadRequest());
            }

            db.Entry(lichSuGD).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LichSuGDExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            LichSuGD lichsugd = db.DSLichSuGD.Find(id);

            db.DSLichSuGD.Remove(lichsugd);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(LichSuGD lichSuGD)
        {
            HttpResponseMessage response = client.PutAsJsonAsync(url + @"lichsugd/" + lichSuGD.MaGD, lichSuGD).Result;

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index"));
        }
Пример #5
0
 public ActionResult Edit([Bind(Include = "MaGD,MaKH,NgayGD,NgayHetHan,SoTien,NguoiThu")] LichSuGD lichsugd)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lichsugd).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaKH = new SelectList(db.DSKhachHang, "MaKH", "TenKH", lichsugd.MaKH);
     return(View(lichsugd));
 }
        public IHttpActionResult GetLichSuGD(int id)
        {
            LichSuGD lichSuGD = db.LichSuGDs.Find(id);

            if (lichSuGD == null)
            {
                return(NotFound());
            }

            return(Ok(lichSuGD));
        }
        public ActionResult Create(LichSuGD lichSuGD)
        {
            HttpResponseMessage response = client.PostAsJsonAsync(url + @"lichsugd/", lichSuGD).Result;

            response.EnsureSuccessStatusCode();
            if (response.IsSuccessStatusCode)
            {
                ViewBag.Detail = "Sucess";
            }
            return(RedirectToAction("Index"));
        }
        // GET: LichSuGD/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            LichSuGD            lichSuGD = null;
            HttpResponseMessage response = await client.GetAsync(url + @"lichsugd/" + id);

            if (response.IsSuccessStatusCode)
            {
                lichSuGD = await response.Content.ReadAsAsync <LichSuGD>();
            }
            return(View(lichSuGD));
        }
Пример #9
0
        public ActionResult ThanhToan(LichSuGD lsgd)
        {
            if (ModelState.IsValid)
            {
                db.DSLichSuGD.Add(lsgd);
                db.SaveChanges();
                return(RedirectToAction("details"));
            }

            return(View(lsgd));
        }
Пример #10
0
        public IHttpActionResult PostLichSuGD(LichSuGD lichSuGD)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LichSuGDs.Add(lichSuGD);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = lichSuGD.MaGD }, lichSuGD));
        }
Пример #11
0
        // GET: /History/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LichSuGD lichsugd = db.DSLichSuGD.Find(id);

            if (lichsugd == null)
            {
                return(HttpNotFound());
            }
            return(View(lichsugd));
        }
Пример #12
0
        public IHttpActionResult DeleteLichSuGD(int id)
        {
            LichSuGD lichSuGD = db.LichSuGDs.Find(id);

            if (lichSuGD == null)
            {
                return(NotFound());
            }

            db.LichSuGDs.Remove(lichSuGD);
            db.SaveChanges();

            return(Ok(lichSuGD));
        }
Пример #13
0
        public bool Update(LichSuGD entity)
        {
            try
            {
                var gd = db.LichSuGDs.Find(entity.iD);
                gd.TenGD = entity.TenGD;

                db.SaveChanges();
                return(true);
            }catch (Exception ex)
            {
                return(false);
            }
        }
Пример #14
0
        // GET: /History/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LichSuGD lichsugd = db.DSLichSuGD.Find(id);

            if (lichsugd == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaKH = new SelectList(db.DSKhachHang, "MaKH", "TenKH", lichsugd.MaKH);
            return(View(lichsugd));
        }
Пример #15
0
 // them data vao danh sach lich su giao dich
 public ActionResult UpdateHistory(int makh, DateTime ngaygd, DateTime ngayhethan, decimal sotien, string nguoithu, int thoihan, decimal cuocphi, decimal tiengiam, string note, bool paid)
 {
     if (ModelState.IsValid)
     {
         LichSuGD newls = new LichSuGD();
         newls.MaKH       = makh;
         newls.NgayGD     = ngaygd;
         newls.NgayHetHan = ngayhethan;
         newls.SoTien     = sotien;
         newls.NguoiThu   = User.Identity.GetUserId();
         newls.CuocPhi    = cuocphi;
         newls.ThoiHan    = thoihan;
         newls.TienGiam   = tiengiam;
         newls.Note       = note;
         newls.Paid       = paid;
         db.DSLichSuGD.Add(newls);
         db.SaveChanges();
         return(Json(true));
     }
     return(Json(false));
 }
Пример #16
0
 public int Insert(LichSuGD entity)
 {
     db.LichSuGDs.Add(entity);
     db.SaveChanges();
     return(entity.iD);
 }