示例#1
0
        public DateTime GenerateRandomDate(int maSim)
        {
            HoaDonDK hoadondk = cuocgoibus.GetSim(maSim);
            int      yearbd   = hoadondk.NgayDK.Year;
            int      monthbd  = hoadondk.NgayDK.Month;
            int      daybd    = hoadondk.NgayDK.Day;

            Random rd = new Random(Guid.NewGuid().GetHashCode());
            int    year, month, day;

            year = rd.Next(yearbd, 2018);

            if (year > yearbd)
            {
                month = rd.Next(1, 12);
            }
            else
            {
                month = rd.Next(monthbd, 12);
            }

            if (year == yearbd && month == monthbd)
            {
                day = rd.Next(daybd, DateTime.DaysInMonth(year, month));
            }
            else
            {
                day = rd.Next(1, DateTime.DaysInMonth(year, month));
            }

            return(new DateTime(year, month, day, rd.Next(0, 23), rd.Next(0, 59), rd.Next(0, 59)));
        }
示例#2
0
        public bool SaveCusBill(string name, string address, string CMND)
        {
            HoaDonDK bill = db.HoaDonDKs.Single(a => a.CMND == CMND);

            bill.TenKH  = name;
            bill.DiaChi = address;
            bill.CMND   = CMND;
            db.SaveChanges();
            return(true);
        }
示例#3
0
        public bool AddCusBill(string name, string CMND, string DiaChi)
        {
            HoaDonDK bill = new HoaDonDK();

            bill.TenKH      = name;
            bill.CMND       = CMND;
            bill.DiaChi     = DiaChi;
            bill.PhiHoaMang = 50000;
            db.HoaDonDKs.Add(bill);
            db.SaveChanges();
            return(true);
        }
示例#4
0
        public int GetMaHoaDon()
        {
            HoaDonDK hoadon = db.HoaDonDKs.OrderByDescending(hd => hd.MaHD).FirstOrDefault();

            if (hoadon == null)
            {
                return(1);
            }
            else
            {
                return(hoadon.MaHD + 1);
            }
        }
示例#5
0
        public string AddHoaDon(int mahd, int masim, DateTime ngaydk, decimal chiphi, int makh)
        {
            HoaDonDK hoadon = new HoaDonDK();

            //Kiểm tra
            hoadon = db.HoaDonDKs.Where(hd => hd.MaHD == mahd).SingleOrDefault();
            if (hoadon != null)
            {
                return("Trùng mã hóa đơn");
            }
            //Thêm
            hoadon        = new HoaDonDK();
            hoadon.MaHD   = mahd;
            hoadon.MaSim  = masim;
            hoadon.NgayDK = ngaydk;
            hoadon.ChiPhi = chiphi;
            hoadon.MaKH   = makh;
            db.HoaDonDKs.Add(hoadon);
            db.SaveChanges();
            return("Thêm thành công");
        }
示例#6
0
    protected void btnCheckPhoneNumber_Click(object sender, EventArgs e)
    {
        string phoneNumber = txtPhoneNumber.Text;

        if (phoneNumber == "")
        {
            lblNotify.Text = "Vui lòng nhập vào số điện thoại!";
        }
        else
        {
            HoaDonDK hoadon = qLCuocDT.HoaDonDKs.Where(x => x.Sim.SoSim == phoneNumber).SingleOrDefault();
            if (hoadon == null)
            {
                lblNotify.Text = "Số điện thoại không tồn tại!";
            }
            else
            {
                Session["NAMECUSTOMER"] = hoadon.KhachHang.TenKH;
                Session["MaSim"]        = hoadon.Sim.MaSim.ToString();
                Server.Transfer("MainForm.aspx");
            }
        }
    }
示例#7
0
        public HoaDonDK GetHoaDonDK(string sosim)
        {
            HoaDonDK hoadon = db.HoaDonDKs.Where(hd => hd.Sim.SoSim == sosim).SingleOrDefault();

            return(hoadon);
        }