Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id = Request["ID"];
        var d = DateTime.Now;
        var cuoiThangTruoc = new DateTime(d.Year, d.Month, 1).AddDays(-1);
        var dauThangSau = d.AddMonths(6);
        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                View.Item = new HangHoa(); ;
            }
            else
            {
                Item = HangHoaDal.SelectById(new Guid(id));
                View.Item = Item;
            }
            var list = SuKienDal.SelectPhieuDichVuForVay(con, cuoiThangTruoc, dauThangSau, id);
            View.List = list;
            var phieuBaoHongList = PhieuBaoHongDal.SelectTopByHhId(con, 10, id);

            var choThueVayList = ChoThueVayDal.SelectTopByHhId(con, 10, id);

            var phieuGiatVayList = PhieuGiatVayDal.SelectTopByHhId(con, 10, id);

            var phieuXuatNhapSanPhamList = PhieuXuatNhapSanPhamDal.SelectTopByHhId(con, 10, id);

            View.PhieuBaoHongList = phieuBaoHongList;
            View.ChoThueVayList = choThueVayList;
            View.PhieuGiatVayList = phieuGiatVayList;
            View.PhieuXuatNhapSanPhamList = phieuXuatNhapSanPhamList;

        }
    }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var id = Request["ID"];
     using (var con = DAL.con())
     {
         if (string.IsNullOrEmpty(id))
         {
             Add.Item = new HangHoa(); ;
         }
         else
         {
             Item = HangHoaDal.SelectById(new Guid(id));
             Add.Item = Item;
         }
     }
 }
Ejemplo n.º 3
0
        public IActionResult Create(HangHoa hh)
        {
            productRepository.Add(hh);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public bool Update(HangHoa hanghoa)
 {
     return(_connect.Update("SP_HANGHOA_UPD", hanghoa));
 }
Ejemplo n.º 5
0
 public bool Insert(HangHoa hangHoa)
 {
     return(hangHoaDAO.Insert(hangHoa));
 }
Ejemplo n.º 6
0
        public IActionResult mua(int mahh, int soluong, int id)
        {
            if (mahh != 0)
            {
                HangHoa hh = new HangHoa();
                hh = _context.HangHoas.Where(p => p.HanghoaID == mahh).First();
                if (HttpContext.Session.Get <int>("xacnhanmuaxong") != 1)
                {
                    if (HttpContext.Session.Get <NguoiDung>("MaKH") == null)
                    {
                        HttpContext.Session.Set <int>("a", 3);
                        return(RedirectToAction("index", "Home"));
                    }
                    else
                    {
                        NguoiDung ngd = HttpContext.Session.Get <NguoiDung>("MaKH");
                        HoaDon    hd  = new HoaDon();
                        hd.NguoiDungID = ngd.NguoiDungID;
                        DateTime d = DateTime.Now;

                        hd.NgayDat  = d;
                        hd.NgayNhan = d;

                        hd.HoTen        = ngd.HoTen;
                        hd.DiaChi       = ngd.DiaChi;
                        hd.ThanhToanID  = 1;
                        hd.VanChuyenID  = 1;
                        hd.PhiVanChuyen = 0;
                        hd.TrangThaiID  = 1;
                        hd.GhiChu       = ngd.DiaChi;
                        _context.hoaDons.Add(hd);
                        _context.SaveChanges();
                        HttpContext.Session.Set("hoadonid", hd.HoaDonID);
                        ChiTietHd cthd = new ChiTietHd();

                        cthd.HoaDonID = hd.HoaDonID;

                        cthd.HangHoaID = mahh;
                        cthd.DonGia    = hh.DonGia;
                        cthd.SoLuong   = soluong;

                        cthd.GiamGia = hh.GiamGia;

                        _context.chiTietHds.Add(cthd);
                        _context.SaveChanges();
                        HttpContext.Session.Set("xacnhanmuaxong", 1);
                    }
                }
                else
                {
                    ChiTietHd cthd = new ChiTietHd();

                    cthd.HoaDonID = HttpContext.Session.Get <int>("hoadonid");

                    cthd.HangHoaID = mahh;
                    cthd.DonGia    = hh.DonGia;
                    cthd.SoLuong   = soluong;

                    cthd.GiamGia = hh.GiamGia;

                    _context.chiTietHds.Add(cthd);
                    _context.SaveChanges();
                    HttpContext.Session.Set("xacnhanmuaxong", 1);
                }
            }
            else
            {
                var ct = _context.chiTietHds.Find(id);
                _context.chiTietHds.Remove(ct);
                _context.SaveChanges();
            }


            List <ChiTietHd> dscts = new List <ChiTietHd>();

            dscts = _context.chiTietHds.Include(x => x.HangHoa).Where(p => p.HoaDonID == HttpContext.Session.Get <int>("hoadonid")).ToList();
            double tongtien = 0;

            foreach (var item in dscts)
            {
                tongtien += item.ThanhTien;
            }
            ViewBag.TongTien = tongtien;
            return(View(dscts));
        }
Ejemplo n.º 7
0
        public void Nhap()//Tạo giao diện Nhap.
        {
            do
            {
                IFHangHoaBLL      hanghoa  = new HangHoaBLL();
                HangHoa           hh       = new HangHoa();
                HangHoaBLL        hhbll    = new HangHoaBLL();
                NhaCCBLL          ccbl     = new NhaCCBLL();
                FormHoaDonNhap    fhdn     = new FormHoaDonNhap();
                IFCTHoaDonNhapBLL ctn      = new CTHoaDonNhapBLL();
                IFHoaDonNhapBLL   hdn      = new HoaDonNhapBLL();
                CTHoaDonNhapBLL   cthdnbll = new CTHoaDonNhapBLL();
                Console.Clear();
                IO.BoxTitle("                                    NHẬP THÔNG TIN HÀNG HÓA", 1, 1, 10, 100);
                IO.Writexy("Mã HH:", 3, 4);
                IO.Writexy("Tên hàng:", 55, 4);
                IO.Writexy("Mã NCC:", 5, 5);
                IO.Writexy("Đợt:", 5, 6);
                IO.Writexy("NSX:", 15, 6);
                IO.Writexy("HSD:", 40, 6);
                IO.Writexy("Số lượng nhập:", 5, 7);
                IO.Writexy("Số lượng còn:", 30, 7);
                IO.Writexy("Giá nhập:", 50, 7);
                IO.Writexy("Giá bán:", 70, 7);
                IO.Writexy("--------------------------------------------------------------------------------------------------", 2, 8);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                fhdn.HienCT(1, 13, ctn.XemDSCTHoaDonNhap(), 5, 0);
                do
                {
                    hh.mahh = int.Parse(IO.ReadNumber(10, 4));
                    if (hh.mahh < 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTra(hh.mahh) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Mã hàng này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.mahh < 0 || hhbll.KiemTra(hh.mahh) == true);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                do
                {
                    hh.tenhang = IO.ReadString(65, 4);
                    if (hh.tenhang == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hh.tenhang == null);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                IO.Clear(1, 13, 60, ConsoleColor.Black);
                fhdn.Hien(1, 13, hdn.XemDSHoaDonNhap(), 5, 0);
                do
                {
                    hh.mancc = int.Parse(IO.ReadNumber(20, 5));
                    if (hh.mancc <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (ccbl.KiemTra(hh.mancc) == false)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Không tồn tại mã nhà cung cấp này!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.mancc <= 0 || ccbl.KiemTra(hh.mancc) == false);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                IO.Clear(1, 13, 60, ConsoleColor.Black);
                fhdn.HienCT(1, 13, ctn.XemDSCTHoaDonNhap(), 5, 0);
                do
                {
                    hh.đot = int.Parse(IO.ReadNumber(11, 6));
                    if (hh.đot <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTraDotHH(hh.đot, hh.tenhang) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Đợt nhập này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.đot <= 0 || hhbll.KiemTraDotHH(hh.đot, hh.tenhang) == true);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                CTHoaDonNhap ctdn = cthdnbll.ReturnDotNhap(hh.tenhang, hh.đot);
                IO.Writexy(ctdn.NSX.ToString(), 20, 6);
                hh.NSX = ctdn.NSX;
                IO.Writexy(ctdn.HSD.ToString(), 45, 6);
                hh.HSD = ctdn.HSD;
                IO.Writexy(ctdn.soluong.ToString(), 20, 7);
                hh.slnhapve = ctdn.soluong;
                IO.Writexy(ctdn.soluong.ToString(), 44, 7);
                hh.slhienco = ctdn.soluong;
                IO.Writexy(ctdn.gianhap.ToString(), 60, 7);
                hh.gianhap = ctdn.gianhap;

                do
                {
                    hh.giaban = double.Parse(IO.ReadNumber(79, 7));
                    if (hh.giaban <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hh.giaban < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                Console.SetCursorPosition(54, 9);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    HienChucNang();//Quay về màn hình chính.
                }
                else if (kt.Key == ConsoleKey.X)
                {
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);//Hiện danh sách.
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    hanghoa.ThemHangHoa(hh);// Sau khi nhập xong chuyển đối tượng hh sang hanghoa của tầng business.
                    IO.Clear(1, 13, 60, ConsoleColor.Black);
                    Hien(1, 17, hanghoa.XemDSHangHoa(), 5, 0);
                }
            } while (true);
        }
Ejemplo n.º 8
0
 public int ThemHangHoa(HangHoa hh)
 {
     return(hhdal.ThemHangHoa(hh));
 }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string act = Request["act"];
        string _ID = Request["ID"];
        string _SoLuong = Request["SoLuong"];
        string _Ten = Request["Ten"];
        string _Gia = Request["Gia"];
        string _Img = Request["Img"];
        string _Email = Request["Email"];
        string _Mobile = Request["Mobile"];
        string _DiaChi = Request["DiaChi"];
        string _GhiChu = Request["GhiChu"];
        var gh = new GioHang();
        var item = new HangHoa();
        var _dele = new SendEmailDele(sendmailThongbao);
        var sb = new StringBuilder();

        switch (act)
        {
            case "add":
            #region add
                item = HangHoaDal.SelectById(new Guid(_ID));
                gh.Add(item, _SoLuong);
                break;
            #endregion
            case "addWishList":
                #region add

                if(Security.IsAuthenticated())
                {
                    var yt = new YeuThich()
                                 {
                                     HH_ID = new Guid(_ID)
                                     , ID = Guid.NewGuid()
                                     , NgayTao = DateTime.Now
                                     , Username = Security.Username
                                 };
                    YeuThichDal.Insert(yt);
                    sb.Append("1");
                }
                else
                {
                    sb.Append("0");
                }
                break;
                #endregion
            case "save":
                #region save

                var itemDh = new DatHang
                                 {
                                     ID=Guid.NewGuid(),
                                     GiaoHang = false,
                                     GiaTri = gh.Total,
                                     KH_DiaChi = _DiaChi,
                                     KH_Email = _Email,
                                     KH_Mobile = _Mobile,
                                     KH_Ten = _Ten,
                                     NgayTao = DateTime.Now,
                                     PhiVanChuyen = gh.ShipCost,
                                     Readed = false,
                                     Tong = gh.Total + gh.ShipCost,
                                     NgayGiao = DateTime.Now,
                                     Username = Security.Username
                                 };
                itemDh = DatHangDal.Insert(itemDh);
                var itemDhCt = new DatHangChiTiet();
                var sbDh = new System.Text.StringBuilder();
                sbDh.AppendFormat(@"Customer: {0}<br/>Email: {1}<br/>Mobile: {2}<br/>Address: {3}<br/>Note: {4}<br/>Date of purchase: {5}<br/><h3>Chi tiết</h3>"
                    ,_Ten,_Email,_Mobile,_DiaChi, _GhiChu,DateTime.Now);
                foreach (var _ghItem in gh.List)
                {
                    var ghItem = _ghItem.Value;
                    itemDhCt = new DatHangChiTiet();
                    itemDhCt.ID = Guid.NewGuid();
                    itemDhCt.DH_ID = itemDh.ID;
                    itemDhCt.HH_ID = new Guid(_ghItem.Key);
                    itemDhCt.HH_Gia = ghItem.Gia;
                    itemDhCt.HH_SoLuong = ghItem.SoLuong;
                    itemDhCt.HH_Ten = ghItem.Ten;
                    itemDhCt.HH_Tong = ghItem.Gia * ghItem.SoLuong;
                    itemDhCt.NgayTao = DateTime.Now;
                    DatHangChiTietDal.Insert(itemDhCt);
                    sbDh.AppendFormat("Item:{0} - {1}<br/>Quality: {2}<br/>Sub total: {3}<hr/>", ghItem.Ten, ghItem.Gia, ghItem.SoLuong, ghItem.Gia * ghItem.SoLuong);
                }
                sbDh.AppendFormat(@"Total:{0}<br/>Shipping cost: {1}<br/>Total amout: {2}"
                    , gh.Total, gh.ShipCost, gh.Total + gh.ShipCost);
                _dele.BeginInvoke("*****@*****.**"
                            , string.Format("Leenaa - New Order: {0}  {1} [{2}.000]", _Ten, DateTime.Now.ToString("hh:mm-dd/MM/yy"),gh.Total + gh.ShipCost)
                            , sbDh.ToString()
                            , null, null);
                gh.Clear();
                if(itemDh.Tong != 0)
                {
                    itemDh.Tong = itemDh.Tong/1141;
                }
                sb.AppendFormat("({0})",JavaScriptConvert.SerializeObject(itemDh));
                rendertext(sb, "text/plain");
                break;
                #endregion
            case "UpSl":
                #region UpSl
                item = HangHoaDal.SelectById(new Guid(_ID));
                gh.UpdateSl(item, _SoLuong);
                break;
                #endregion
            case "del":
                #region add
                gh.Remove(_ID);
                break;
                #endregion
            case "delWishList":
                #region delWishList
                if (Security.IsAuthenticated())
                {
                    YeuThichDal.DeleteById(new Guid(_ID));
                }
                break;
                #endregion
            case "clear":
                #region add
                gh.Clear();
                break;
                #endregion
            case "get":
                #region get
                break;
            #endregion
            default:
                break;
        }
        //sb.Append(format_gioHang(gh));
        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(gh));
        rendertext(sb, "text/plain");
    }
Ejemplo n.º 10
0
        public IActionResult Detail(int id)
        {
            HangHoa hh = db.HangHoas.SingleOrDefault(p => p.MaHh == id);

            return(View(hh));
        }
        public IActionResult ChiTiet(int mahh)
        {
            HangHoa hh = db.HangHoa.SingleOrDefault(p => p.MaHh == mahh);

            return(View(hh));
        }
Ejemplo n.º 12
0
        public ActionResult DatHang(DonHang dh)
        {
            // kiểm tra đăng nhập
            if (Session["ThanhVien"] == null || Session["ThanhVien"].ToString() == "")
            {
                ViewBag.ThongBao = "Cần Đăng Nhập Để đặt hàng";
                return(RedirectToAction("DangNhap", "User"));
            }
            if (Session["GioHang"] == null)
            {
                RedirectToAction("index", "Home");
            }
            //Thêm đơn hàng


            ThanhVien tv = Session["ThanhVien"] as ThanhVien;

            if (tv.DiaChi != null)
            {
                ViewBag.DiaChi = tv.DiaChi;
            }
            if (tv.HoTen != null || tv.HoTen != "")
            {
                ViewBag.HoTen = tv.HoTen;
            }
            if (tv.SoDienThoai != null)
            {
                ViewBag.SoDienThoai = tv.SoDienThoai;
            }

            List <GioHang> gh = LayGioHang();

            dh.MaTV      = tv.MaTV;
            dh.NgayDat   = DateTime.Now;
            dh.MaTV      = tv.MaTV;
            dh.TrangThai = (int)1;

            db.DonHangs.Add(dh);
            db.SaveChanges();
            decimal tien = 0;

            foreach (var item in gh)
            {
                ChiTietDonHang ctdh = new ChiTietDonHang();
                ctdh.MaDH = dh.MaDH;
                ctdh.Size = item.iSize;
                ctdh.MaHH = item.sMaHH;

                ctdh.SoLuong = item.iSoLuong;
                HangHoa hhh = db.HangHoas.SingleOrDefault(n => n.MaHH == item.sMaHH);
                if (hhh != null)
                {
                    hhh.SoLuong = (hhh.SoLuong - item.iSoLuong);
                    db.SaveChanges();
                }
                ctdh.DonGia   = (decimal)item.dDonGia;
                ctdh.TongTien = ctdh.SoLuong * ctdh.DonGia;
                db.ChiTietDonHangs.Add(ctdh);

                db.SaveChanges();
                tien = tien + (decimal)ctdh.TongTien;
            }
            dh.TongTienDonHang = tien;
            db.SaveChanges();
            Session["GioHang"] = null;
            ViewBag.ThongBao   = "Đặt Hàng Thành công";
            return(View());
        }
Ejemplo n.º 13
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            #region Tham số
            string msg = Request["NoiDungLienHe"];
            string msgtitle = Request["msgtitle"];
            sendEmailDele _dele = new sendEmailDele(sendmailThongbao);

            string MaDanhMuc = Request["MaDanhMuc"];

            string _NgayDKSPDT = Request["NgayDKSPDT"];
            string _NgayKTDKSPDT = Request["NgayKTDKSPDT"];

            string _ID = Request["ID"];
            string _LangBased = Request["LangBased"];
            string _LangBased_ID = Request["LangBased_ID"];
            string _DM_ID = Request["DM_ID"];
            string _Ten = Request["Ten"];
            string _Ma = Request["Ma"];
            string _Alias = Request["Alias"];
            string _Lang = Request["Lang"];
            string _XuatXu_ID = Request["XuatXu_ID"];
            string _DonVi_ID = Request["DonVi_ID"];
            string _SoLuong = Request["SoLuong"];
            string _GNY = Request["GNY"];
            string _GiaNhap = Request["GiaNhap"];
            string _KeyWords = Request["KeyWords"];
            string _Description = Request["Description"];
            string _MoTa = Request["MoTa"];
            string _Anh = Request["Anh"];
            string _NoiDung = Request["NoiDung"];
            string _Active = Request["Active"];
            string _Publish = Request["Publish"];
            string _Hot = Request["Hot"];
            string _Hot1 = Request["Hot1"];
            string _Hot2 = Request["Hot2"];
            string _Hot3 = Request["Hot3"];
            string _Hot4 = Request["Hot4"];
            string _q = Request["q"];
            HangHoa Item;
            List<HangHoa> List = new List<HangHoa>();
            List<jgridRow> ListRow = new List<jgridRow>();
            #endregion

            switch (subAct)
            {

                case "DKSPDT":
                    #region Cập nhật đăng ký dịch vụ
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        DateTime dkspdt;
                        DateTime ktdkspdt;

                        #region Đăng ký sản phẩm đặc trưng
                        if (!string.IsNullOrEmpty(_NgayDKSPDT))
                        {
                            dkspdt = Convert.ToDateTime(_NgayDKSPDT, new CultureInfo("vi-vn"));
                        }
                        else
                        {
                            dkspdt = DateTime.MinValue;
                        }
                        if (!string.IsNullOrEmpty(_NgayKTDKSPDT))
                        {
                            ktdkspdt = Convert.ToDateTime(_NgayKTDKSPDT, new CultureInfo("vi-vn"));
                        }
                        else
                        {
                            ktdkspdt = DateTime.MinValue;
                        }
                        #endregion

                        HangHoaDal.UpdateDKSPDacTrung(_ID, _Hot1, dkspdt, ktdkspdt);
                        sb.Append("1");
                    }
                    break;
                    #endregion

                case "lienHe":
                    Member memberinfo = MemberDal.SelectByUser(Security.Username);
                    #region lienhe
                    _dele.BeginInvoke(""
                        , string.Format(msgtitle)
                        , string.Format(NoiDungLienHe, memberinfo.Username, memberinfo.Ten, memberinfo.DiaChi, memberinfo.Email, memberinfo.Mobile, msg)
                        , null, null);
                    break;
                    #endregion
                case "LoadHoTroDKDV":
                    #region load hỗ trợ đăng ký dịch vụ
                    sb.Append(JavaScriptConvert.SerializeObject(DanhMucDal.SelectLangBased("", MaDanhMuc)));
                    break;
                    #endregion
                case "get":
                    #region lấy dữ liệu cho grid
                    Pager<HangHoa> PagerGet = HangHoaDal.pagerLangBased("HH_" + jgrsidx + " " + jgrsord, Convert.ToInt32(jgRows));
                    foreach (HangHoa item in PagerGet.List)
                    {
                        ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                              item.ID.ToString()
                            , item.LangBased.ToString()
                            , item.Lang
                            , string.Format(@"<img src=""../up/i/{0}"" />",Lib.imgSize(item.Anh,"50x50"))

                            , item.Ma
                            , item.Ten
                            , item._DM_Ten
                            , string.Format("{0:dd/MM/yy}",item.NgayCapNhat)
                        }));
                    }
                    jgrid grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                        , List.Count.ToString()
                        , List.Count.ToString()
                        , ListRow);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "del":
                    #region xóa
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        HangHoaDal.DeleteById(Convert.ToInt32(_ID));
                    }
                    break;
                    #endregion
                case "edit":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(HangHoaDal.SelectById(Convert.ToInt32(_ID))));
                    }
                    break;
                    #endregion
                case "save":
                    #region lưu
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        Item = HangHoaDal.SelectById(Convert.ToInt32(_ID));
                    }
                    else
                    {
                        Item = new HangHoa();
                    }
                    Item.LangBased = Convert.ToBoolean(_LangBased);
                    if (!string.IsNullOrEmpty(_LangBased_ID))
                    {
                        Item.LangBased_ID = Convert.ToInt32(_LangBased_ID);
                    }
                    if (!string.IsNullOrEmpty(_DM_ID))
                    {
                        Item.DM_ID = Convert.ToInt32(_DM_ID);
                    }
                    Item.Ten = _Ten;
                    Item.Ma = _Ma;
                    Item.Alias = _Alias;
                    Item.Lang = _Lang;
                    if (!string.IsNullOrEmpty(_XuatXu_ID))
                    {
                        Item.XuatXu_ID = Convert.ToInt32(_XuatXu_ID);
                    }
                    if (!string.IsNullOrEmpty(_DonVi_ID))
                    {
                        Item.DonVi_ID = Convert.ToInt32(_DonVi_ID);
                    }
                    if (!string.IsNullOrEmpty(_SoLuong))
                    {
                        Item.GiaNhap = Convert.ToDouble(_GiaNhap);
                    }
                    Item.Keywords = _KeyWords;
                    Item.Description = _Description;
                    Item.Anh = _Anh;
                    Item.NoiDung = _NoiDung;
                    Item.Active = Convert.ToBoolean(_Active);
                    Item.Publish = Convert.ToBoolean(_Publish);
                    Item.Hot1 = Convert.ToBoolean(_Hot1);
                    Item.Hot2 = Convert.ToBoolean(_Hot2);
                    Item.Hot3 = Convert.ToBoolean(_Hot3);
                    Item.Hot4 = Convert.ToBoolean(_Hot4);
                    Item.NgayCapNhat = DateTime.Now;
                    Item.NguoiCapNhat = Security.Username;
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        Item = HangHoaDal.Update(Item);
                    }
                    else
                    {
                        Item.NgayTao = DateTime.Now;
                        Item.RowId = Guid.NewGuid();
                        Item.NguoiTao = Security.Username;
                        Item = HangHoaDal.Insert(Item);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "autoCompleteLangBased":
                    #region Lấy danh sách danh mục
                    //Item = new hangHoa();
                    //Item.ID = 0;
                    //Item.Ten = "Chọn";
                    //List = getTree(HangHoaDal.SelectLangBased(_ID));
                    //List.Insert(0, Item);
                    //sb.Append(JavaScriptConvert.SerializeObject(List));
                    break;
                    #endregion
                case "getByLangBasedId":
                    #region getByLangBasedId: Lấy danh sách các ngôn ngữ khác theo ngôn ngữ gốc

                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(Class1), "cnn.plugin.DangKyDichVu.DKSanPhamDacTrung.JScript1.js"));
                    break;
                    #endregion
                default:
                    #region nạp
                    FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                    sb.Append(@"
            <div class=""mdl-head"">
            <span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
            <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
            <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-HangHoaDKSanPhamDacTrungFn"" />
            </span>
            <a class=""mdl-head-btn mdl-head-add"" id=""HangHoaDKSanPhamDacTrungFnMdl-addBtn"" href=""javascript:"" onclick=""HangHoaDKSanPhamDacTrungFn.add();"">Thêm</a>
            <a class=""mdl-head-btn mdl-head-edit"" id=""HangHoaDKSanPhamDacTrungFnMdl-editBtn"" href=""javascript:"" onclick=""HangHoaDKSanPhamDacTrungFn.edit();"">Sửa</a>
            <a class=""mdl-head-btn mdl-head-del"" id=""HangHoaDKSanPhamDacTrungFnMdl-delBtn"" href=""javascript:"" onclick=""HangHoaDKSanPhamDacTrungFn.del();"" >Xóa</a>

            <a class=""mdl-head-btn mdl-head-del"" id=""HangHoaDKSanPhamDacTrungFnMdl-delBtn"" href=""javascript:"" onclick=""HangHoaDKSanPhamDacTrungFn.DangKySanPhamDacTrung();"" >Đăng ký Sản phẩm đặc trưng</a>
            </div>
            <table id=""HangHoaDKSanPhamDacTrungFnMdl-List"" class=""mdl-list""></table>
            <div id=""HangHoaDKSanPhamDacTrungFnMdl-Pager""></div>
            ");
                    sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                        , cs.GetWebResourceUrl(typeof(Class1), "cnn.plugin.DangKyDichVu.DKSanPhamDacTrung.JScript1.js")
                        , "{HangHoaDKSanPhamDacTrungFn.loadgrid();}");
                    sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                    break;
                    #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Ejemplo n.º 14
0
 public int ThemHangHoa(HangHoa hh)
 {
     return(hanghoa.ThemHangHoa(hh));
 }
Ejemplo n.º 15
0
        public void Sua()
        {
            do
            {
                IFHangHoaBLL hanghoa = new HangHoaBLL();
                HangHoaBLL   hhbll   = new HangHoaBLL();
                NhaCCBLL     ccbl    = new NhaCCBLL();
                Console.Clear();
                IO.BoxTitle("                                    SỬA THÔNG TIN HÀNG HÓA", 1, 1, 10, 100);
                IO.Writexy("Mã HH:", 3, 4);
                IO.Writexy("Tên hàng:", 55, 4);
                IO.Writexy("Mã NCC:", 5, 5);
                IO.Writexy("Đợt:", 5, 6);
                IO.Writexy("NSX:", 15, 6);
                IO.Writexy("HSD:", 40, 6);
                IO.Writexy("Số lượng nhập:", 5, 7);
                IO.Writexy("Số lượng còn:", 30, 7);
                IO.Writexy("Giá nhập:", 50, 7);
                IO.Writexy("Giá bán:", 70, 7);
                IO.Writexy("--------------------------------------------------------------------------------------------------", 2, 8);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 0);

                int    mahh;
                string tenhang;
                int    mancc;
                int    đot;
                string nsx;
                string hsd;
                int    sln;
                int    slc;
                double gianhap;
                double giaban;
                do
                {
                    mahh = int.Parse(IO.ReadNumber(10, 4));
                    if (mahh < 0 || hhbll.KiemTra(mahh) == false)
                    {
                        IO.Clear(5, 8, 80, ConsoleColor.Black);
                        IO.Writexy("Không tồn tại mã hàng này. Vui lòng kiểm tra lại!", 5, 9);
                    }
                } while (mahh < 0 || hhbll.KiemTra(mahh) == false);

                HangHoa hh = hanghoa.LayHangHoa(mahh);
                IO.Writexy(hh.tenhang, 65, 4);
                IO.Writexy(hh.mancc.ToString(), 20, 5);
                IO.Writexy(hh.đot.ToString(), 11, 6);
                IO.Writexy(hh.NSX, 20, 6);
                IO.Writexy(hh.HSD, 45, 6);
                IO.Writexy(hh.slnhapve.ToString(), 20, 7);
                IO.Writexy(hh.slhienco.ToString(), 44, 7);
                IO.Writexy(hh.gianhap.ToString(), 60, 7);
                IO.Writexy(hh.giaban.ToString(), 79, 7);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                do
                {
                    tenhang = IO.ReadString(65, 4);
                    if (tenhang == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (tenhang == null);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    mancc = int.Parse(IO.ReadNumber(20, 5));
                    if (mancc <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (ccbl.KiemTra(hh.mancc) == false)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Không tồn tại mã nhà cung cấp này!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (mancc <= 0 || ccbl.KiemTra(mancc) == false);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    đot = int.Parse(IO.ReadNumber(11, 6));
                    if (đot <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTraDotHH(đot, tenhang) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Đợt nhập này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (đot <= 0 || hhbll.KiemTraDotHH(đot, tenhang) == true);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    nsx = IO.ReadString(20, 6);
                    if (nsx == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (nsx == null);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    hsd = IO.ReadString(45, 6);
                    if (hsd == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hsd == null);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    IO.Clear(19, 7, 4, ConsoleColor.Black);
                    sln = int.Parse(IO.ReadNumber(20, 7));
                    if (sln < 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (sln < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    slc = int.Parse(IO.ReadNumber(44, 7));
                    if (sln <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (slc < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    gianhap = double.Parse(IO.ReadNumber(60, 7));
                    if (gianhap <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (gianhap < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    giaban = double.Parse(IO.ReadNumber(79, 7));
                    if (giaban <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (giaban < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);


                IO.Clear(5, 8, 80, ConsoleColor.Black);
                IO.Writexy("Enter để cập nhật, Esc để thoát, X để xem chi tiết...", 5, 8);
                IO.Clear(1, 13, 80, ConsoleColor.Black);
                Console.SetCursorPosition(58, 8);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    HienChucNang();
                }
                else if (kt.Key == ConsoleKey.X)
                {
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    hanghoa.SuaHangHoa(hh);
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);
                }
            } while (true);
        }
Ejemplo n.º 16
0
 public int Update(HangHoa hh)
 {
     return(hanghoa.Update(hh));
 }
Ejemplo n.º 17
0
 public virtual void HangHoaModelToHangHoa(PhieuGuiHangModel.HangHoaModel model, HangHoa hanghoa)
 {
     hanghoa.TenHangHoa    = model.TenHangHoa;
     hanghoa.LoaiHangHoaId = model.LoaiHangHoaId;
     hanghoa.CanNang       = model.CanNang;
     hanghoa.GiaTri        = model.GiaTri;
     hanghoa.GiaCuoc       = model.GiaCuoc;
     hanghoa.GhiChu        = model.GhiChu;
     hanghoa.SoLuong       = model.SoLuong;
 }
Ejemplo n.º 18
0
 public int SuaHangHoa(HangHoa hh)
 {
     return(hhdal.SuaHangHoa(hh));
 }
Ejemplo n.º 19
0
 internal HangHoaOutput()
 {
     hangHoaEntity   = new HangHoa();
     chungLoaiEntity = new ChungLoai();
 }
Ejemplo n.º 20
0
 public bool Update(string maHangOld, HangHoa hangHoa)
 {
     return(hangHoaDAO.Update(maHangOld, hangHoa));
 }
Ejemplo n.º 21
0
 internal HangHoaOutput()
 {
     hangHoaEntity = new HangHoa();
     loaiEntity    = new Loai();
 }
Ejemplo n.º 22
0
 public bool Insert(HangHoa hanghoa)
 {
     return(_connect.Update(hanghoa));
 }
Ejemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        private void hienThiDanhSachHangHoa()
        {
            flowFoodLayoutHienTai.Controls.Clear();
            if (dictionaryHienTai.ContainsKey(pageNumber) == false)
            {
                listHangHoa    = BUS.SanPhamBUS.XemSanPham(nhaCungCap.MaNCC, loaiHienTai, pageNumber, pageSize);
                listFoodLayout = new List <FoodLayout>();
                for (int i = 0; i < listHangHoa.Count; i++)
                {
                    HangHoa item = listHangHoa[i];
                    // Get the current directory.
                    string path = Directory.GetCurrentDirectory();
                    path = Path.GetFullPath(Path.Combine(path, @"..\..\")) + @"\Image\" + item.TenHinhAnh;
                    Image image = null;
                    try
                    {
                        image = Image.FromFile(path);
                    }
                    catch (Exception)
                    {
                    }


                    FoodLayout foodLayout = new FoodLayout(image)
                    {
                        HangHoa = item, IndexDict = pageNumber, IndexList = i
                    };
                    foodLayout.AutoScaleMode = AutoScaleMode.None;
                    foodLayout.AutoSize      = false;
                    foodLayout.AutoScaleMode = AutoScaleMode.None;

                    foodLayout.HangHoa = item;
                    foodLayout.setClick((sender, e) =>
                    {
                        if (phieuNhapHang.NgayGiao != "" && phieuNhapHang.NgayGiao != null)
                        {
                            MessageBox.Show("Đơn đặt hàng đã giao bạn không được phép sửa");
                            return;
                        }
                        if (hashMaHangHoa.Contains(foodLayout.HangHoa.Ma))
                        {
                            return;
                        }
                        string tenLoaiHangHoa = foodLayout.HangHoa.Loai == "0" ? "Thức ăn" : foodLayout.HangHoa.LoaiHangHoa.Ten;
                        string maHangHoa      = foodLayout.HangHoa.Ma;
                        if (dictionaryDataSource.ContainsKey(tenLoaiHangHoa))
                        {
                            dictionaryDataSource[tenLoaiHangHoa].Add(maHangHoa, new HangHoaDataSource()
                            {
                                Ma             = maHangHoa,
                                Ten            = foodLayout.HangHoa.Ten,
                                Gia            = foodLayout.HangHoa.Gia.ToString(),
                                Soluong        = "1",
                                Thanhtien      = foodLayout.HangHoa.Gia.ToString(),
                                Loai           = foodLayout.HangHoa.Loai,
                                IndexDict      = foodLayout.IndexDict,
                                IndexList      = foodLayout.IndexList,
                                MaLoaiHangHoa  = foodLayout.HangHoa.LoaiHangHoa.Ma,
                                TenLoaiHangHoa = tenLoaiHangHoa,
                                DonViTinh      = foodLayout.HangHoa.DonViTinh,
                            });
                        }


                        hashMaHangHoa.Add(maHangHoa);
                        sapXepLaiDanhSachHoaDon();

                        TongCong = TongCong + foodLayout.HangHoa.Gia;
                    });
                    flowFoodLayoutHienTai.Controls.Add(foodLayout);

                    listFoodLayout.Add(foodLayout);
                }
                dictionaryHienTai.Add(pageNumber, listFoodLayout);
            }
            else
            {
                listFoodLayout = dictionaryHienTai[pageNumber];
                for (int i = 0; i < listFoodLayout.Count; i++)
                {
                    FoodLayout foodLayout = listFoodLayout[i];
                    flowFoodLayoutHienTai.Controls.Add(foodLayout);
                }
            }
        }
Ejemplo n.º 24
0
        public static DataTable LayHangHoa()
        {
            try
            {
                HangHoa   hh           = new HangHoa();
                DonViTinh dv           = new DonViTinh();
                Kho       k            = new Kho();
                DataTable dataTableHH  = hh.LoadHangHoa();
                DataTable dataTableDV  = dv.LoadDVTDonGian();
                DataTable dataTableKho = k.LoadKhoHang();

                var results = from table1 in dataTableHH.AsEnumerable()
                              join table2 in dataTableDV.AsEnumerable() on(string) table1["Unit"] equals(string) table2["UNIT_ID"]
                              join table3 in dataTableKho.AsEnumerable() on(string) table1["Provider_ID"] equals(string) table3["Stock_ID"]
                              select new
                {
                    Product_ID        = table1["Product_ID"].ToString(),
                    Product_Name      = table1["Product_Name"].ToString(),
                    ProductGroup_Name = table1["ProductGroup_Name"].ToString(),
                    Unit            = table2["UNIT_Name"].ToString(),
                    Org_Price       = float.Parse(table1["Org_Price"].ToString()),
                    Sale_Price      = float.Parse(table1["Sale_Price"].ToString()),
                    Retail_Price    = float.Parse(table1["Retail_Price"].ToString()),
                    LimitOrders     = float.Parse(table1["LimitOrders"].ToString()),
                    Product_Type_ID = table1["Product_Type_ID"].ToString(),
                    Stock_ID        = table3["Stock_Name"].ToString(),
                    Active          = bool.Parse(table1["Active"].ToString())
                };

                DataTable rs = new DataTable();
                rs.Columns.Add("Product_ID");
                rs.Columns.Add("Product_Name");
                rs.Columns.Add("ProductGroup_Name");
                rs.Columns.Add("Unit");
                rs.Columns.Add("Org_Price");
                rs.Columns.Add("Sale_Price");
                rs.Columns.Add("Retail_Price");
                rs.Columns.Add("LimitOrders");
                rs.Columns.Add("Product_Type_ID");
                rs.Columns.Add("Stock_Name", typeof(string));
                rs.Columns.Add("Active", typeof(bool));

                foreach (var item in results)
                {
                    rs.Rows.Add(item.Product_ID, item.Product_Name, item.ProductGroup_Name, item.Unit, item.Org_Price,
                                item.Sale_Price, item.Retail_Price, item.LimitOrders, item.Product_Type_ID, item.Stock_ID, item.Active);
                }

                foreach (DataRow row in rs.Rows)
                {
                    if (float.Parse(row["Product_Type_ID"].ToString()) == 0)
                    {
                        row.SetField("Product_Type_ID", "Hàng hóa");
                    }
                }

                return(rs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Edit(string id)
        {
            HangHoa hh = db.HangHoas.Find(id);

            return(View());
        }
Ejemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string act = Request["act"];
        string _ID = Request["ID"];
        string _SoLuong = Request["SoLuong"];
        string _Ten = Request["Ten"];
        string _Gia = Request["Gia"];
        string _Img = Request["Img"];
        string _Email = Request["Email"];
        string _Mobile = Request["Mobile"];
        string _DiaChi = Request["DiaChi"];
        string _GhiChu = Request["GhiChu"];
        var gh = new GioHang();
        var item = new HangHoa();
        var _dele = new SendEmailDele(sendmailThongbao);
        var sb = new StringBuilder();

        switch (act)
        {
            case "add":
            #region add
                item = HangHoaDal.SelectById(new Guid(_ID));
                gh.Add(item, _SoLuong);
                break;
            #endregion
            case "save":
                #region save

                var itemDh = new DatHang
                                 {
                                     ID=Guid.NewGuid(),
                                     GiaoHang = false,
                                     GiaTri = gh.Total,
                                     KH_DiaChi = _DiaChi,
                                     KH_Email = _Email,
                                     KH_Mobile = _Mobile,
                                     KH_Ten = _Ten,
                                     NgayTao = DateTime.Now,
                                     PhiVanChuyen = gh.ShipCost,
                                     Readed = false,
                                     Tong = gh.Total + gh.ShipCost,
                                     NgayGiao = DateTime.Now
                                 };
                itemDh = DatHangDal.Insert(itemDh);
                var itemDhCt = new DatHangChiTiet();
                var sbDh = new System.Text.StringBuilder();
                sbDh.AppendFormat(@"Khách hàng: {0}<br/>Email: {1}<br/>Mobile: {2}<br/>Địa chỉ: {3}<br/>Ghi chú: {4}<br/>Ngày đặt hàng: {5}<br/><h3>Chi tiết</h3>"
                    ,_Ten,_Email,_Mobile,_DiaChi, _GhiChu,DateTime.Now);
                foreach (GioHangItem ghItem in gh.List.Values)
                {
                    itemDhCt = new DatHangChiTiet();
                    itemDhCt.ID = Guid.NewGuid();
                    itemDhCt.DH_ID = itemDh.ID;
                    itemDhCt.HH_Gia = ghItem.Gia;
                    itemDhCt.HH_SoLuong = ghItem.SoLuong;
                    itemDhCt.HH_Ten = ghItem.Ten;
                    itemDhCt.HH_Tong = ghItem.Gia * ghItem.SoLuong;
                    itemDhCt.NgayTao = DateTime.Now;
                    DatHangChiTietDal.Insert(itemDhCt);
                    sbDh.AppendFormat("Món:{0} - {1}<br/>Số lượng: {2}<br/>Tổng: {3}<hr/>", ghItem.Ten, ghItem.Gia, ghItem.SoLuong, ghItem.Gia * ghItem.SoLuong);
                }
                sbDh.AppendFormat(@"Tổng:{0}<br/>Phí vận chuyển: {1}<br/>Tổng cộng: {2}"
                    , gh.Total, gh.ShipCost, gh.Total + gh.ShipCost);
                _dele.BeginInvoke("*****@*****.**"
                            , string.Format("mamvui.com - Đặt hàng mới: {0}  {1} [{2}.000đ]", _Ten, DateTime.Now.ToString("hh:mm-dd/MM/yy"),gh.Total + gh.ShipCost)
                            , sbDh.ToString()
                            , null, null);
                gh.Clear();
                break;
                #endregion
            case "UpSl":
                #region UpSl
                item = HangHoaDal.SelectById(new Guid(_ID));
                gh.UpdateSl(item, _SoLuong);
                break;
                #endregion
            case "del":
                #region add
                gh.Remove(_ID);
                break;
                #endregion
            case "clear":
                #region add
                gh.Clear();
                break;
                #endregion
            case "get":
                #region get
                break;
            #endregion
            default:
                break;
        }
        //sb.Append(format_gioHang(gh));
        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(gh));
        rendertext(sb, "text/plain");
    }
Ejemplo n.º 27
0
 public frmHangHoa()
 {
     InitializeComponent();
     dt = new DataTable();
     hh = new HangHoa();
 }
Ejemplo n.º 28
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            #region Tham số
            string _ID = Request["ID"];
            string _LangBased = Request["LangBased"];
            string _LangBased_ID = Request["LangBased_ID"];
            string _DM_ID = Request["DM_ID"];
            string _Ten = Request["Ten"];
            string _Ma = Request["Ma"];
            string _Alias = Request["Alias"];
            string _Lang = Request["Lang"];
            string _XuatXu_ID = Request["XuatXu_ID"];
            string _DonVi_ID = Request["DonVi_ID"];
            string _SoLuong = Request["SoLuong"];
            string _GNY = Request["GNY"];
            string _GiaNhap = Request["GiaNhap"];
            string _KeyWords = Request["KeyWords"];
            string _Description = Request["Description"];
            string _MoTa = Request["MoTa"];
            string _Anh = Request["Anh"];
            string _NoiDung = Request["NoiDung"];
            string _Active = Request["Active"];
            string _Publish = Request["Publish"];
            string _Hot = Request["Hot"];
            string _Hot1 = Request["Hot1"];
            string _Hot2 = Request["Hot2"];
            string _Hot3 = Request["Hot3"];
            string _Hot4 = Request["Hot4"];
            string _q = Request["q"];
            HangHoa Item;
            List<HangHoa> List = new List<HangHoa>();
            List<jgridRow> ListRow = new List<jgridRow>();
            #endregion

            switch (subAct)
            {
                case "get":
                    #region lấy dữ liệu cho grid
                    Pager<HangHoa> PagerGet = HangHoaDal.pagerLangBased("HH_" + jgrsidx + " " + jgrsord, Convert.ToInt32(jgRows));
                    foreach (HangHoa item in PagerGet.List)
                    {
                        ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                              item.ID.ToString()
                            , item.LangBased.ToString()
                            , item.Lang
                            , string.Format(@"<img src=""../up/i/{0}"" />",Lib.imgSize(item.Anh,"50x50"))
                            , item._DM_Ten
                            , item.Ma
                            , item.Ten
                            , item.GNY.ToString("###.###")
                            , string.Format("{0:dd/MM/yy}",item.NgayCapNhat)
                        }));
                    }
                    jgrid grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                        , List.Count.ToString()
                        , List.Count.ToString()
                        , ListRow);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "del":
                    #region xóa
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        HangHoaDal.DeleteById(Convert.ToInt32(_ID));
                    }
                    break;
                    #endregion
                case "edit":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(HangHoaDal.SelectByIdHoangDa(Convert.ToInt32(_ID))));
                    }
                    break;
                    #endregion
                case "save":
                    #region lưu
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        Item = HangHoaDal.SelectByIdHoangDa(Convert.ToInt32(_ID));
                    }
                    else
                    {
                        Item = new HangHoa();
                    }
                    Item.LangBased = Convert.ToBoolean(_LangBased);
                    if (!string.IsNullOrEmpty(_LangBased_ID))
                    {
                        Item.LangBased_ID = Convert.ToInt32(_LangBased_ID);
                    }
                    if (!string.IsNullOrEmpty(_DM_ID))
                    {
                        Item.DM_ID = Convert.ToInt32(_DM_ID);
                    }
                    Item.Ten = _Ten;
                    Item.Ma = _Ma;
                    Item.Alias = _Alias;
                    Item.Lang = _Lang;
                    if (!string.IsNullOrEmpty(_XuatXu_ID))
                    {
                        Item.XuatXu_ID = Convert.ToInt32(_XuatXu_ID);
                    }
                    if (!string.IsNullOrEmpty(_DonVi_ID))
                    {
                        Item.DonVi_ID = Convert.ToInt32(_DonVi_ID);
                    }
                    if (!string.IsNullOrEmpty(_SoLuong))
                    {
                        Item.GiaNhap = Convert.ToDouble(_GiaNhap);
                    }
                    Item.Keywords = _KeyWords;
                    Item.Description = _Description;
                    Item.Anh = _Anh;
                    Item.NoiDung = _NoiDung;
                    Item.Active = Convert.ToBoolean(_Active);
                    Item.Publish = Convert.ToBoolean(_Publish);
                    Item.Hot1 = Convert.ToBoolean(_Hot1);
                    Item.Hot2 = Convert.ToBoolean(_Hot2);
                    Item.Hot3 = Convert.ToBoolean(_Hot3);
                    Item.Hot4 = Convert.ToBoolean(_Hot4);
                    Item.NgayCapNhat = DateTime.Now;
                    Item.NguoiCapNhat = Security.Username;
                    if (!string.IsNullOrEmpty(_ID))
                    {
                        Item = HangHoaDal.Update(Item);
                    }
                    else
                    {
                        Item.NgayTao = DateTime.Now;
                        Item.RowId = Guid.NewGuid();
                        Item.NguoiTao = Security.Username;
                        Item = HangHoaDal.Insert(Item);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "autoCompleteLangBased":
                    #region Lấy danh sách danh mục
                    //Item = new hangHoa();
                    //Item.ID = 0;
                    //Item.Ten = "Chọn";
                    //List = getTree(HangHoaDal.SelectLangBased(_ID));
                    //List.Insert(0, Item);
                    //sb.Append(JavaScriptConvert.SerializeObject(List));
                    break;
                    #endregion
                case "getByLangBasedId":
                    #region getByLangBasedId: Lấy danh sách các ngôn ngữ khác theo ngôn ngữ gốc

                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(Class1), "cnn.plugin.QuanLySanPham.User.UserSPMoi.JScript1.js"));
                    break;
                    #endregion
                default:
                    #region nạp
                    FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                    sb.Append(@"
            <div class=""mdl-head"">
            <span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
            <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
            <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-UserSanPhamMoiFn"" />
            </span>
            <a class=""mdl-head-btn mdl-head-add"" id=""UserSanPhamMoiFnMdl-addBtn"" href=""javascript:"" onclick=""UserSanPhamMoiFn.add();"">Thêm</a>
            <a class=""mdl-head-btn mdl-head-add"" id=""UserSanPhamMoiFnMdl-addBtn"" href=""javascript:"" onclick=""UserSanPhamMoiFn.addLang();"" >Thêm ngôn ngứ phụ</a>
            <a class=""mdl-head-btn mdl-head-edit"" id=""UserSanPhamMoiFnMdl-editBtn"" href=""javascript:"" onclick=""UserSanPhamMoiFn.edit();"">Sửa</a>
            <a class=""mdl-head-btn mdl-head-del"" id=""UserSanPhamMoiFnMdl-delBtn"" href=""javascript:"" onclick=""UserSanPhamMoiFn.del();"" >Xóa</a>
            <select class=""slt"" onchange=""UserSanPhamMoiFn.search();"" id=""UserSanPhamMoiFnMdl-changeLangSlt""></select>
            <span class=""mdl-head-filterPnl ui-state-default ui-corner-all"">
            <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
            <input type=""text"" _value="""" class=""mdl-head-filter mdl-head-filterDanhMucUserSanPhamMoiFn""/>
            </span>
            </div>

            <table id=""UserSanPhamMoiFnMdl-List"" class=""mdl-list""></table>
            <div id=""UserSanPhamMoiFnMdl-Pager""></div>
            <div class=""sub-mdl-list"" id=""UserSanPhamMoiFnMdl-subMdl"">
            <ul>
            <li><a href=""#UserSanPhamMoiFnMdl-subLangMdl"">Ngôn ngữ</a></li>
            <li><a href=""#UserSanPhamMoiFnMdl-subNhomMdl"">Nhóm</a></li>
            <li><a href=""#UserSanPhamMoiFnMdl-subAnhMdl"">Ảnh</a></li>
            </ul>
            <div  id=""UserSanPhamMoiFnMdl-subLangMdl"" class=""sub-mdl-list-item"">
            <div class=""mdl-head"">
            <span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
                <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
                <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-tinMdl-subTinNhomMdl"" />
            </span>
            </div>
            <table id=""UserSanPhamMoiFnMdl-subLangMdl-List"" class=""mdl-list""></table>
            </div>
            <div id=""UserSanPhamMoiFnMdl-subNhomMdl"" class=""sub-mdl-list-item"">
            <div class=""mdl-head"">
            <span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
                <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
                <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-tinMdl-subTinTopicMdl"" />
            </span>
            </div>
            <table id=""UserSanPhamMoiFnMdl-subNhomMdl-List"" class=""mdl-list""></table>
            </div>
            <div id=""UserSanPhamMoiFnMdl-subAnhMdl"" class=""sub-mdl-list-item"">
            <div class=""mdl-head"">
            <span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
                <a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
                <input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-tinMdl-subTinBinhLuanMdl"" />
            </span>
            </div>
            <table id=""UserSanPhamMoiFnMdl-subAnhMdl-List"" class=""mdl-list""></table>
            </div>
            </div>
            ");
                    sb.AppendFormat(@"<script>$.getScript('{0}', function () { 1 });</script>"
                        , cs.GetWebResourceUrl(typeof(Class1), "cnn.plugin.QuanLySanPham.User.UserSPMoi.JScript1.js")
                        , "{UserSanPhamMoiFn.loadgrid();}");
                    sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                    break;
                    #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Ejemplo n.º 29
0
 public void insert(HangHoa hh)
 {
     dao.insert(hh);
 }