コード例 #1
0
 public bool ThemKhachHang(string HoTen, DateTime NgaySinh, string Email, string MatKhau, string SDT, string DiaChi, string GioiTinh)
 {
     KhachHang kh = new KhachHang();
     kh.HoTen = HoTen;
     kh.NgaySinh = NgaySinh;
     kh.Email = Email;
     kh.MatKhau = MatKhau;
     kh.SDT = SDT;
     kh.DiaChi = DiaChi;
     kh.GioiTinh = GioiTinh;
     kh.NgayDangKi = DateTime.Now;
     try
     {
         using (DBGiayDepEntities db = new DBGiayDepEntities())
         {
             //Lưu add kh mới vào model
             db.KhachHangs.Add(kh);
             //Lưu vào CSDL
             db.SaveChanges();
             return true;
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         return false;
     }
 }
コード例 #2
0
        public ActionResult Create(KhachHang obj)
        {
            var newKhachHang = new KhachHang();
            newKhachHang.Username = obj.Username;
            newKhachHang.Password = obj.Password;
            newKhachHang.Description = obj.Description;
            newKhachHang.Email = obj.Email;

            storeDB.KhachHangs.AddObject(newKhachHang);
            storeDB.SaveChanges();

            return RedirectToAction("Index");
        }
コード例 #3
0
 /// <summary>
 /// Add a new KhachHang within KhachHang database table
 /// </summary>
 /// <param name="obj">KhachHang</param>
 /// <returns>key of table</returns>
 public int Add(KhachHang obj)
 {
     DbParameter parameterItemID = Data.CreateParameter("MaKhachHang", obj.MaKhachHang);
     parameterItemID.Direction = ParameterDirection.Output;
     SqlHelper.ExecuteNonQuery(Data.ConnectionString, CommandType.StoredProcedure,"sproc_KhachHang_Add"
                     ,parameterItemID
                     ,Data.CreateParameter("TenKhachHang", obj.TenKhachHang)
                     ,Data.CreateParameter("DiaChiLienHe", obj.DiaChiLienHe)
                     ,Data.CreateParameter("DiaChiVAT", obj.DiaChiVAT)
                     ,Data.CreateParameter("Email", obj.Email)
                     ,Data.CreateParameter("DienThoai", obj.DienThoai)
                     ,Data.CreateParameter("NguoiLienHe", obj.NguoiLienHe)
     );
     return 0;
 }
コード例 #4
0
ファイル: UserController.cs プロジェクト: xxhhmxx/Web-Service
        public ActionResult Edit(int id, KhachHang kh)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool i = khachHang.UpdateUser(id, kh);
                    if (i)
                    {
                        return RedirectToAction("Detail", "User");
                    }

                }
                return View(kh);
            }
            catch
            {
                return View();
            }
        }
コード例 #5
0
        void LoadHD()
        {
            if (IsEdit == false)
            {
                btnHuyHD.Visible     = false;
                btnLuuHD.Visible     = false;
                btnThemSPMua.Visible = false;
                btnLuuEditSL.Visible = false;
                btnXoaSPMua.Visible  = false;
                btnThanhToan.Visible = false;
                btnLuuTam.Visible    = false;
            }
            if (HD == null)
            {
                textBoxNSX.Visible      = false;
                textBoxLoaiSP.Visible   = false;
                textBoxDSP.Visible      = false;
                textBoxMauKieu.Visible  = false;
                textBoxMaKieuSP.Visible = false;
                textBoxSP.Visible       = false;

                textBoxTinhTrangHD.Text    = "Chưa Thanh Toán";
                textBoxMaNV.Text           = MaNV;
                textBoxMaCH.Text           = IDCH;
                comboBoxMaKH.DataSource    = KHBUS.GetKH();
                comboBoxMaKH.DisplayMember = "MaKH";
                comboBoxMaKH.ValueMember   = "MaKH";
                groupBox2.Enabled          = false;
                btnLuuTam.Visible          = false;
                btnThanhToan.Visible       = false;
            }
            else
            {
                textBoxMaHD.ReadOnly = true;
                textBoxMaKH.ReadOnly = true;
                comboBoxMaKH.Visible = false;

                textBoxHTGH.ReadOnly = true;
                btnHuyHD.Visible     = false;
                btnLuuHD.Visible     = false;
                btnThemKH.Visible    = false;

                textBoxMaCH.Text = HD.MaCuaHang;
                textBoxMaHD.Text = HD.MaHoaDon;
                textBoxMaNV.Text = HD.MaNV;
                textBoxHTGH.Text = HD.HTGiaoHang;
                if (HD.TinhTrang == 1)
                {
                    textBoxTinhTrangHD.Text = "Đã Thanh Toán";
                    btnThemSPMua.Visible    = false;
                    btnLuuEditSL.Visible    = false;
                    btnXoaSPMua.Visible     = false;
                    btnLuuTam.Visible       = false;
                    btnThanhToan.Visible    = false;
                    btnLuuHD.Visible        = false;
                    btnHuyHD.Visible        = false;
                    btnThemSPMua.Visible    = false;
                    btnLuuEditSL.Visible    = false;
                    btnXoaSPMua.Visible     = false;
                    btnThanhToan.Visible    = false;
                    btnLuuTam.Visible       = false;
                }
                else
                {
                    textBoxTinhTrangHD.Text = "Chưa Thanh Toán";
                    btnThanhToan.Visible    = true;
                }
                if (HD.HTGiaoHang.ToLower() != "Trực Tiếp".ToLower())
                {
                    textBoxTinhTrangGiaHang.Visible = true;
                    lbTrangGiaoHang.Visible         = true;
                    linkLbChiTietGiaoHang.Visible   = true;
                    try {
                        textBoxTinhTrangGiaHang.Text = GiaoHangBUS.GetGiaoHangByMaHD_MaCH(HD.MaHoaDon, HD.MaCuaHang).TinhTrangGH.ToString();
                        if (textBoxTinhTrangGiaHang.Text == "Đang Giao Hàng")
                        {
                            btnThanhToan.Visible = false;
                            btnLuuTam.Visible    = false;
                        }
                    }
                    catch { }
                    radioGiaoHang.Checked = true;
                }
                else

                {
                    textBoxTinhTrangGiaHang.Visible = false;
                    lbTrangGiaoHang.Visible         = false;
                    linkLbChiTietGiaoHang.Visible   = false;
                }
                radioGiaoHang.Enabled          = false;
                radioMuaTT.Enabled             = false;
                dateTimePickerNgayVietHD.Value = HD.NgayLapHD;
                KhachHang kh = KHBUS.GetKHByMAKH(HD.MaKH);
                textBoxTenKH.Text  = kh.TenKH;
                textBoxDiaChi.Text = kh.DiaChi;
                txtboxSDT.Text     = kh.SDT;
                textBoxMaKH.Text   = kh.MaKH;

                chiTietHoaDonBindingSource.DataSource = ChiTietHoaDonBUS.GetChieTietHD_ByMaHD(HD.MaHoaDon, HD.MaCuaHang);

                lbTongTien.Text = ChiTietHoaDonBUS.TinhTien_ByMaHD(HD.MaHoaDon, HD.MaCuaHang).ToString();
            }
        }
コード例 #6
0
        public ActionResult DatHang(KhachHang kh)
        {
            if (Session["GioHang"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            KhachHang KhachHang = new KhachHang();

            if (Session["TaiKhoan"] == null)
            {
                KhachHang = kh;
                _khService.ThemMoi(KhachHang);
                _khService.luu();
            }
            else
            {
                ThanhVien tv        = Session["TaiKhoan"] as ThanhVien;
                var       khachhang = _khService.LayKhachHangTheoMaThanhVien(tv.MaTV);
                if (!khachhang.Any())
                {
                    KhachHang.Ten       = tv.HoTen;
                    KhachHang.DiaChi    = tv.DiaChi;
                    KhachHang.Email     = tv.Email;
                    KhachHang.DienThoai = tv.DienThoai;
                    KhachHang.MaTV      = tv.MaTV;
                    _khService.ThemMoi(KhachHang);
                    _khService.luu();
                }
                else
                {
                    KhachHang = khachhang.FirstOrDefault();
                }
            }

            DonDatHang ddh = new DonDatHang();

            ddh.MaKH              = KhachHang.MaKH;
            ddh.NgayDatHang       = DateTime.Now;
            ddh.TinhTrangGiaoHang = false;
            ddh.DaThanhToan       = false;
            ddh.UuDai             = 0;
            ddh.DaXoa             = false;
            ddh.DaHuy             = false;
            _ddhService.ThemMoi(ddh);
            _ddhService.luu();

            List <VatPhamTrongGioHang> lstGH = LayGioHang();

            foreach (var item in lstGH)
            {
                ChiTietDonDatHang ctdh = new ChiTietDonDatHang();
                ctdh.MaDDH   = ddh.MaDDH;
                ctdh.MaSP    = item.MaSP;
                ctdh.TenSP   = item.TenSP;
                ctdh.SoLuong = item.SoLuong;
                ctdh.DonGia  = item.DonGia;
                _ctddhService.ThemMoi(ctdh);
            }
            _ctddhService.luu();
            Session["GioHang"]   = null;
            TempData["ThongBao"] = "Mua hàng thành công! chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất!";
            return(RedirectToAction("XemGioHang"));
        }
コード例 #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public KhachHang Populate(IDataReader myReader)
 {
     KhachHang obj = new KhachHang();
     obj.MaKhachHang = (int) myReader["MaKhachHang"];
     obj.TenKhachHang = (string) myReader["TenKhachHang"];
     obj.DiaChiLienHe = (string) myReader["DiaChiLienHe"];
     obj.DiaChiVAT = (string) myReader["DiaChiVAT"];
     obj.Email = (string) myReader["Email"];
     obj.DienThoai = (string) myReader["DienThoai"];
     obj.NguoiLienHe = (string) myReader["NguoiLienHe"];
     return obj;
 }
コード例 #8
0
ファイル: KhachHangBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Insert(KhachHang data, User user)
 {
     return KhachHangDao.Insert(data, user);
 }
コード例 #9
0
 public bool SuaKH(KhachHang khachhangSua)
 {
     return(khContext.SuaKH(khachhangSua));
 }
コード例 #10
0
        public async Task <IActionResult> PutKhachHang([FromBody] EditKHRequest khach_hang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (khach_hang == null)
            {
                return(BadRequest());
            }

            KhachHang khachHang = _context.KhachHang.Find(khach_hang.Id);

            if (checkNullAndEmpty(khach_hang.Address))
            {
                khachHang.DiaChiKhachHang = khach_hang.Address;
            }

            if (checkNullAndEmpty(khach_hang.Email))
            {
                khachHang.EmailKhachHang = khach_hang.Email;
            }

            if (checkNullAndEmpty(khach_hang.SoDienThoaiKhachHang))
            {
                khachHang.SoDienThoaiKhachHang = khach_hang.SoDienThoaiKhachHang;
            }

            if (checkNullAndEmpty(khach_hang.TenKhachHang))
            {
                khachHang.TenKhachHang = khach_hang.TenKhachHang;
            }

            if (checkNullAndEmpty(khach_hang.Password))
            {
                khachHang.Password = khach_hang.Password;
            }

            if (checkNullAndEmpty(khach_hang.Anh))
            {
                khachHang.Avatar = khach_hang.Anh;
            }
            _context.Entry(khachHang).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KhachHangExists(khach_hang.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(khachHang));
        }
コード例 #11
0
 public ActionResult Logout()
 {
     Session["User"] = null;
     khachhangstatic = null;
     return(RedirectToAction("Index", "Home"));
 }
コード例 #12
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            QlSachDbDataContext db = new QlSachDbDataContext();
            if ((string)Session["dn"] == "")
            {

                if (!(db.DangNhaps.Where(p => p.TenDangNhap == tbTenDangNhap.Text)).Any())
                {
                    DangNhap dn = new DangNhap();
                    dn.TenDangNhap = tbTenDangNhap.Text;
                    dn.MatKhau = Encoding.MaHoa(Encoding.key, tbMK.Text);
                    dn.Quyen = false;
                    dn.hoten = tbHoten.Text;
                    db.DangNhaps.InsertOnSubmit(dn);
                    db.SubmitChanges();
                }
                else
                {
                    //Type cstype = this.GetType();

                    //// Get a ClientScriptManager reference from the Page class.
                    //ClientScriptManager cs = Page.ClientScript;

                    //// Check to see if the startup script is already registered.
                    //if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
                    //{
                    //    String cstext = "alert('Tên đăng nhập này đã tồn tại!');";
                    //    cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
                    //}
                    Response.Write("<script>alert(\"Tên đăng nhập này đã tồn tại!\")</script>");
                    
                    return;
                }
                long makh;
                if (db.KhachHangs.Count() == 0)
                    makh = 0;
                else
                    makh = db.KhachHangs.Max(p => p.Makh);
                KhachHang kh = new KhachHang();
                kh.Makh = makh + 1;
                kh.hoten = tbHoten.Text;
                kh.SoDT = tbSdt.Text;
                kh.email = tbEmail.Text;
                kh.diachi = tbDiachi.Text;
                kh.TenDangNhap = tbTenDangNhap.Text;
                db.KhachHangs.InsertOnSubmit(kh);
                db.SubmitChanges();

                if (Session["gh"] == null)
                {
                    Response.Write("<script>alert(\"Giỏ hàng trống!\");window.location='default.aspx';</script>");
                    //Response.Redirect("default.aspx");
                    return;
                }

                long mahd = 0;
                if (db.hoadons.Count() == 0)
                    mahd = 0;
                else
                    mahd = db.hoadons.Max(p => p.MaHoaDon);
                hoadon hd = new hoadon();
                hd.MaHoaDon = mahd + 1;
                hd.makh = kh.Makh;
                hd.damua = false;
                hd.NgayMua = DateTime.Now;
                db.hoadons.InsertOnSubmit(hd);
                db.SubmitChanges();
                DataTable dt = new DataTable();
                Gio gh = new Gio();
                gh = (Gio)Session["gh"];
                dt = gh.dt;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ChiTietHoaDon cthd = new ChiTietHoaDon();
                    long macthd;
                    if (db.ChiTietHoaDons.Count() == 0)
                        macthd = 0;
                    else
                        macthd = db.ChiTietHoaDons.Max(p => p.MaChiTietHD);
                    cthd.MaChiTietHD = macthd + 1;
                    cthd.MaHoaDon = mahd + 1;
                    cthd.MaSach = dt.Rows[i]["masach"].ToString();
                    cthd.SoLuongMua = int.Parse(dt.Rows[i]["soluong"].ToString());
                    
                    //Trừ số lượng sách mua
                    sach s = db.saches.Single(p => p.masach == cthd.MaSach);
                    s.soluong -= cthd.SoLuongMua;
                    db.ChiTietHoaDons.InsertOnSubmit(cthd);
                    db.SubmitChanges();
                    //Type cstype = this.GetType();

                    //// Get a ClientScriptManager reference from the Page class.
                    //ClientScriptManager cs = Page.ClientScript;

                    //// Check to see if the startup script is already registered.
                    //if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
                    //{
                    //    String cstext = "alert('Đặt mua thành công!');";
                    //    cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
                    //}
                    

                }

                Response.Write("<script>alert(\"Đăng kí thành công!\")</script>");
                Response.Write("<script>window.location='xoagiohang.aspx';</script>");
            }
            else
            {
                string sdn = (string)Session["dn"];
                DangNhap dn = db.DangNhaps.Single(p => p.TenDangNhap == sdn);
                KhachHang kh = db.KhachHangs.Single(p => p.TenDangNhap == sdn);
                dn.MatKhau = Encoding.MaHoa(Encoding.key, tbMK.Text);
                db.SubmitChanges();
                kh.hoten = tbHoten.Text;
                kh.diachi = tbDiachi.Text;
                kh.SoDT = tbSdt.Text;
                kh.email = tbEmail.Text;
                db.SubmitChanges();
               
                Response.Write("<script>alert(\"Thay đổi thông tin thành công!\");window.location ='default.aspx';</script>");
                //Response.Redirect("~/default.aspx");
            }
        }
コード例 #13
0
ファイル: Default.aspx.cs プロジェクト: nhatkycon/ThaoLyShop
    protected void Page_Load(object sender, EventArgs e)
    {
        var act = Request["act"];
        var Ten = Request["Ten"];
        var Ho = Request["Ho"];
        var ID = Request["ID"];
        var XungHo = Request["XungHo"];
        var NgaySinh = Request["NgaySinh"];
        var Mobile = Request["Mobile"];
        var FacebookUid = Request["FacebookUid"];
        var NguonGoc_ID = Request["NguonGoc_ID"];
        var KhuVuc_ID = Request["KhuVuc_ID"];
        var DiaChi = Request["DiaChi"];
        var NgungTheoDoi = Request["NgungTheoDoi"];
        var HH_ID = Request["HH_ID"];
        var GhiChu = Request["GhiChu"];
        var FacebookUrl = Request["FacebookUrl"];
        var UuTien = Request["UuTien"];
        var NgayGiao = Request["NgayGiao"];
        var NgayGiaoYeuCau = Request["NgayGiaoYeuCau"];
        var NgayDat = Request["NgayDat"];
        NgungTheoDoi = !string.IsNullOrEmpty(NgungTheoDoi) ? "true" : "false";
        switch (act)
        {
            case "add":
            #region add
                if(Security.IsAuthenticated())
                {
                    KhachHang item;
                    if(string.IsNullOrEmpty(ID))
                    {
                        item=new KhachHang();
                        item.ID = Guid.NewGuid();
                        item.NgayTao = DateTime.Now;
                    }
                    else
                    {
                        item = KhachHangDal.SelectById(new Guid(ID));

                    }
                    item.NguoiTao = Security.Username;
                    item.Ten = Ten;
                    item.Mobile = Mobile;
                    item.FacebookUid = FacebookUid;
                    item.DiaChi = DiaChi;
                    if(!string.IsNullOrEmpty(NguonGoc_ID))
                    {
                        item.NguonGoc_ID=new Guid(NguonGoc_ID);
                    }
                    if (!string.IsNullOrEmpty(KhuVuc_ID))
                    {
                        item.KhuVuc_ID = new Guid(KhuVuc_ID);
                    }
                    item.NgungTheoDoi = Convert.ToBoolean(NgungTheoDoi);
                    item.NgayCapNhat = DateTime.Now;
                    item = string.IsNullOrEmpty(ID) ? KhachHangDal.Insert(item) : KhachHangDal.Update(item);
                    rendertext(item.ID.ToString());
                }
                break;
            #endregion
            case "xoa":
                #region add
                if (Security.IsAuthenticated())
                {
                    KhachHangDal.DeleteById(new Guid(ID));
                }
                break;
                #endregion
            case "addAndShip":
                #region add
                if (Security.IsAuthenticated())
                {
                    var item = new KhachHang
                                   {
                                       ID = Guid.NewGuid(),
                                       NgayTao = DateTime.Now,
                                       NguoiTao = Security.Username,
                                       Ten = Ten,
                                       Mobile = Mobile,
                                       FacebookUid = FacebookUid,
                                       DiaChi = DiaChi,
                                       Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10)
                                   };
                    if (!string.IsNullOrEmpty(NguonGoc_ID))
                    {
                        item.NguonGoc_ID = new Guid(NguonGoc_ID);
                    }
                    if (!string.IsNullOrEmpty(KhuVuc_ID))
                    {
                        item.KhuVuc_ID = new Guid(KhuVuc_ID);
                    }
                    item.NgungTheoDoi = Convert.ToBoolean(NgungTheoDoi);
                    item = KhachHangDal.Insert(item);

                    var hh = docsoft.entities.HangHoaDal.SelectById(new Guid(HH_ID));

                    var dh = new DatHang
                                 {
                                     GiaTri = Convert.ToInt32(hh.GNY),
                                     ID = Guid.NewGuid(),
                                     KH_DiaChi = DiaChi,
                                     KH_ID = item.ID,
                                     KH_Mobile = Mobile,
                                     KH_Ten = Ten,
                                     Readed = false,
                                     Tong = Convert.ToInt32(hh.GNY),
                                     PhiVanChuyen = 0,
                                     NgayTao = DateTime.Now,
                                     Username = Security.Username,
                                     GhiChu = GhiChu,
                                     FacebookUrl = FacebookUrl,
                                     Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10),
                                     UuTien = Convert.ToInt32(string.IsNullOrEmpty(UuTien) ? "1" : UuTien)
                                 };

                    if (!string.IsNullOrEmpty(NgayGiaoYeuCau))
                    {
                        dh.NgayGiaoYeuCau = Convert.ToDateTime(NgayGiaoYeuCau, new CultureInfo("vi-vn"));
                    }
                    if (!string.IsNullOrEmpty(NgayDat))
                    {
                        dh.NgayDat = Convert.ToDateTime(NgayDat, new CultureInfo("vi-vn"));
                    }
                    else
                    {
                        dh.NgayDat = DateTime.Now;
                    }
                    if (!string.IsNullOrEmpty(NgayGiao))
                    {
                        dh.NgayGiao = Convert.ToDateTime(NgayGiao, new CultureInfo("vi-vn"));
                    }
                    if (!string.IsNullOrEmpty(NguonGoc_ID))
                    {
                        dh.NguonGoc_ID = new Guid(NguonGoc_ID);
                    }
                    dh = DatHangDal.Insert(dh);

                    var dhct = new DatHangChiTiet
                                   {
                                       DH_ID = dh.ID,
                                       HH_ID = hh.ID,
                                       HH_Gia = Convert.ToInt32(hh.GNY),
                                       HH_SoLuong = 1,
                                       HH_Ten = hh.Ten,
                                       HH_Tong = Convert.ToInt32(hh.GNY),
                                       ID = Guid.NewGuid(),
                                       NgayTao = DateTime.Now
                                   };
                    dhct = DatHangChiTietDal.Insert(dhct);

                    var ship = new Shipping()
                                   {
                                       ID = Guid.NewGuid()
                                       , DH_ID = dh.ID
                                       , DH_Ma = dh.Ma
                                       , Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10)
                                       , DaGiao = false
                                       , DiaChi = dh.KH_DiaChi
                                       , HD_ID = dhct.HH_ID
                                       , NgayGiao = DateTime.Now
                                       , NgayTao = DateTime.Now
                                       , NguoiTao = Security.Username
                                       , Phi = dh.PhiVanChuyen
                                       , Readed = false
                                       , TraTien = false
                                       , PhaiThu = dh.Tong
                                   };
                    ship = ShippingDal.Insert(ship);

                    // Xuất nhập
                    var danhMucLoaiXuatNhap = DanhMucDal.SelectByMa("LXN-X");
                    var xn = XuatNhapDal.SelectByDraff(true);
                    xn.TVDV_ID = dh.ID;
                    xn.ChietKhau = 0;
                    xn.ChuyenDoi = false;
                    xn.ConNo = 0;
                    xn.CongTienHang = dh.Tong;
                    xn.DauKy = false;
                    xn.DienGiai = string.Format("Thêm hóa đơn bán lẻ cho đặt hàng {0}", dh.Ma);
                    xn.ID = Guid.NewGuid();
                    xn.KHO_ID = KhoHangDal.SelectAll()[0].ID;
                    xn.KH_ID = dh.KH_ID;
                    xn.KH_Ten = dh.KH_Ten;
                    xn.NgayCapNhat = DateTime.Now;
                    xn.NgayHoaDon = DateTime.Now;
                    xn.NgayTao = DateTime.Now;
                    xn.NguoiCapNhat = Security.Username;
                    xn.NguoiTao = Security.Username;
                    xn.NhanVien = Security.Username;
                    xn.NoiBo = false;
                    xn.ThanhToan = dh.Tong;
                    xn.TuVanVien = Security.Username;
                    xn.VAT = 0;
                    xn.Xuat = true;
                    xn.LOAI_ID = danhMucLoaiXuatNhap.ID;
                    xn = XuatNhapDal.Insert(xn);

                    // Xuất nhập chi tiết

                    var itemXnCt = new XuatNhapChiTiet
                                       {
                                           ID = Guid.NewGuid(),
                                           CKTien = Convert.ToDouble(0),
                                           CKTyLe = Convert.ToDouble(0),
                                           DonGia = Convert.ToDouble(dhct.HH_Gia),
                                           HH_ID = dhct.HH_ID,
                                           GhiChu = GhiChu,
                                           NgayCapNhat = DateTime.Now,
                                           NguoiCapNhat = Security.Username,
                                           SoLuong = Convert.ToDouble(dhct.HH_SoLuong),
                                           Tong = Convert.ToDouble(dhct.HH_Tong),
                                           VAT = Convert.ToDouble(0),
                                           KH_ID = dh.KH_ID
                                       };
                    itemXnCt = XuatNhapChiTietDal.Update(itemXnCt);

                    // Thu chi
                    var thuChi = ThuChiDal.SelectByXnId(xn.ID.ToString());
                    thuChi.LoaiQuy = Convert.ToInt32(0);
                    thuChi.P_ID = xn.KH_ID;
                    thuChi.NgayTao = DateTime.Now;
                    thuChi.SoTien = dh.Tong;
                    if (thuChi.ID == Guid.Empty)
                    {
                        var ndtcItem = DanhMucDal.SelectByMa("NDTC-THU-KHANGTRA");
                        thuChi = ThuChiDal.SelectByDraff(true);
                        thuChi.LoaiCandoi = 0;
                        thuChi.Mota = string.Format("{0}: {1}", ndtcItem.Ten, item.Ma);
                        thuChi.NDTC_ID = ndtcItem.ID;
                        thuChi.Thu = true;
                        thuChi.XN_ID = item.ID;
                        thuChi.NguoiTao = Security.Username;
                        thuChi.NguoiSua = Security.Username;
                        thuChi.NgaySua = DateTime.Now;
                        thuChi.isCandoi = false;
                        ThuChiDal.Insert(thuChi);
                    }
                    else
                    {
                        thuChi.NguoiSua = Security.Username;
                        thuChi.NgaySua = DateTime.Now;
                        ThuChiDal.Update(thuChi);
                    }

                    rendertext(dh.ID.ToString());
                }
                break;
                #endregion
            case "addAndHoaDon":
                #region addAndHoaDon
                if (Security.IsAuthenticated())
                {
                    var item = new KhachHang
                    {
                        ID = Guid.NewGuid(),
                        NgayTao = DateTime.Now,
                        NguoiTao = Security.Username,
                        Ten = Ten,
                        Mobile = Mobile,
                        FacebookUid = FacebookUid,
                        DiaChi = DiaChi,
                        Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10)
                    };
                    if (!string.IsNullOrEmpty(NguonGoc_ID))
                    {
                        item.NguonGoc_ID = new Guid(NguonGoc_ID);
                    }
                    if (!string.IsNullOrEmpty(KhuVuc_ID))
                    {
                        item.KhuVuc_ID = new Guid(KhuVuc_ID);
                    }
                    item.NgungTheoDoi = Convert.ToBoolean(NgungTheoDoi);
                    item = KhachHangDal.Insert(item);

                    var hh = docsoft.entities.HangHoaDal.SelectById(new Guid(HH_ID));

                    var dh = new DatHang
                    {
                        GiaTri = Convert.ToInt32(hh.GNY),
                        ID = Guid.NewGuid(),
                        KH_DiaChi = DiaChi,
                        KH_ID = item.ID,
                        KH_Mobile = Mobile,
                        KH_Ten = Ten,
                        Readed = false,
                        Tong = Convert.ToInt32(hh.GNY),
                        PhiVanChuyen = 0,
                        NgayTao = DateTime.Now,
                        Username = Security.Username,
                        GhiChu = GhiChu,
                        FacebookUrl = FacebookUrl,
                        Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10),
                        UuTien = Convert.ToInt32(string.IsNullOrEmpty(UuTien) ? "1" : UuTien)
                    };

                    if (!string.IsNullOrEmpty(NgayGiaoYeuCau))
                    {
                        dh.NgayGiaoYeuCau = Convert.ToDateTime(NgayGiaoYeuCau, new CultureInfo("vi-vn"));
                    }
                    if (!string.IsNullOrEmpty(NgayDat))
                    {
                        dh.NgayDat = Convert.ToDateTime(NgayDat, new CultureInfo("vi-vn"));
                    }
                    else
                    {
                        dh.NgayDat = DateTime.Now;
                    }
                    if (!string.IsNullOrEmpty(NgayGiao))
                    {
                        dh.NgayGiao = Convert.ToDateTime(NgayGiao, new CultureInfo("vi-vn"));
                    }
                    if (!string.IsNullOrEmpty(NguonGoc_ID))
                    {
                        dh.NguonGoc_ID = new Guid(NguonGoc_ID);
                    }
                    dh = DatHangDal.Insert(dh);

                    var dhct = new DatHangChiTiet
                    {
                        DH_ID = dh.ID,
                        HH_ID = hh.ID,
                        HH_Gia = Convert.ToInt32(hh.GNY),
                        HH_SoLuong = 1,
                        HH_Ten = hh.Ten,
                        HH_Tong = Convert.ToInt32(hh.GNY),
                        ID = Guid.NewGuid(),
                        NgayTao = DateTime.Now
                    };
                    dhct = DatHangChiTietDal.Insert(dhct);

                    var ship = new Shipping()
                    {
                        ID = Guid.NewGuid()
                        ,
                        DH_ID = dh.ID
                        ,
                        DH_Ma = dh.Ma
                        ,
                        Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10)
                        ,
                        DaGiao = false
                        ,
                        DiaChi = dh.KH_DiaChi
                        ,
                        HD_ID = dhct.HH_ID
                        ,
                        NgayGiao = DateTime.Now
                        ,
                        NgayTao = DateTime.Now
                        ,
                        NguoiTao = Security.Username
                        ,
                        Phi = dh.PhiVanChuyen
                        ,
                        Readed = false
                        ,
                        TraTien = false
                        ,
                        PhaiThu = dh.Tong
                    };
                    ship = ShippingDal.Insert(ship);
                    rendertext(dh.ID.ToString());
                }
                break;
                #endregion
            default:
                break;
        }
    }
コード例 #14
0
 /// <summary>
 /// updates the specified KhachHang
 /// </summary>
 /// <param name="obj">KhachHang</param>
 /// <returns></returns>
 public void Update(KhachHang obj)
 {
     SqlHelper.ExecuteNonQuery(Data.ConnectionString, CommandType.StoredProcedure,"sproc_KhachHang_Update"
                     ,Data.CreateParameter("MaKhachHang", obj.MaKhachHang)
                     ,Data.CreateParameter("TenKhachHang", obj.TenKhachHang)
                     ,Data.CreateParameter("DiaChiLienHe", obj.DiaChiLienHe)
                     ,Data.CreateParameter("DiaChiVAT", obj.DiaChiVAT)
                     ,Data.CreateParameter("Email", obj.Email)
                     ,Data.CreateParameter("DienThoai", obj.DienThoai)
                     ,Data.CreateParameter("NguoiLienHe", obj.NguoiLienHe)
     );
 }
コード例 #15
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#line 2 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"

            ViewData["Title"] = "ThanhToan1";
            Layout            = "~/Views/Shared/_Frontend.cshtml";

#line default
#line hidden
            BeginContext(135, 2665, true);
            WriteLiteral(@"
<script>
    function myFunction() {
        alert(""Đặt hàng thành công! Bạn có thể theo dõi đơn hàng của mình."");

    }
</script>

<script>
    function myFunction1() {
        alert(""Xin lỗi, Không có đủ hàng cho sản phẩm này."");
    }
</script>

<script>
    $(document).ready(function () {
        $('input[type=""radio""]').click(function () {
            var inputValue = $(this).attr(""value"");
            var targetBox = $(""."" + inputValue);
            $("".box1"").not(targetBox).hide();
            $(targetBox).fadeIn(500);
        });
    });
</script>

<style>
    .box1 {
        display: none;
    }

    [type=""radio""]:checked,
    [type=""radio""]:not(:checked) {
        position: absolute;
        left: -9999px;
    }
    [type=""radio""]:checked + label,
    [type=""radio""]:not(:checked) + label
    {
        position: relative;
        padding-left: 28px;
        cursor: pointer;
        line-height: 20px;
        display: inline-block;
        color: #666;
  ");
            WriteLiteral(@"  }
    [type=""radio""]:checked + label:before,
    [type=""radio""]:not(:checked) + label:before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 18px;
        height: 18px;
        border: 1px solid #6c757d;
        border-radius: 100%;
        background: #fff;
    }
        [type=""radio""]:checked + label:after,
        [type=""radio""]:not(:checked) + label:after {
            content: '';
            width: 12px;
            height: 12px;
            background: #ff9999;
            position: absolute;
            top: 3px;
            left: 3px;
            border-radius: 100%;
            -webkit-transition: all 0.2s ease;
            transition: all 0.2s ease;
        }
    [type=""radio""]:not(:checked) + label:after {
        opacity: 0;
        -webkit-transform: scale(0);
        transform: scale(0);
    }
    [type=""radio""]:checked + label:after {
        opacity: 1;
        -webkit-transform: scale(1);
        transform");
            WriteLiteral(@": scale(1);
    }
</style>

<div id=""content"">
    <div class=""container"">
        <div class=""row"">
            <div class=""col-lg-12"">
                <!-- breadcrumb-->
                <nav aria-label=""breadcrumb"">
                    <ol class=""breadcrumb"">
                        <li class=""breadcrumb-item""><a href=""#"">Trang chủ </a></li>
                        <li aria-current=""page"" class=""breadcrumb-item active"">Thanh Toán bước 2</li>
                    </ol>
                </nav>
            </div>
            <div id=""checkout"" class=""col-lg-9"">
                <div class=""box"">
");
            EndContext();
#line 102 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"

            double tong = 0;


#line default
#line hidden
            BeginContext(2889, 248, true);
            WriteLiteral("                    <h1>Hóa đơn của bạn</h1>\r\n                    <div class=\"nav flex-column flex-sm-row nav-pills\"><a href=\"#\" class=\"nav-link flex-sm-fill text-sm-center\"> <i class=\"fa fa-map-marker\">                  </i>Thông tin giao hàng</a>");
            EndContext();
            BeginContext(3137, 167, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "acab48e43d994de09bd31aadac596bcc", async() => {
                BeginContext(3238, 62, true);
                WriteLiteral(" <i class=\"fa fa-eye\">                     </i>Hóa đơn của bạn");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
            __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
            __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
            __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_1.Value;
            __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
            __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(3304, 9, true);
            WriteLiteral(" </div>\r\n");
            EndContext();
#line 107 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
            if (Context.Session.Get <KhachHang>("TaiKhoan") != null)
            {
                KhachHang kh = Context.Session.Get <KhachHang>("TaiKhoan");


#line default
#line hidden
                BeginContext(3500, 24, true);
                WriteLiteral("                        ");
                EndContext();
                BeginContext(3524, 6918, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "6263a431f4764cad99d5e463b2ff922d", async() => {
                    BeginContext(3592, 2, true);
                    WriteLiteral("\r\n");
                    EndContext();
#line 112 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    if (Context.Session.Get <List <NguoiNhan> >("ThongTin") != null)
                    {
                        List <NguoiNhan> info = Context.Session.Get <List <NguoiNhan> >("ThongTin");



#line default
#line hidden
#line 116 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        foreach (var item in info)
                        {
#line default
#line hidden
                            BeginContext(3921, 71, true);
                            WriteLiteral("                                    <input type=\"hidden\" name=\"tennhan\"");
                            EndContext();
                            BeginWriteAttribute("value", " value=\"", 3992, "\"", 4013, 1);
#line 118 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            WriteAttributeValue("", 4000, item.TenNhan, 4000, 13, false);

#line default
#line hidden
                            EndWriteAttribute();
                            BeginContext(4014, 100, true);
                            WriteLiteral(" class=\"form-control\" />\r\n                                    <input type=\"hidden\" name=\"diachinhan\"");
                            EndContext();
                            BeginWriteAttribute("value", " value=\"", 4114, "\"", 4138, 1);
#line 119 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            WriteAttributeValue("", 4122, item.DiaChiNhan, 4122, 16, false);

#line default
#line hidden
                            EndWriteAttribute();
                            BeginContext(4139, 97, true);
                            WriteLiteral(" class=\"form-control\" />\r\n                                    <input type=\"hidden\" name=\"sdtnhan\"");
                            EndContext();
                            BeginWriteAttribute("value", " value=\"", 4236, "\"", 4257, 1);
#line 120 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            WriteAttributeValue("", 4244, item.SDTNhan, 4244, 13, false);

#line default
#line hidden
                            EndWriteAttribute();
                            BeginContext(4258, 100, true);
                            WriteLiteral(" class=\"form-control\" />\r\n                                    <input type=\"hidden\" name=\"ghichunhan\"");
                            EndContext();
                            BeginWriteAttribute("value", " value=\"", 4358, "\"", 4378, 1);
#line 121 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            WriteAttributeValue("", 4366, item.GhiChu, 4366, 12, false);

#line default
#line hidden
                            EndWriteAttribute();
                            BeginContext(4379, 26, true);
                            WriteLiteral(" class=\"form-control\" />\r\n");
                            EndContext();
#line 122 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        }

#line default
#line hidden
#line 122 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    }
                    else
                    {
#line default
#line hidden
                        BeginContext(4536, 67, true);
                        WriteLiteral("                                <input type=\"hidden\" name=\"tennhan\"");
                        EndContext();
                        BeginWriteAttribute("value", " value=\"", 4603, "\"", 4620, 1);
#line 126 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        WriteAttributeValue("", 4611, kh.HoTen, 4611, 9, false);

#line default
#line hidden
                        EndWriteAttribute();
                        BeginContext(4621, 96, true);
                        WriteLiteral(" class=\"form-control\" />\r\n                                <input type=\"hidden\" name=\"diachinhan\"");
                        EndContext();
                        BeginWriteAttribute("value", " value=\"", 4717, "\"", 4735, 1);
#line 127 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        WriteAttributeValue("", 4725, kh.DiaChi, 4725, 10, false);

#line default
#line hidden
                        EndWriteAttribute();
                        BeginContext(4736, 93, true);
                        WriteLiteral(" class=\"form-control\" />\r\n                                <input type=\"hidden\" name=\"sdtnhan\"");
                        EndContext();
                        BeginWriteAttribute("value", " value=\"", 4829, "\"", 4850, 1);
#line 128 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        WriteAttributeValue("", 4837, kh.DienThoai, 4837, 13, false);

#line default
#line hidden
                        EndWriteAttribute();
                        BeginContext(4851, 26, true);
                        WriteLiteral(" class=\"form-control\" />\r\n");
                        EndContext();
#line 129 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    }

#line default
#line hidden
                    BeginContext(4908, 60, true);
                    WriteLiteral("                            <input type=\"hidden\" name=\"makh\"");
                    EndContext();
                    BeginWriteAttribute("value", " value=\"", 4968, "\"", 4984, 1);
#line 130 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    WriteAttributeValue("", 4976, kh.MaKh, 4976, 8, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(4985, 89, true);
                    WriteLiteral(" class=\"form-control\" />\r\n                            <input type=\"hidden\" name=\"hotenkh\"");
                    EndContext();
                    BeginWriteAttribute("value", " value=\"", 5074, "\"", 5091, 1);
#line 131 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    WriteAttributeValue("", 5082, kh.HoTen, 5082, 9, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(5092, 90, true);
                    WriteLiteral(" class=\"form-control\" />\r\n                            <input type=\"hidden\" name=\"diachikh\"");
                    EndContext();
                    BeginWriteAttribute("value", " value=\"", 5182, "\"", 5200, 1);
#line 132 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    WriteAttributeValue("", 5190, kh.DiaChi, 5190, 10, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(5201, 85, true);
                    WriteLiteral(" class=\"form-control\" />\r\n                            <input type=\"hidden\" name=\"sdt\"");
                    EndContext();
                    BeginWriteAttribute("value", " value=\"", 5286, "\"", 5307, 1);
#line 133 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    WriteAttributeValue("", 5294, kh.DienThoai, 5294, 13, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(5308, 692, true);
                    WriteLiteral(@" class=""form-control"" />
                            <div class=""content"">
                                <div class=""table-responsive"">
                                    <table class=""table"">
                                        <thead>
                                            <tr>
                                                <th colspan=""2"">Sản phẩm</th>
                                                <th>Số lượng</th>
                                                <th>Đơn giá</th>
                                                <th colspan=""1"">Tổng cộng</th>
                                            </tr>
                                        </thead>
");
                    EndContext();
#line 145 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    if (Context.Session.Get <List <CartItem> >("GioHang") != null)
                    {
#line default
#line hidden
                        BeginContext(6145, 53, true);
                        WriteLiteral("                                            <tbody>\r\n");
                        EndContext();
#line 148 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        foreach (var item in Model)
                        {
#line default
#line hidden
                            BeginContext(6327, 130, true);
                            WriteLiteral("                                                    <tr>\r\n                                                        <td><a href=\"#\">");
                            EndContext();
                            BeginContext(6457, 62, false);
                            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("img", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "c53fe10b2cfd4a0dbe824f1a3f65a841", async() => {
                            }
                                                                                        );
                            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
                            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
                            BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "src", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                            AddHtmlAttributeValue("", 6467, "~/Hinh/beauty/", 6467, 14, true);
#line 151 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            AddHtmlAttributeValue("", 6481, item.Hinh, 6481, 10, false);

#line default
#line hidden
                            EndAddHtmlAttributeValues(__tagHelperExecutionContext);
                            __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3);
                            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                            if (!__tagHelperExecutionContext.Output.IsContentModified)
                            {
                                await __tagHelperExecutionContext.SetOutputContentAsync();
                            }
                            Write(__tagHelperExecutionContext.Output);
                            __tagHelperExecutionContext = __tagHelperScopeManager.End();
                            EndContext();
                            BeginContext(6519, 83, true);
                            WriteLiteral("</a></td>\r\n                                                        <td><a href=\"#\">");
                            EndContext();
                            BeginContext(6603, 10, false);
#line 152 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            Write(item.TenHh);

#line default
#line hidden
                            EndContext();
                            BeginContext(6613, 97, true);
                            WriteLiteral("</a></td>\r\n                                                        <td style=\"text-align:center\">");
                            EndContext();
                            BeginContext(6711, 12, false);
#line 153 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            Write(item.SoLuong);

#line default
#line hidden
                            EndContext();
                            BeginContext(6723, 67, true);
                            WriteLiteral("</td>\r\n                                                        <td>");
                            EndContext();
                            BeginContext(6791, 29, false);
#line 154 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            Write(item.GiaBan.ToString("#,##0"));

#line default
#line hidden
                            EndContext();
                            BeginContext(6820, 69, true);
                            WriteLiteral(" đ</td>\r\n                                                        <td>");
                            EndContext();
                            BeginContext(6890, 32, false);
#line 155 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                            Write(item.ThanhTien.ToString("#,##0"));

#line default
#line hidden
                            EndContext();
                            BeginContext(6922, 68, true);
                            WriteLiteral(" đ</td>\r\n                                                    </tr>\r\n");
                            EndContext();
#line 157 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        }

#line default
#line hidden
                        BeginContext(7041, 107, true);
                        WriteLiteral("                                            </tbody>\r\n                                            <tfoot>\r\n");
                        EndContext();
#line 160 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        foreach (var item in Model)
                        {
                            tong = tong + item.ThanhTien;
                        }

#line default
#line hidden
                        BeginContext(7411, 194, true);
                        WriteLiteral("                                                <tr>\r\n                                                    <th colspan=\"4\">Tổng cộng</th>\r\n                                                    <th>");
                        EndContext();
                        BeginContext(7606, 22, false);
#line 166 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                        Write(tong.ToString("#,##0"));

#line default
#line hidden
                        EndContext();
                        BeginContext(7628, 118, true);
                        WriteLiteral(" đ</th>\r\n                                                </tr>\r\n                                            </tfoot>\r\n");
                        EndContext();
#line 169 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    }
                    else
                    {
#line default
#line hidden
                        BeginContext(7878, 769, true);
                        WriteLiteral(@"                                            <tbody>
                                                <tr>
                                                    <td colspan=""6"" style=""text-align:center""><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bạn chưa chọn sản phẩm nào<br /><br /><br /></td>
                                                </tr>
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <th colspan=""4"">Tổng cộng</th>
                                                    <th>0 đ</th>
                                                </tr>
                                            </tfoot>
");
                        EndContext();
#line 183 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    }

#line default
#line hidden
                    BeginContext(8690, 389, true);
                    WriteLiteral(@"                                    </table>
                                </div>
                                <!-- /.table-responsive-->
                            </div>
                            <!-- /.content-->
                            <div class=""box-footer d-flex justify-content-between"">
                                <div>
                                    ");
                    EndContext();
                    BeginContext(9079, 149, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "1ecd83c885b0444dbfb1e3d3d319a935", async() => {
                        BeginContext(9162, 62, true);
                        WriteLiteral("<i class=\"fa fa-chevron-left\"></i>Quay lại thông tin giao hàng");
                        EndContext();
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_1.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(9228, 44, true);
                    WriteLiteral("\r\n\r\n                                </div>\r\n");
                    EndContext();
#line 194 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    if (Context.Session.Get <List <CartItem> >("GioHang") != null)
                    {
#line default
#line hidden
                        BeginContext(9401, 573, true);
                        WriteLiteral(@"                                    <div>
                                        <div>
                                            <a><input type=""radio"" id=""test1"" name=""colorRadio"" value=""cod""><label for=""test1"">Thanh toán khi nhận hàng &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>  </a>
                                            <a><input type=""radio"" id=""test2"" name=""colorRadio"" value=""paypal""><label for=""test2"">Thanh toán bằng Paypal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> </a>
                                        </div>
                                        ");
                        EndContext();
                        BeginContext(9974, 204, false);
                        __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "b2a876a6c64446dda7fbe3742e28df87", async() => {
                            BeginContext(10025, 149, true);
                            WriteLiteral("<button style=\"position:relative;left:28px;top:7px;\" type=\"submit\" class=\"cod box1 btn btn-primary\" onclick=\"myFunction()\">Xác nhận đặt hàng</button>");
                            EndContext();
                        }
                                                                                    );
                        __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                        __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                        __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_5.Value;
                        __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5);
                        __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_1.Value;
                        __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                        await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                        if (!__tagHelperExecutionContext.Output.IsContentModified)
                        {
                            await __tagHelperExecutionContext.SetOutputContentAsync();
                        }
                        Write(__tagHelperExecutionContext.Output);
                        __tagHelperExecutionContext = __tagHelperScopeManager.End();
                        EndContext();
                        BeginContext(10178, 50, true);
                        WriteLiteral("\r\n                                        </div>\r\n");
                        EndContext();
#line 203 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
                    }
                    else
                    {
                    }

#line default
#line hidden
                    BeginContext(10375, 60, true);
                    WriteLiteral("                            </div>\r\n                        ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Action = (string)__tagHelperAttribute_5.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Controller = (string)__tagHelperAttribute_1.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_6.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_6);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(10442, 26, true);
                WriteLiteral("\r\n                        ");
                EndContext();
                BeginContext(10468, 164, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "fa940c306c8d47498d897ec1db3ca1b6", async() => {
                    BeginContext(10525, 100, true);
                    WriteLiteral("\r\n                            <button type=\"submit\">PaypalPayment</button>\r\n                        ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Action = (string)__tagHelperAttribute_7.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_7);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Controller = (string)__tagHelperAttribute_8.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_8);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(10632, 2, true);
                WriteLiteral("\r\n");
                EndContext();
#line 214 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
            }
            else
            {
#line default
#line hidden
                BeginContext(10706, 32, true);
                WriteLiteral("                        <br />\r\n");
                EndContext();
                BeginContext(10740, 83, true);
                WriteLiteral("                        <div class=\"alert alert-danger\" style=\"text-align:center\"> ");
                EndContext();
                BeginContext(10823, 94, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "ec0e1db4bed04a94a708ba4877d551f8", async() => {
                    BeginContext(10874, 39, true);
                    WriteLiteral("Bạn cần đăng nhập để tiếp tục mua hàng ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_9.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_9);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_10.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_10);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(10917, 8, true);
                WriteLiteral("</div>\r\n");
                EndContext();
                BeginContext(10927, 109, true);
                WriteLiteral("                        <div class=\"box-footer d-flex justify-content-between\">\r\n                            ");
                EndContext();
                BeginContext(11036, 136, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a33109720d5e4b39ae836fd5d8b83493", async() => {
                    BeginContext(11117, 51, true);
                    WriteLiteral("<i class=\"fa fa-chevron-left\"></i>Quay lại giỏ hàng");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_11.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_11);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(11172, 34, true);
                WriteLiteral("\r\n                        </div>\r\n");
                EndContext();
#line 224 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
            }

#line default
#line hidden
            BeginContext(11229, 717, true);
            WriteLiteral(@"                </div>
                <!-- /.box-->
            </div>
            <!-- /.col-lg-9-->
            <div class=""col-lg-3"">
                <div id=""order-summary"" class=""card"">
                    <div class=""card-header"" style=""text-align:center"">
                        <h3 class=""mt-4 mb-4"">Thông tin hóa đơn</h3>
                    </div>
                    <div class=""card-body"">
                        <div class=""table-responsive"">
                            <table class=""table"">
                                <tbody>
                                    <tr>
                                        <td>Tổng tiền giỏ hàng</td>
                                        <th>");
            EndContext();
            BeginContext(11947, 22, false);
#line 240 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
            Write(tong.ToString("#,##0"));

#line default
#line hidden
            EndContext();
            BeginContext(11969, 618, true);
            WriteLiteral(@" đ</th>
                                    </tr>
                                    <tr>
                                        <td>Phí giao hàng</td>
                                        <th>Miễn phí</th>
                                    </tr>
                                    <tr>
                                        <td>Khuyến mãi</td>
                                        <th>0</th>
                                    </tr>
                                    <tr class=""total"">
                                        <td>Tổng cộng</td>
                                        <th>");
            EndContext();
            BeginContext(12588, 22, false);
#line 252 "C:\Users\DELL\Desktop\Obaju\WebOnline\Views\ThanhToan\ThanhToan1.cshtml"
            Write(tong.ToString("#,##0"));

#line default
#line hidden
            EndContext();
            BeginContext(12610, 304, true);
            WriteLiteral(@" đ</th>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.col-lg-3-->
        </div>
    </div>
</div>
");
            EndContext();
        }
コード例 #16
0
 public void ThemKhachHang(KhachHang khachhang)
 {
     dbContext.KhachHangs.InsertOnSubmit(khachhang);
     dbContext.SubmitChanges();
 }
コード例 #17
0
        public void ProsessOrder(ShippingDetailsViewModel shippingDetails, Cart cart)
        {
            var customer = context.KhachHangs.FirstOrDefault(x => x.Email == shippingDetails.Email);

            if (customer == null)
            {
                customer = new KhachHang()
                {
                    Ten     = shippingDetails.Ten,
                    Email   = shippingDetails.Email,
                    DiaChi  = shippingDetails.DiaChi,
                    SDT     = shippingDetails.SDT,
                    NoiDung = shippingDetails.NoiDung
                };
                context.KhachHangs.Add(customer);
            }
            else
            {
                customer.Ten    = shippingDetails.Ten;
                customer.DiaChi = shippingDetails.DiaChi;
                customer.SDT    = shippingDetails.SDT;
            }
            context.SaveChanges();

            DonHang order = new DonHang()
            {
                CreateDate = DateTime.Now,
                Status     = (int)Define.OrderStatus.ChoXacNhan,
                CustomerId = customer.CustomerID,
                ShipName   = customer.Ten,
                ShipAdress = customer.DiaChi,
                ShipEmail  = customer.Email,
                ShipMobile = customer.SDT
            };

            context.DonHangs.Add(order);
            context.SaveChanges();

            foreach (var item in cart.LineCollection)
            {
                ChiTietDonHang orderDetaisl = new ChiTietDonHang();
                if (item.Product.GiaKhuyenMai > 0)
                {
                    orderDetaisl.OrderId    = order.OrderId;
                    orderDetaisl.ProductId  = item.Product.ProductID;
                    orderDetaisl.Quantity   = item.Quantity;
                    orderDetaisl.Price      = item.Product.GiaKhuyenMai;
                    orderDetaisl.CreateDate = DateTime.Now;
                    orderDetaisl.CreateBy   = customer.Email;
                    orderDetaisl.Status     = (int)Define.OrderStatus.ChoXacNhan;
                }
                else
                {
                    orderDetaisl.OrderId    = order.OrderId;
                    orderDetaisl.ProductId  = item.Product.ProductID;
                    orderDetaisl.Quantity   = item.Quantity;
                    orderDetaisl.Price      = item.Product.Gia;
                    orderDetaisl.CreateDate = DateTime.Now;
                    orderDetaisl.CreateBy   = customer.Email;
                    orderDetaisl.Status     = (int)Define.OrderStatus.ChoXacNhan;
                }

                context.ChiTietDonHangs.Add(orderDetaisl);
            }
            context.SaveChanges();

            foreach (var item in cart.LineCollection)
            {
                var model = context.SanPhams.Where(x => x.ProductID == item.Product.ProductID).FirstOrDefault();
                model.SoLuong -= item.Quantity;
            }
            context.SaveChanges();
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<ol>");
            foreach (var line in cart.LineCollection)
            {
                if (line.Product.GiaKhuyenMai > 0)
                {
                    stringBuilder.Append("<li>");
                    stringBuilder.Append(line.Product.Ten);
                    stringBuilder.Append("<span>" + line.Quantity + "x" + line.Product.GiaKhuyenMai);
                    stringBuilder.Append("= " + line.Quantity * line.Product.GiaKhuyenMai);
                    stringBuilder.Append("</span>");
                }
                else
                {
                    stringBuilder.Append("<li>");
                    stringBuilder.Append(line.Product.Ten);
                    stringBuilder.Append("<span>" + line.Quantity + "x" + line.Product.Gia);
                    stringBuilder.Append("= " + line.Quantity * line.Product.Gia);
                    stringBuilder.Append("</span>");
                }
                stringBuilder.Append("</ol>");
                stringBuilder.Append("<h3>Tổng Tiền : <strong>" + cart.ComputerTotal() + "</strong></h3>");
            }
            EmailHelper emailHelper = new EmailHelper();

            emailHelper.Send(
                "Đơn Hàng" + order.OrderId,
                shippingDetails.Email,
                stringBuilder.ToString(),
                null,
                null);
        }
コード例 #18
0
        void LoadCustomers()
        {
            dgvWaBills.DataSource     = null;
            dgvWaPhoneBill.DataSource = null;

            using (var ctx = new PhoneStoreManageEntities())
            {
                var customer = from c in ctx.KhachHangs where c.SoDienThoai == txtWaPhoneNum.Text select c;
                try
                {
                    txtWaCustomer.Text = (from c in customer select c.TenKH).FirstOrDefault().ToString();
                    datWaBirth.Value   = (from c in customer select c.NgaySinh).FirstOrDefault().Value;
                    txtWaEmail.Text    = (from c in customer select c.Email).FirstOrDefault().ToString();
                    txtWaAdress.Text   = (from c in customer select c.DiaChi).FirstOrDefault().ToString();

                    if ((from c in customer select c.GioiTinh).FirstOrDefault().ToString() == "Nam")
                    {
                        radWaMale.Checked = true;
                    }
                    else
                    {
                        radWaFemale.Checked = true;
                    }


                    cusID = (from c in customer select c.MaKH).FirstOrDefault();
                    var bill = from b in ctx.HoaDons
                               where b.MaKH == cusID
                               select new
                    {
                        b.MaHD,
                        b.MaKH,
                        b.NhanVien.TenNV,
                        b.NgayMua,
                        b.HanBH,
                        b.Tongtien
                    };
                    dgvWaBills.DataSource            = bill.ToList();
                    dgvWaBills.Columns[0].HeaderText = "Mã HD";
                    dgvWaBills.Columns[1].HeaderText = "Mã KH";
                    dgvWaBills.Columns[2].HeaderText = "Nhân viên";
                    dgvWaBills.Columns[3].HeaderText = "Ngày mua";
                    dgvWaBills.Columns[4].HeaderText = "Hạn bảo hành";
                    dgvWaBills.Columns[5].HeaderText = "Tổng tiền";
                    dgvWaBills.Refresh();
                }
                catch
                {
                    txtWaCustomer.Text  = "";
                    datWaBirth.Value    = new DateTime(2000, 1, 1);
                    txtWaEmail.Text     = "";
                    txtWaAdress.Text    = "";
                    radWaMale.Checked   = false;
                    radWaFemale.Checked = false;

                    DialogResult answer = MessageBox.Show("Không tìn thấy khách hàng. Bạn có muốn tạo mới không?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (answer == DialogResult.Yes)
                    {
                        var lastCusID = (from cus in ctx.KhachHangs orderby cus.MaKH descending select cus.MaKH).FirstOrDefault();
                        var newCus    = new KhachHang {
                            MaKH = lastCusID + 1, SoDienThoai = txtWaPhoneNum.Text
                        };
                        cusID = lastCusID + 1;
                        ctx.KhachHangs.Add(newCus);
                        ctx.SaveChanges();
                    }
                }
            }
        }
コード例 #19
0
        public ActionResult Create(String radSelect, [Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] PHIEUDATPHONG tblPhieuDatPhong, [Bind(Include = "hoten,socmt,tuoi,sodt")] KhachHang kh)
        {
            System.Diagnostics.Debug.WriteLine("SS :" + radSelect);
            if (radSelect.Equals("rad2"))
            {
                tblPhieuDatPhong.MAKH = null;
                List <KhachHang> likh = new List <KhachHang>();
                likh.Add(kh);
                String ttkh = JsonConvert.SerializeObject(likh);
                tblPhieuDatPhong.THONGTINKHACHTHUE = ttkh;
            }

            tblPhieuDatPhong.TINHTRANGPHIEU = 1;
            tblPhieuDatPhong.NGAYVAO        = DateTime.Now;
            tblPhieuDatPhong.NGAYDAT        = DateTime.Now;
            db.PHIEUDATPHONGs.Add(tblPhieuDatPhong);
            db.SaveChanges();
            int ma = tblPhieuDatPhong.MAPHIEUDAT;

            return(RedirectToAction("Add", "HoaDon", new { id = ma }));

            // ViewBag.MAKH = new SelectList(db.KHACHHANGs, "MAKH", "MAKH", PHIEUDATPHONG.MAKH);
            // ViewBag.MAPHONG = new SelectList(db.PHONGs, "MAPHONG", "SOPHONG", PHIEUDATPHONG.MAPHONG);
            //ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
コード例 #20
0
ファイル: DangKy.cs プロジェクト: nhatkycon/Autodaily2013
        public override void KhoiTao(SqlConnection con, Page page)
        {
            var sb = new StringBuilder();
            var cs = page.ClientScript;
            var c = HttpContext.Current;
            #region bien
            var ID = Request["ID"];
            var TT_ID = Request["TT_ID"];
            var DV_ID = Request["DV_ID"];
            var Ma = Request["Ma"];
            var So = Request["So"];
            var KH_ID = Request["KH_ID"];
            var TuVanVien = Request["TuVanVien"];
            var Ngay = Request["Ngay"];
            var NgayTao = Request["NgayTao"];
            var NguoiTao = Request["NguoiTao"];
            var NgayCapNhat = Request["NgayCapNhat"];
            var NguoiCapNhat = Request["NguoiCapNhat"];
            var TinhTrangSucKhoe = Request["TinhTrangSucKhoe"];
            var TinhTrangLanDa = Request["TinhTrangLanDa"];
            var GhiChu = Request["GhiChu"];
            var YKienKhachHang = Request["YKienKhachHang"];
            var HieuQua = Request["HieuQua"];
            var PDV_ID = Request["PDV_ID"];
            var TuVanVienDanhGia = Request["TuVanVienDanhGia"];
            var KhongTheoDoi = Request["KhongTheoDoi"];
            var DichVuDieuTriKhac = Request["DichVuDieuTriKhac"];
            var KH_NguoiGioiThieu = Request["KH_NguoiGioiThieu"];

            var KH_Ma = Request["KH_Ma"];
            var Anh = Request["Anh"];
            var KH_Ten = Request["KH_Ten"];
            var KH_GioiTinh = Request["KH_GioiTinh"];
            var KH_NgaySinh = Request["KH_NgaySinh"];
            var KH_DiaChi = Request["KH_DiaChi"];
            var KH_KhuVuc_ID = Request["KH_KhuVuc_ID"];
            var KH_Phone = Request["KH_Phone"];
            var KH_Mobile = Request["KH_Mobile"];
            var KH_Ym = Request["KH_Ym"];
            var KH_CMND = Request["KH_CMND"];
            var KH_Email = Request["KH_Email"];
            var KH_NguonGoc_ID = Request["KH_NguonGoc_ID"];
            var LinhVuc_ID = Request["LinhVuc_ID"];
            #endregion
            switch (subAct)
            {
                case "draff":
                    #region draff
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(KhachHangDal.SelectDraff(con)));
                    break;
                    #endregion
                case "draffTuVan":
                    #region draffTuVan
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(TuVanDal.SelectDraff(con)));
                    break;
                    #endregion
                case "addTinhTrang":
                    #region addTinhTrang
                    if (!string.IsNullOrEmpty(ID))
                    {
                        var itemTuVanTinhTrang = TuVanTinhTrangDal.Insert(new TuVanTinhTrang()
                                                                            {
                                                                                ID = Guid.NewGuid()
                                                                                ,
                                                                                NgayTao = DateTime.Now
                                                                                ,
                                                                                TT_ID = new Guid(TT_ID)
                                                                                ,
                                                                                ThuTu = 0
                                                                                ,
                                                                                TV_ID = new Guid(ID)
                                                                            });
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(itemTuVanTinhTrang));
                    }

                    break;
                    #endregion
                case "delTinhTrang":
                    #region delTinhTrang
                    TuVanTinhTrangDal.DeleteById(new Guid(TT_ID));
                    break;
                    #endregion
                case "delDichVu":
                    #region delDichVu
                    RelationDal.DeleteByCidPid(DV_ID, ID);
                    break;
                    #endregion
                case "getAlbum":
                    #region getAlbum
                    var slideIndex = 0;
                    var anhFsFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "AlbumMgr.anh-dich-vu-full.htm");
                    foreach (var anh in FilesDal.SelectByPRowId(new Guid(ID)))
                    {
                        sb.AppendFormat(anhFsFormat, slideIndex == 0 ? "block" : "none", domain, Lib.imgSize(anh.Path, "full"), anh.ThuMuc);
                        slideIndex++;
                    }
                    break;
                    #endregion
                case "save":
                    #region save
                    if(!string.IsNullOrEmpty(KH_Ten))
                    {
                        var khItem = new KhachHang();
                        khItem.CMND = KH_CMND;
                        khItem.DanhGia = 0;
                        khItem.DiaChi = KH_DiaChi;
                        khItem.Email = KH_Email;
                        khItem.FacebookUid = string.Empty;
                        khItem.GioiTinh = Convert.ToBoolean(KH_GioiTinh);
                        if (!string.IsNullOrEmpty(KH_KhuVuc_ID))
                        {
                            khItem.KhuVuc_ID = new Guid(KH_KhuVuc_ID);
                        }
                        khItem.ID = Guid.NewGuid();
                        khItem.Ma = KH_Ma;
                        khItem.Mobile = KH_Mobile;
                        khItem.NgayCapNhat = DateTime.Now;
                        khItem.NgaySinh = Convert.ToDateTime(KH_NgaySinh, new CultureInfo("vi-Vn"));
                        khItem.NguoiCapNhat = Security.Username;
                        khItem.NguoiTao = Security.Username;
                        if (!string.IsNullOrEmpty(LinhVuc_ID))
                        {
                            khItem.LinhVuc_ID = new Guid(LinhVuc_ID);
                        }
                        khItem.TuVanVien = TuVanVien;
                        if (!string.IsNullOrEmpty(KH_NguonGoc_ID))
                        {
                            khItem.NguonGoc_ID = new Guid(KH_NguonGoc_ID);
                        }
                        if (!string.IsNullOrEmpty(KH_NguoiGioiThieu))
                        {
                            khItem.NguoiGioiThieu = new Guid(KH_NguoiGioiThieu);
                        }
                        khItem.Phone = KH_Phone;
                        khItem.Ten = KH_Ten;
                        khItem.Ym = KH_Ym;
                        khItem.NgayTao = DateTime.Now;
                        khItem.Anh = Anh;
                        khItem = KhachHangDal.Insert(khItem);
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(khItem));
                    }
                    break;
                    #endregion
                case "editTuVan":
                    #region editTuVan
                    var itemEditTuvan = TuVanDal.SelectById(new Guid(ID));
                    itemEditTuvan._TuVanTinhTrang = TuVanTinhTrangDal.SelectByTvId(ID);
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(itemEditTuvan));
                    break;
                    #endregion
                case "saveTuVan":
                    #region saveTuVan
                    if (!string.IsNullOrEmpty(So))
                    {
                        var tvItem = new TuVan();
                        tvItem.ID = new Guid(ID);
                        tvItem.DichVuDieuTriKhac = DichVuDieuTriKhac;
                        tvItem.GhiChu = GhiChu;
                        tvItem.HieuQua = false;
                        tvItem.KH_ID = new Guid(KH_ID);
                        tvItem.Ma = Ma;
                        tvItem.Ngay = Convert.ToDateTime(Ngay, new CultureInfo("vi-Vn"));
                        tvItem.NgayCapNhat = DateTime.Now;
                        tvItem.NgayTao = DateTime.Now;
                        tvItem.NguoiCapNhat = Security.Username;
                        tvItem.NguoiTao = Security.Username;
                        tvItem.So = So;
                        tvItem.TinhTrangLanDa = TinhTrangLanDa;
                        tvItem.TinhTrangSucKhoe = TinhTrangSucKhoe;
                        tvItem.TuVanVien = TuVanVien;
                        tvItem.YKienKhachHang = YKienKhachHang;
                        tvItem = TuVanDal.Insert(tvItem);
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(tvItem));
                    }
                    break;
                    #endregion
                case "reports":
                    #region bao cao
                    var itemTuVanRpt = new List<TuVan>();
                    itemTuVanRpt.Add(TuVanDal.SelectById(new Guid(ID)));
                    var listKh = new List<KhachHang>();
                    listKh.Add(KhachHangDal.SelectById(itemTuVanRpt[0].KH_ID));
                    RenderReport(itemTuVanRpt, listKh, DanhMucDal.SelectByTvId(ID).ToList(), "WORD", "Báo cáo", DateTime.Now.ToString("dd-mm-yy"));
                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(DangKy), "appStore.pmSpa.desktop.controls.KHang.DangKy.js"));
                    break;
                    #endregion
                case "print":
                    #region Nạp js
                    if(!string.IsNullOrEmpty(ID))
                    {
                        var tvItem = TuVanDal.SelectById(new Guid(ID));
                        var khItem = KhachHangDal.SelectById(tvItem.KH_ID);
                        var memItem = MemberDal.SelectByUser(tvItem.TuVanVien);
                        var printFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "KHang.TuVan-In.htm");
                        var ttFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "KHang.TuVan-In-TinhTrang-Item.htm");
                        var dvFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "KHang.TuVan-In-DichVu-Item.htm");

                        var sbTinhTrang = new StringBuilder();
                        var sbDichVu = new StringBuilder();
                        var tinhTrangItem = new DanhMuc();
                        var dichVuItem = new TinhTrangDichVu();
                        foreach (var rel in RelationDal.SelectByPid(tvItem.ID.ToString()))
                        {
                            tinhTrangItem = DanhMucDal.SelectById(rel.CID);
                            sbDichVu=new StringBuilder();
                            foreach (var itemdv in TinhTrangDichVuDal.SelectDmId(rel.CID.ToString()))
                            {
                                sbDichVu.AppendFormat(dvFormat
                                   , itemdv.dvu.Ma
                                   , itemdv.dvu.Ten
                                   , itemdv.dvu.SoLan
                                   , itemdv.dvu.ThoiGian
                                   , string.Format(new CultureInfo("vi-Vn"), "{0:c}", itemdv.dvu.Gia).Replace(",00 ₫", ""));
                            }
                            sbTinhTrang.AppendFormat(ttFormat, tinhTrangItem.Ten, sbDichVu);
                        }

                        sb.AppendFormat(printFormat
                                        , cs.GetWebResourceUrl(typeof (DangKy),"appStore.pmSpa.desktop.controls.KHang.start-up.png")
                                        , khItem.Ma
                                        , string.Empty
                                        , tvItem.So
                                        , tvItem.NgayTao.ToString("dd/MM/yy")
                                        , memItem.Ten
                                        , khItem.Ten
                                        , khItem.GioiTinh ? "Nữ" : "Nam"
                                        , khItem.NgaySinh.ToString("dd/MM/yy")
                                        , khItem.DiaChi
                                        , khItem.KhuVuc_Ten
                                        , khItem.Phone
                                        , khItem.Mobile
                                        , khItem.Ym
                                        , khItem.CMND
                                        , khItem.Email
                                        , khItem.NguonGoc_Ten
                                        , tvItem.TinhTrangSucKhoe
                                        , tvItem.TinhTrangLanDa
                                        , tvItem.YKienKhachHang
                                        , sbTinhTrang
                                        , tvItem.DichVuDieuTriKhac
                                        , cs.GetWebResourceUrl(typeof(DangKy), "appStore.pmSpa.desktop.controls.KHang.Print.css"));
                    }
                    break;
                    #endregion
                default:
                    #region nạp
                    var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                    sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "KHang.TuVan.htm"));
                    sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                        , cs.GetWebResourceUrl(typeof(DangKy), "appStore.pmSpa.desktop.controls.KHang.DangKy.js")
                        , "{danhMucDichVuMgr.loadgrid();}");
                    sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn));
                    break;
                    #endregion
            }

            Html = sb.ToString();
            base.KhoiTao(con);
        }
コード例 #21
0
 public void sua(KhachHang kh)
 {
     dalKH.suaKhachHang(kh);
 }
コード例 #22
0
 public void them(KhachHang kh)
 {
     dalKH.themKhachHang(kh);
 }
コード例 #23
0
 public void xoa(KhachHang kh)
 {
     dalKH.xoaKhachHang(kh);
 }
コード例 #24
0
        public ActionResult StepEnd()
        {
            //Nhận dữ liệu trên form từ trang index
            string DienThoai = Request.Form["DienThoai"];
            string HoTenKH   = Request.Form["HoTenKH"];
            string EmailKH   = Request.Form["EmailKH"];
            string DiaChiKH  = Request.Form["DiaChiKH"];
            string note      = Request.Form["note"];
            //kiểm tra xem có customer chưa và cập nhật lại
            KhachHang newCus = new KhachHang();
            var       cus    = db.KhachHangs.FirstOrDefault(p => p.DienThoai.Equals(DienThoai));

            if (cus != null)
            {
                //nếu có số điện thoại trong db rồi
                //cập nhật thông tin và lưu
                cus.HoTenKH  = HoTenKH;
                cus.EmailKH  = EmailKH;
                cus.DiaChiKH = DiaChiKH;
                uDB.UpdateKhachHang(cus);
            }
            else
            {
                //nếu chưa có sđt trong db
                //thêm thông tin và lưu
                newCus.DienThoai = DienThoai;
                newCus.HoTenKH   = HoTenKH;
                newCus.EmailKH   = EmailKH;
                newCus.DiaChiKH  = DiaChiKH;
                uDB.ThemKhachHang(newCus);
            }
            //Thêm thông tin vào order và orderdetail
            List <CartItem> giohang = Session["giohang"] as List <CartItem>;
            //thêm order mới
            HoaDon newOrder   = new HoaDon();
            string newIDOrder = (Int32.Parse(db.HoaDons.OrderByDescending(p => p.MaHD).FirstOrDefault().MaHD.Replace("HD", "")) + 1).ToString();

            newOrder.MaHD      = "HD" + newIDOrder;
            newOrder.DienThoai = DienThoai;
            newOrder.GhiChu    = note;
            uDB.ThemHoaDon(newOrder);
            //thêm details

            for (int i = 0; i < giohang.Count; i++)
            {
                ChiTietHD newOrdts = new ChiTietHD();
                newOrdts.MaHD     = newOrder.MaHD;
                newOrdts.MaSP     = giohang.ElementAtOrDefault(i).SanPhamID;
                newOrdts.TenSP    = giohang.ElementAtOrDefault(i).TenSanPham;
                newOrdts.DonGia   = giohang.ElementAtOrDefault(i).DonGia;
                newOrdts.SoLuong  = giohang.ElementAtOrDefault(i).SoLuong;
                newOrdts.TongCong = giohang.ElementAtOrDefault(i).ThanhTien;
                uDB.ThemChiTietHD(newOrdts);
                uDB.CapNhatToTalHoaDon(newOrdts.MaHD);
            }

            Session["MHD"]   = "HD" + newIDOrder;
            Session["Phone"] = DienThoai;
            //xoá sạch giỏ hàng
            giohang.Clear();
            return(RedirectToAction("HoaDon", "ThanhToan"));
        }
コード例 #25
0
        public ActionResult Register(string TenKhachHang, string Email, string TaiKhoanDangNhap, string MatKhau,
                                     string pass,
                                     string DiaChi, string SoDienThoai, int Gender, string NgaySinh)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (_db.TaiKhoans.Find(TaiKhoanDangNhap) != null)
                    {
                        throw new Exception("Tài khoản này đã được đăng kí ! Vui lòng chọn tên đăng nhập khác");
                    }

                    if (string.IsNullOrEmpty(TaiKhoanDangNhap))
                    {
                        throw new Exception("Lỗi Tài khoản đăng nhập");
                    }

                    if (string.IsNullOrEmpty(TenKhachHang))
                    {
                        throw new Exception("Lỗi Tên khách hàng");
                    }

                    if (!SoDienThoai.ValidatePhoneNumber(true))
                    {
                        throw new Exception("Số điện thoại không hợp lệ");
                    }

                    if (!ValidationFunction.IsValidEmail(Email))
                    {
                        throw new Exception("Email không hợp lệ");
                    }

                    if (!ValidationFunction.IsValidPassword(MatKhau))
                    {
                        throw new Exception(
                                  "Mật khẩu không hợp lệ ! Hãy nhập ít nhất 1 chữ số , một chữ cái viết hoa , dài ít nhất 8 kí tự");
                    }

                    if (string.Compare(MatKhau, pass) != 0)
                    {
                        throw new Exception("Hãy nhập mật khẩu khớp nhau");
                    }


                    if (Gender > 1 || Gender < 0)
                    {
                        throw new Exception("Lỗi thông tin giới tính");
                    }

                    try
                    {
                        DateTime.Parse(NgaySinh);
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.Message);
                    }
                }
                catch (Exception e)
                {
                    Response.StatusCode = 400;
                    return(Json(new { msg = e.Message }, JsonRequestBehavior.AllowGet));
                }

                var identity = _db.IdentityTraces.Find(1);

                identity.KhachHangIdentity++;
                var khachHang = new KhachHang
                {
                    MaKhachHang     = "KHACHHANG" + identity.KhachHangIdentity.ToString("00"),
                    Email           = Email,
                    Ten             = TenKhachHang,
                    DiaChi          = DiaChi,
                    GioiTinh        = Gender == 1 ? true : false,
                    MaLoaiKhachHang = "KHACHHANGTHUONG",
                    NgaySinh        = DateTime.Parse(NgaySinh),
                    ThoiGianDangKi  = DateTime.Now,
                    SoDienThoai     = SoDienThoai
                };
                _db.KhachHangs.Add(khachHang);
                _db.SaveChanges();

                var taiKhoan = new TaiKhoan
                {
                    MaTaiKhoan       = khachHang.MaKhachHang,
                    TaiKhoanDangNhap = TaiKhoanDangNhap,
                    MatKhau          = MatKhau
                };

                _db.TaiKhoans.Add(taiKhoan);
                _db.SaveChanges();

                Response.StatusCode = 200;
                return(Json(new { msg = "Thành Công" }, JsonRequestBehavior.AllowGet));
            }

            Response.StatusCode = 400;
            return(Json(new { msg = "Lỗi ! Hãy Thử trong vài giây nữa" }, JsonRequestBehavior.AllowGet));
        }
コード例 #26
0
 public ActionResult Profile(KhachHang khachhang)
 {
     return(View(khachhang));
 }
コード例 #27
0
        //  public async Task<IActionResult> DangNhap(LoginViewModel model)
        public ActionResult DangNhap(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                KhachHang kh = db.KhachHang.SingleOrDefault(p => p.MaKh == model.MaKh && /*p.MatKhau==model.MatKhau);*/
                                                            passwordHasher.VerifyHashedPassword(p.MatKhau, model.MatKhau) == PasswordVerificationResult.Success);
                if (kh == null)
                {
                    ModelState.AddModelError("Loi", "Thông tin tài khoản hoặc mật khẩu không hợp lệ.");
                    return(View("Index"));
                }
                else
                {
                    HttpContext.Session.Set("TaiKhoan", kh);
                    return(RedirectToAction("Index", "Home"));

                    #region try catch

                    /*try
                     *
                     *
                     * {
                     *  //HttpContext.Session.Set("TaiKhoan", kh);
                     *  //return RedirectToAction("Index", "Home");
                     *  if (kh != null && !string.IsNullOrEmpty(kh.AuthyId))
                     *  {
                     *      phonenum = kh.DienThoai;
                     *      var sendSMSResponse = await _authy.SendSmsAsync(kh.AuthyId).ConfigureAwait(false);
                     *
                     *      if (sendSMSResponse.StatusCode == HttpStatusCode.OK)
                     *      {
                     *          var smsVerificationSucceedObject = JsonConvert.DeserializeObject<AccessCodeVerifyResult>(await sendSMSResponse.Content.ReadAsStringAsync());
                     *          if (smsVerificationSucceedObject.Success)
                     *          {
                     *              //Send SMS success
                     *              return View("XacMinhDangNhap");
                     *              throw new UserDefException($"Gửi token thành công tới {phonenum}");
                     *
                     *          }
                     *          else
                     *          {
                     *              //Fail
                     *              throw new UserDefException($"Có lỗi gửi tin nhắn tới {phonenum}");
                     *          }
                     *      }
                     *  }
                     *  else
                     *      throw new UserDefException($"Không có khách hàng nào có điện thoại: {phonenum}");
                     * }
                     * catch (UserDefException e)
                     * {
                     *  ViewBag.Result = e.Message;
                     * }
                     * catch (Exception e)
                     * {
                     *   ViewBag.Result = e.Message;
                     * }*/
                    #endregion
                }
            }
            return(View("Index"));
        }
コード例 #28
0
        //
        // GET: /Agent/Create

        public ActionResult Create()
        {
            var model = new KhachHang();
            return View(model);
        } 
コード例 #29
0
        public async Task <IActionResult> CreateAccount([FromBody] CreateAccountCustomerCommand command)
        {
            try
            {
                if (command.password != command.password_confirm)
                {
                    return(BadRequest(new
                    {
                        error = "The password comfirm is not the same as The password"
                    }));
                }
                else
                {
                    // password Length of password is >= 8 and any character is number and any character is upper and case better to have a special then Symbol
                    var expectedPasswordPattern = new Regex(@"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$");

                    var isValidPassword = expectedPasswordPattern.IsMatch(command.password);


                    if (isValidPassword == true)
                    {
                        // Get account by email
                        Account account = new Account();
                        account = await accountRepository.Get(w => w.email == command.email);


                        if (account != null)
                        {
                            return(BadRequest(new
                            {
                                code = 400,
                                error = "Email is exist"
                            }));
                        }
                        else
                        {
                            Account   account_new = new Account();
                            KhachHang kh          = new KhachHang();
                            // Add new customer

                            kh.ten_kh = command.ten_kh;
                            kh.sdt    = command.sdt;
                            await khachHangRepository.Create_v(kh);

                            // Add account
                            account_new.email      = command.email;
                            account_new.password   = HashHelper.Hash(command.password);
                            account_new.ma_kh      = kh.ma_kh;
                            account_new.rolecode   = 1;
                            account_new.createtime = DateTime.Now;

                            //try
                            //{
                            await accountRepository.Create_v(account_new);

                            return(Ok(new
                            {
                                code = 200,
                                success = "register is success"
                            }));
                            //}
                            //catch (Exception e)
                            //{
                            //    return BadRequest(new
                            //    {
                            //        error = "Add account fail -  " + e.InnerException.Message
                            //    });
                            //}
                        }
                    }
                    else
                    {
                        return(BadRequest(new
                        {
                            code = 404,
                            error = "password Length of password is >= 8 and any character is number and any character is upper and case better to have a special then Symbol"
                        }));
                    }
                }
            }
            catch (NullReferenceException e)
            {
                return(BadRequest(new
                {
                    code = 400,
                    error = e.InnerException.Message
                }));
            }
        }
コード例 #30
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            if (lbltongcong.Text == "")
            {
                MessageBox.Show("Bạn chưa bấm Tổng Cộng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                bool check = KhachHangDAO.Instance.checkKHCSDL(txbsdt.Text); // Check xem Kh da ton tai trong csdl chua
                if (check == false)
                {
                    //Tạo khách hàng, và thêm khách hàng vào CSDL
                    KhachHang kh = new KhachHang(txbName.Text, txbdiachi.Text, txbsdt.Text, txblinkfacebook.Text);
                    KhachHangDAO.Instance.LoadKHLenCSDL(kh);
                    //Tạo hóa đơn và lấy id hóa đơn, để gán vào thông tin hóa đơn, thêm hóa đơn vào CSDL
                    Hoadon hd = new Hoadon(0, DateTime.Now, txbsdt.Text, "Chưa Giao Hàng", double.Parse(lbltongcong.Text));
                    HoaDonDAO.Instance.LoadHoaDonLenCSDL(hd);
                    //Xử lý thêm thông tin hóa đơn
                    foreach (ListViewItem item in lsvhoadon.Items)
                    {
                        // Bước 1: Lấy id sản phẩm
                        int idhd1 = HoaDonDAO.Instance.GetidhdbySDTanddate(txbsdt.Text, DateTime.Now);
                        int idsp  = SanPhamDAO.Instance.getIdbyNameAndColor(item.SubItems[3].Text, item.SubItems[4].Text);

                        ThongTinHoaDon tthd = new ThongTinHoaDon(idhd1, idsp, int.Parse(item.SubItems[5].Text));
                        ThongTinHDDAO.Instance.LoadTTHDtoCSDL(tthd);
                    }
                    MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // Tạo hóa đơn và lấy id hóa đơn, để gán vào thông tin hóa đơn, thêm hóa đơn vào CSDL


                    Hoadon hd = new Hoadon(0, DateTime.Now, txbsdt.Text, "Chưa Giao Hàng", double.Parse(lbltongcong.Text));
                    HoaDonDAO.Instance.LoadHoaDonLenCSDL(hd);
                    // Xử lý thêm thông tin hóa đơn

                    foreach (ListViewItem item in lsvhoadon.Items)
                    {
                        // Bước 1: Lấy id sản phẩm
                        int idhd1 = HoaDonDAO.Instance.GetidhdbySDTanddate(txbsdt.Text, DateTime.Now);
                        int idsp  = SanPhamDAO.Instance.getIdbyNameAndColor(item.SubItems[3].Text, item.SubItems[4].Text);

                        ThongTinHoaDon tthd = new ThongTinHoaDon(idhd1, idsp, int.Parse(item.SubItems[5].Text));
                        ThongTinHDDAO.Instance.LoadTTHDtoCSDL(tthd);
                    }
                    // Cuối cùng, xóa hết dữ liệu, để nhập dữ liệu mới
                    MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                txbName.Clear();
                txbdiachi.Clear();
                txbsdt.Clear();
                nmtongtien.Value = 0;
                txbName.Focus();
                cbbsanpham.SelectedIndex = 0;
                nmsanpham.Value          = 1;
                lbltongcong.Text         = "";
                lsvhoadon.Items.Clear();
            }
        }
コード例 #31
0
        public IActionResult HoaDonTV(string ghichu)
        {
            KhachHang kh = HttpContext.Session.Get <KhachHang>("Username");
            HoaDon    hd = new HoaDon
            {
                MaKh                = kh.MaKh,
                HoTen               = kh.HoTen,
                DiaChi              = kh.DiaChi,
                GhiChu              = ghichu,
                NgayDat             = DateTime.Now,
                MaTrangThai         = 0,
                PhuongThucThanhToan = 0,
                TinhTrangThanhToan  = 0,
                PhiVanChuyen        = 0
            };

            db.HoaDon.Add(hd);
            double tongtien   = 0;
            double tonghoadon = 0;

            foreach (var i in Carts)
            {
                tongtien = tongtien + i.ThanhTien;
                HangHoa hh = db.HangHoa.SingleOrDefault(p => p.MaHh == i.MaHh);

                ChiTietHd cthd = new ChiTietHd
                {
                    MaHd    = hd.MaHd,
                    MaHh    = i.MaHh,
                    DonGia  = hh.DonGia,
                    GiamGia = hh.GiamGia,
                    SoLuong = i.SoLuong
                };
                db.ChiTietHd.Add(cthd);
                db.SaveChanges();


                if (hh.SoLuong >= cthd.SoLuong)
                {
                    hh.SoLuong = hh.SoLuong - cthd.SoLuong;
                }
                else
                {
                    HangHoa hanghoa = db.HangHoa.SingleOrDefault(p => p.MaHh == cthd.MaHh);
                    string  hethang = "Mặt hàng " + hanghoa.TenHh + " Chỉ còn : " + hh.SoLuong + " sản phẩm";
                    HttpContext.Session.Set("HetHang", hethang);
                    db.ChiTietHd.Remove(cthd);
                    db.HoaDon.Remove(hd);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            tonghoadon      = tongtien + 0;
            hd.TongTienHang = tongtien;
            hd.TongThucThu  = tonghoadon;
            db.SaveChanges();
            HttpContext.Session.Set <string>("OrderSuccess", "Đơn hàng của bạn đã được đặt thành công.");
            //ViewBag.OrderSuccess = true;
            HttpContext.Session.Remove("GioHang");


            return(RedirectToAction("Index"));
        }
コード例 #32
0
        // dat hang

        public ActionResult DatHang(KhachHang kh)
        {
            // kiem tra gio hang
            if (Session["GioHang"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            KhachHang khachhang = new KhachHang();

            if (Session["taikhoan"] == null)
            {
                khachhang = kh;
                db.KhachHangs.Add(khachhang);
                db.SaveChanges();
            }
            else
            {
                ThanhVien tv = Session["taikhoan"] as ThanhVien;
                khachhang = new KhachHang();

                khachhang.TenKH       = tv.HoTen;
                khachhang.DiaChi      = tv.DiaChi;
                khachhang.SoDienThoai = tv.SoDienThoai;
                khachhang.Email       = tv.Email;

                db.KhachHangs.Add(khachhang);
                db.SaveChanges();
            }
            // them don dat hang
            DonDatHang ddh = new DonDatHang();

            ddh.MaKH        = khachhang.MaKH;
            ddh.NgayDat     = DateTime.Now;
            ddh.TinhTrang   = false;
            ddh.DaThanhToan = false;
            ddh.UuDai       = 0;
            ddh.DaHuy       = false;
            ddh.DaXoa       = false;
            db.DonDatHangs.Add(ddh);
            db.SaveChanges();

            // them chi tiet don dat hang

            List <GioHang> lstGioHang = LayGioHang();

            foreach (var item in lstGioHang)
            {
                ChiTietDonDatHang ctddh = new ChiTietDonDatHang();
                ctddh.MaDDH   = ddh.MaDDH;
                ctddh.MaSP    = item.MaSP;
                ctddh.TenSP   = item.TenSP;
                ctddh.SoLuong = item.Soluong;
                ctddh.DonGia  = item.Dongia;

                db.ChiTietDonDatHangs.Add(ctddh);
            }

            db.SaveChanges();

            Session["GioHang"] = null;
            return(RedirectToAction("XemGioHang", "GioHang"));
        }
コード例 #33
0
 private void Frm_onAdd(KhachHang khachhang)
 {
     thongtinkhachhang.Insert(khachhang);
     ReloadData();
 }
コード例 #34
0
 public bool ThemKH(KhachHang khachhangMoi)
 {
     return(khContext.ThemKH(khachhangMoi));
 }
コード例 #35
0
 //Thêm dữ liệu
 public void ThemDuLieu(KhachHang et)
 {
     cn.ThemDuLieu(et);
 }
コード例 #36
0
        public ActionResult ConvertListDH(int[] data, int TrangThai, bool TrangThaiThanhToan)
        {
            bool Check = Permission("DonHang", "Submit");

            if (Check == true)
            {
                for (int i = 0; i < data.Length; i++)
                {
                    int    MaDB = data[i];
                    DonBan dh   = db.DonBans.Find(MaDB);
                    int    MaKH = dh.MaKH;
                    dh.TrangThai          = TrangThai;
                    dh.TrangThaiThanhToan = TrangThaiThanhToan;
                    db.Entry(dh).State    = EntityState.Modified;

                    var ListCTDH = db.ChiTietDonBans.Where(s => s.MaDB == MaDB).ToList();
                    if (ListCTDH != null)
                    {
                        foreach (var item in ListCTDH)
                        {
                            ChiTietDonBan CTDB = db.ChiTietDonBans.Find(item.MaCTDB);
                            CTDB.TrangThai          = TrangThai;
                            CTDB.TrangThaiThanhToan = TrangThaiThanhToan;
                            db.Entry(CTDB).State    = EntityState.Modified;
                        }
                    }
                    if (TrangThai == 1)
                    {
                        #region Gửi mail
                        int         j   = 1;
                        CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN");

                        string    TongTien = dh.TongTien.Value.ToString("#,###", cul.NumberFormat);
                        string    PhiShip  = dh.PhiShip.ToString("#,###", cul.NumberFormat);
                        KhachHang kh       = db.KhachHangs.Find(MaKH);
                        ThanhPho  TP       = db.ThanhPhos.Find(kh.MaThanhPho);
                        Huyen     huyen    = db.Huyens.Find(kh.MaHuyen);

                        var ListCTDB1 = db.ChiTietDonBans.Include(s => s.SANPHAM).Where(s => s.MaDB == MaDB).ToList();

                        var Body = "";
                        Body += " <html>";
                        Body += "<body>";

                        Body += "<p style='font-weight:bold'>Họ và tên:" + "<span style='font-weight:lighter;'>" + " " + kh.TenKH + "</span>" + "</p>";
                        Body += "<p style='font-weight:bold'>Địa chỉ:" + "<span style='font-weight:lighter;'>" + " " + kh.DiaChi + " - " + huyen.TenHuyen + " - " + TP.TenThanhPho + "</span>" + "</p>";
                        Body += "<p style='font-weight:bold'>Số điện thoại:" + "<span style='font-weight:lighter;'>" + " " + 0 + "" + kh.SDT + "</span>" + "</p>";

                        Body += "<table border='1' width='1000' class='table table-striped table-bordered table-hover'>";
                        Body += "<tr  style='text-align:center' class='success'>";
                        Body += "<td colspan='5'><h3>Đơn hàng của bạn từ Rượu plaza</h3> </td>";
                        Body += "</tr>";

                        Body += "<tr  style='text-align:center'>";
                        Body += "<td>STT</td> <td> Tên sản phẩm </td><td> Số lượng </td><td> Đơn giá </td> <td> Thành tiền</td>";
                        Body += "<tr >";

                        foreach (var item in ListCTDB1)
                        {
                            string GiaBan = item.SANPHAM.GiaBan.Value.ToString("#,###", cul.NumberFormat);
                            string Monney = (item.SoLuong.Value * item.SANPHAM.GiaBan.Value).ToString("#,###", cul.NumberFormat);

                            Body += "<tr >";
                            Body += "<td style='text-align:center;'> " + (j++) + "</td>" + "<td  style='text-align:left;'> " + "<p style='margin-left:20px;font-weight:bold'>" + item.SANPHAM.TenSP + "</p>" + "</td>" + "<td style='text-align:center;color:red'> " + item.SoLuong + "</td>" + "<td style='text-align:center;color:red'> " + GiaBan + "</td>" + "<td style='text-align:center;color:red'> " + Monney + "</td>";
                            Body += "<tr >";
                        }

                        Body += "</table>";
                        Body += "<p style='font-weight:bold'>Phí ship:" + "<span style='font-weight:lighter;color:red'>" + " " + PhiShip + " " + "₫" + "</span>" + "</p>";
                        Body += "<p style='font-weight:bold'>Tổng tiền:" + "<span style='font-weight:lighter;color:red'>" + " " + TongTien + " " + "₫" + "</span>" + "</p>";
                        Body += "<p>Đơn hàng của bạn đã được xử lý.Trong vòng 1 tuần đơn hàng sẽ đến địa chỉ của bạn mong bạn hãy kiểm tra sản phẩm trước khi thanh toán.Cảm ơn bạn rất nhiều chúc bạn có một ngày mới vui vẻ <3 !!!</p>";
                        Body += "</body>";
                        Body += "</html>";

                        #endregion
                        var Mail = SendMail(Body, kh.Gmail);
                    }
                }
                db.SaveChanges();
                messenger.IsSuccess = true;
                messenger.Message   = "Cập nhập thành công!!!";
                return(Content(JsonConvert.SerializeObject(new
                {
                    messenger,
                })));
            }
            else
            {
                messenger.IsSuccess        = false;
                messenger.RedirectToAction = true;
                messenger.Message          = "Thêm sản phẩm thất bại!!!";
                return(Content(JsonConvert.SerializeObject(new
                {
                    messenger,
                })));
            }
        }
コード例 #37
0
 //Sửa dữ liệu
 public void SuaDuLieu(KhachHang et)
 {
     cn.SuaDuLieu(et);
 }
コード例 #38
0
ファイル: UserController.cs プロジェクト: xxhhmxx/Web-Service
 public ActionResult Register(KhachHang kh)
 {
     try
     {
         if (ModelState.IsValid)
         {
             string pass = Helper.Encryptor.MD5Hash(kh.MatKhau);
             kh.PerId = 1;
             kh.MatKhau = pass;
             bool i = khachHang.AddUser(kh);
             if (i)
             {
                 return RedirectToAction("Index", "Home");
             }
             else
             {
                 ModelState.AddModelError("", "Đăng ký không thành công");
             }
         }
         return View(kh);
     }
     catch
     {
         return View();
     }
 }
コード例 #39
0
 //Xóa dữ liệu
 public void XoaDuLieu(KhachHang et)
 {
     cn.XoaDuLieu(et);
 }
コード例 #40
0
ファイル: UserController.cs プロジェクト: xxhhmxx/Web-Service
        public ActionResult FacebookCallback(string code)
        {
            var fb = new FacebookClient();
            dynamic result = fb.Post("oauth/access_token", new
            {
                client_id = ConfigurationManager.AppSettings["LoginId"],
                client_secret = ConfigurationManager.AppSettings["LoginSec"],
                redirect_uri = RedirectUri.AbsoluteUri,
                code = code
            });

            var access_token = result.access_token;
            if (!string.IsNullOrEmpty(access_token))
            {
                fb.AccessToken = access_token;
                dynamic me = fb.Get("me?fields=first_name,middle_name,last_name,id,email");
                string email = me.email;
                string username = me.email;
                string firstname = me.first_name;
                string middlename = me.middle_name;
                string lastname = me.last_name;

                var kh = new KhachHang();
                kh.Email = email;
                kh.TenDangNhap = username;
                kh.MatKhau = "123";
                kh.Ten = lastname + middlename + firstname;
                kh.PerId = 1;
                kh.SoDienThoai = "";
                kh.DiaChi = "";
                Session["LogedName"] = username;
                var check = khachHang.AddUserForFacebook(kh);
            }
            return RedirectToAction("Index", "Home");
        }
コード例 #41
0
 public int InsertData(KhachHang KH)
 {
     return(da.InsertData(KH));
 }
コード例 #42
0
ファイル: KhachHangBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Delete(KhachHang data, User user)
 {
     return KhachHangDao.Delete(data, user);
 }
コード例 #43
0
 public int UpdateData(KhachHang KH)
 {
     return(da.UpdateData(KH));
 }
コード例 #44
0
ファイル: KhachHangBus.cs プロジェクト: vuchannguyen/lg-py
 public static bool Update(KhachHang data, User user)
 {
     return KhachHangDao.Update(data, user);
 }
コード例 #45
0
        private void FormLapHoaDon_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'sanPham_FormLapHoaDon.SanPham' table. You can move, or remove it, as needed.
            this.sanPhamTableAdapter.Fill(this.sanPham_FormLapHoaDon.SanPham);
            // TODO: This line of code loads data into the 'mauSac_FormLapHoaDon.MauSac' table. You can move, or remove it, as needed.
            this.mauSacTableAdapter.Fill(this.mauSac_FormLapHoaDon.MauSac);
            // TODO: This line of code loads data into the 'size_FormLapHoaDon.Size' table. You can move, or remove it, as needed.
            this.sizeTableAdapter.Fill(this.size_FormLapHoaDon.Size);
            // TODO: This line of code loads data into the 'sanPham_FormLapHoaDon.SanPham' table. You can move, or remove it, as needed.
            this.sanPhamTableAdapter.Fill(this.sanPham_FormLapHoaDon.SanPham);
            if (FormKiemTraKhachHang.TTKHC.Ma == 0)
            {
                MaKH = FormKhachHangMoi.TTKHM.Ma;
            }
            else if (FormKhachHangMoi.TTKHM.Ma == 0)
            {
                MaKH = FormKiemTraKhachHang.TTKHC.Ma;
            }
            var r = from s in dt.HDXuats select s.Ma;

            if (r.Count() == 0)
            {
                lbMaHD.Text = "1";
            }
            else if (r.Count() != 0)
            {
                lbMaHD.Text = Convert.ToString(Convert.ToInt32(r.Max().ToString()) + 1);
            }

            KhachHang KH = dt.KhachHangs.Where(s => s.Ma == MaKH).FirstOrDefault();

            lbTenKH.Text       = KH.Ten;
            lbSoDienThoai.Text = KH.SoDienThoai;
            LoaiKH Loai = dt.LoaiKHs.Where(s => s.Ma == KH.Ma_LoaiKH).FirstOrDefault();

            lbThanhVien.Text = Loai.Ten;

            cbbSP.DisplayMember = "Ten";
            cbbSP.ValueMember   = "Ma";
            cbbSP.DataSource    = dt.SanPhams;


            SanPham sp = dt.SanPhams.Where(s => s.Ma == Convert.ToInt32(cbbSP.SelectedValue)).FirstOrDefault();

            cbbSize.DisplayMember = "TenSize";
            cbbSize.ValueMember   = "Ma";
            cbbSize.DataSource    = dt.cbbSize(sp.Ma_LoaiSP);

            cbbMau.DisplayMember = "TenMau";
            cbbMau.ValueMember   = "Ma";
            cbbMau.DataSource    = dt.MauSacs;

            cbbSP.Enabled   = false;
            cbbSize.Enabled = false;
            cbbMau.Enabled  = false;
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = true;
            txtSoLuong.ResetText();
            lbThanhTien.Text               = "0";
            txtSoLuong.Enabled             = false;
            lbTren.Visible                 = false;
            lbSoLuongTon.Visible           = false;
            lbDonGia.Visible               = false;
            lbThanhTien.Visible            = false;
            lbThanhTien.Visible            = false;
            TTMHDX.Ma                      = Convert.ToInt32(lbMaHD.Text);
            dgvSanPham.AutoGenerateColumns = false;
            dgvSanPham.DataSource          = dt.SanPhams;
        }
コード例 #46
0
ファイル: Class1.cs プロジェクト: nhatkycon/ThaoLyShop
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var cs = this.Page.ClientScript;
            #region Variables
            var ID = Request["ID"];
            var Ma = Request["Ma"];
            var Ten = Request["Ten"];
            var Ho = Request["Ho"];
            var XungHo = Request["XungHo"];
            var NgaySinh = Request["NgaySinh"];
            var GioiTinh = Request["GioiTinh"];
            var Email = Request["Email"];
            var Mobile = Request["Mobile"];
            var Phone = Request["Phone"];
            var CMND = Request["CMND"];
            var Ym = Request["Ym"];
            var FacebookUid = Request["FacebookUid"];
            var LinhVuc_ID = Request["LinhVuc_ID"];
            var NguonGoc_ID = Request["NguonGoc_ID"];
            var NguonGoc_ChiTiet_ID = Request["NguonGoc_ChiTiet_ID"];
            var DiaChi = Request["DiaChi"];
            var KhuVuc_ID = Request["KhuVuc_ID"];
            var NgayTao = Request["NgayTao"];
            var NguoiTao = Request["NguoiTao"];
            var NgayCapNhat = Request["NgayCapNhat"];
            var NguoiCapNhat = Request["NguoiCapNhat"];
            var NgungTheoDoi = Request["NgungTheoDoi"];
            var NoiBat = Request["NoiBat"];
            var ChiaSe = Request["ChiaSe"];
            var DanhGia = Request["DanhGia"];
            var KhongNhanEmail = Request["KhongNhanEmail"];
            var KhongDuocGoiDien = Request["KhongDuocGoiDien"];
            var ThoiGianGoiDien = Request["ThoiGianGoiDien"];
            var NguoiGioiThieu = Request["NguoiGioiThieu"];
            var TuVanVien = Request["TuVanVien"];
            var EmailTitle = Request["EmailTitle"];
            var EmailBody = Request["EmailBody"];

            var _q = Request["q"];
            #endregion

            var ListRow = new List<jgridRow>();
            switch (subAct)
            {
                case "get":
                    #region get
                    var pagerGet = KhachHangDal.pagerNormal("", false, "a.KH_" +  jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), KhuVuc_ID,NguonGoc_ID);
                    foreach (var item in pagerGet.List)
                    {
                        ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {

                            item.ID.ToString()
                            , item.Ma
                            , item.Ten
                            , item.Mobile
                            , item.Email
                            , item.GioiTinh ? "Nam" : "Nữ"
                            , item.Ym
                            , item.NgaySinh.ToString("dd/MM/yy")
                            , item.KhuVuc_Ten
                            , item.NguonGoc_Ten
                            , string.Format("{0:dd/MM/yy}",item.NgayCapNhat
                            )
                        }));
                    }
                    jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                        , pagerGet.TotalPages.ToString()
                        , pagerGet.Total.ToString()
                        , ListRow);
                    sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                    break;
                #endregion
                case "save":
                    #region chỉnh sửa
                    if (Security.IsAuthenticated())
                    {
                        var item = new KhachHang();
                        if (!string.IsNullOrEmpty(ID))
                        {
                            item = KhachHangDal.SelectById(new Guid(ID));
                        }
                        else
                        {
                            if(string.IsNullOrEmpty(Ma))
                            {
                                Ma = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 10);
                            }
                        }
                        item.CMND = CMND;
                        item.DiaChi = DiaChi;
                        item.Email = Email;
                        item.GioiTinh = Convert.ToBoolean(GioiTinh);
                        if (!string.IsNullOrEmpty(KhuVuc_ID))
                        {
                            item.KhuVuc_ID = new Guid(KhuVuc_ID);

                        }
                        item.Ma = Ma;
                        item.Mobile = Mobile;
                        item.NgayCapNhat = DateTime.Now;
                        if (!string.IsNullOrEmpty(NgaySinh))
                        {
                            item.NgaySinh = Convert.ToDateTime(NgaySinh, new CultureInfo("vi-Vn"));
                        }
                        item.NgungTheoDoi = Convert.ToBoolean(NgungTheoDoi);
                        item.NguoiCapNhat = Security.Username;
                        if (!string.IsNullOrEmpty(NguonGoc_ID))
                        {
                            item.NguonGoc_ID = new Guid(NguonGoc_ID);

                        }
                        item.Phone = Phone;
                        item.Ten = Ten;
                        item.Ym = Ym;

                        if(!string.IsNullOrEmpty(LinhVuc_ID))
                        {
                            item.LinhVuc_ID = new Guid(LinhVuc_ID);
                        }
                        if (!string.IsNullOrEmpty(NguoiGioiThieu))
                        {
                            item.NguoiGioiThieu = new Guid(NguoiGioiThieu);
                        }
                        if (!string.IsNullOrEmpty(ID))
                        {
                            item = KhachHangDal.Update(item);
                        }
                        else
                        {
                            item.ID = Guid.NewGuid();
                            item.NgayTao = DateTime.Now;
                            item.NguoiTao = Security.Username;
                            item = KhachHangDal.Insert(item);
                        }
                        sb.Append(item.ID.ToString());
                    }

                    break;
                    #endregion
                case "draff":
                    #region draff
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(KhachHangDal.SelectDraff(DAL.con())));
                    break;
                    #endregion
                case "edit":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(ID))
                    {
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(KhachHangDal.SelectById(new Guid(ID))));

                    }
                    break;
                    #endregion
                case "del":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(ID))
                    {
                        KhachHangDal.DeleteById(new Guid(ID));

                    }
                    break;
                    #endregion
                case "sendmail":
                    #region sendmail
                    if (!string.IsNullOrEmpty(ID))
                    {
                        using (var con = DAL.con())
                        {
                            string[] _email = ID.Split(new char[] { ',' });
                            sendEmailDelegate _send = new sendEmailDelegate(sendMail);
                            foreach (var eitem in _email)
                            {
                                if (eitem != "")
                                {
                                    var kh = KhachHangDal.SelectById(new Guid(eitem), con);
                                    if (!string.IsNullOrEmpty(kh.Email))
                                    {
                                        _send.BeginInvoke(kh.Email, string.Format(EmailTitle,kh.Ten,kh.Email), string.Format(EmailBody,kh.Ten,kh.Email), null, null);
                                    }
                                }
                            }
                        }
                    }
                    break;
                    #endregion
                case "search":
                    #region get
                    var pagerSearch = KhachHangDal.pagerNormal("", false, "a.KH_Ten", _q, 20, null, null);
                    sb.Append(JavaScriptConvert.SerializeObject(pagerSearch.List));
                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(Class1), "appStore.pmSpa.khachHangMgr.DanhSachKhachHang.JScript1.js"));
                    break;
                    #endregion
                default:
                    #region default
                    {
                        var ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                        sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "DanhSachKhachHang.mdl.htm"));
                        sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                            , cs.GetWebResourceUrl(typeof(Class1), "appStore.pmSpa.khachHangMgr.DanhSachKhachHang.JScript1.js")
                            , "{DanhSachKhachHangFn.loadgrid();}");
                        sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                        break;
                    }
                    #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
コード例 #47
0
 private void ViewKhachHang_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     int vitri = ViewKhachHang.CurrentRow.Index;
     List<KhachHang> list = user.ListUser().ToList();
     kh = list[vitri];
     txtMaKhachHang.Text = kh.MaKhachHang.ToString();
     txtTenKhachHang.Text = kh.Ten;
     txtDiaChi.Text = kh.DiaChi;
     txtSDT.Text = kh.SoDienThoai;
     txtEmail.Text = kh.Email;
     txtTaiKhoan.Text = kh.TenDangNhap;
     txtMatKhau.Text = kh.MatKhau;
     cbPhanQuyen.SelectedItem = kh.PerId.ToString();
 }