public ActionResult Create([Bind(Include = "IDSIM,SoDienThoai,NgayDangKy,NgayHetHan,Flag,MaKH")] ThongTinSIM thongTinSIM)
        {
            if (ModelState.IsValid)
            {
                db.ThongTinSIMs.Add(thongTinSIM);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKH = new SelectList(db.KhachHangs, "MaKH", "TenKH", thongTinSIM.MaKH);
            return(View(thongTinSIM));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "MaHDTC,IDSIM,TuNgay,DenNgay,PhiHangThang,TongTien,NgayXuat,ThanhToan,Flag")] HoaDonTinhCuoc hoaDonTinhCuoc)
        {
            if (ModelState.IsValid)
            {
                db.HoaDonTinhCuocs.Add(hoaDonTinhCuoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IDSIM = new SelectList(db.ThongTinSIMs, "IDSIM", "SoDienThoai", hoaDonTinhCuoc.IDSIM);
            return(View(hoaDonTinhCuoc));
        }
        public ActionResult Create([Bind(Include = "ID,IDSIM,TGBD,TGKT,SoPhutSD7h23h,SoPhutSD23h7h")] ChiTietSuDung chiTietSuDung)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietSuDungs.Add(chiTietSuDung);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IDSIM = new SelectList(db.ThongTinSIMs, "IDSIM", "SoDienThoai", chiTietSuDung.IDSIM);
            return(View(chiTietSuDung));
        }
예제 #4
0
 public bool ThemThongTinSim(ThongTinSIM thongtin)
 {
     try
     {
         ThongTinSIM sim = new ThongTinSIM();
         sim.IDSIM       = thongtin.IDSIM;
         sim.SoDienThoai = thongtin.SoDienThoai;
         sim.NgayDangKy  = thongtin.NgayDangKy;
         sim.NgayHetHan  = thongtin.NgayHetHan;
         sim.MaKH        = thongtin.MaKH;
         db.ThongTinSIMs.Add(sim);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #5
0
 public bool ThemHoaDon(HoaDonDangKy hoadon)
 {
     try
     {
         HoaDonDangKy hd  = new HoaDonDangKy();
         ThongTinSIM  sim = db.ThongTinSIMs.Find(hoadon.IDSIM);
         hd.MaHDDK       = hoadon.MaHDDK;
         hd.IDSIM        = hoadon.IDSIM;
         hd.NgayDangKy   = hoadon.NgayDangKy;
         hd.ChiPhiDangKy = hoadon.ChiPhiDangKy;
         sim.Flag        = true;
         db.HoaDonDangKies.Add(hd);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #6
0
 public bool ThemKhachHang(KhachHang khachhang)
 {
     try
     {
         KhachHang kh = new KhachHang();
         kh.MaKH       = khachhang.MaKH;
         kh.ChucVu     = khachhang.ChucVu;
         kh.CMND       = khachhang.CMND;
         kh.DiaChi     = khachhang.DiaChi;
         kh.Email      = khachhang.Email;
         kh.NgheNghiep = khachhang.NgheNghiep;
         kh.TenKH      = khachhang.TenKH;
         kh.NgayDangKy = khachhang.NgayDangKy;
         db.KhachHangs.Add(kh);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #7
0
 public bool CapNhatThanhToan(int mahd)
 {
     try
     {
         HoaDonTinhCuoc hd = db.HoaDonTinhCuocs.Find(mahd);
         hd.ThanhToan = true;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #8
0
        public bool ImportFile(string[] data)
        {
            try
            {
                foreach (string line in data)
                {
                    int      id            = db.ChiTietSuDungs.Max(item => item.ID);
                    decimal  sophutSD7h23h = 0;
                    decimal  sophutSD23h7h = 0;
                    string[] split         = line.Split('\t');
                    DateTime dateBD        = DateTime.ParseExact(split[1], "yyyy-MM-dd HH:mm:ss",
                                                                 System.Globalization.CultureInfo.InvariantCulture);
                    DateTime dateKT = DateTime.ParseExact(split[2], "yyyy-MM-dd HH:mm:ss",
                                                          System.Globalization.CultureInfo.InvariantCulture);
                    DateTime tmp23 = dateBD.Date.AddHours(23);
                    DateTime tmp7  = dateBD.Date.AddHours(7);
                    if ((dateBD.Hour < 23 && dateBD.Hour >= 7) && (dateKT.Hour >= 23 || dateKT.Hour < 7))
                    {
                        sophutSD23h7h = Math.Round((decimal)(dateKT - tmp23).TotalMinutes);
                        sophutSD7h23h = Math.Round((decimal)(tmp23 - dateBD).TotalMinutes);
                    }
                    else
                    if (dateBD.Hour < 7 && (dateKT.Hour >= 7 && dateKT.Hour < 23))
                    {
                        sophutSD7h23h = Math.Round((decimal)(dateKT - tmp7).TotalMinutes);
                        sophutSD23h7h = Math.Round((decimal)(tmp7 - dateBD).TotalMinutes);
                    }
                    else
                    if (dateBD.Hour >= 7 && dateKT.Hour < 23)
                    {
                        sophutSD7h23h = Math.Round((decimal)(dateKT - dateBD).TotalMinutes);
                    }
                    else
                    {
                        sophutSD23h7h = Math.Round((decimal)(dateKT - dateBD).TotalMinutes);
                    }

                    /*TimeSpan time = dateKT - dateBD;
                     * decimal phut = Math.Round((decimal)time.TotalMinutes);
                     *
                     * if (7 < dateKT.Hour && dateKT.Hour < 24)
                     * {
                     *  sophutSD7h23h = phut;
                     * }
                     * else
                     * {
                     *  sophutSD23h7h = phut;
                     * }*/
                    db.ChiTietSuDungs.Add(new ChiTietSuDung()
                    {
                        ID = id + 1, IDSIM = split[0], TGBD = dateBD, TGKT = dateKT, SoPhutSD7h23h = sophutSD7h23h, SoPhutSD23h7h = sophutSD23h7h
                    });
                    db.SaveChanges();
                }
                TinhHoaDonTinhCuoc();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }