コード例 #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});
            }
        }
コード例 #2
0
        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"));
        }
コード例 #4
0
        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));
 }
コード例 #6
0
        public IHttpActionResult GetLichSuGD(int id)
        {
            LichSuGD lichSuGD = db.LichSuGDs.Find(id);

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

            return(Ok(lichSuGD));
        }
コード例 #7
0
        public ActionResult Create(LichSuGD lichSuGD)
        {
            HttpResponseMessage response = client.PostAsJsonAsync(url + @"lichsugd/", lichSuGD).Result;

            response.EnsureSuccessStatusCode();
            if (response.IsSuccessStatusCode)
            {
                ViewBag.Detail = "Sucess";
            }
            return(RedirectToAction("Index"));
        }
コード例 #8
0
        // 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);
 }