public FmThongTinNhapHang(NhapHang nh = null, NhapHangController nhctr = null)
 {
     InitializeComponent();
     if (nhctr == null) NHCtr = new NhapHangController();
     else NHCtr = nhctr;
     SPCTCtr = new SanPham_ChiTietController(NHCtr._db);
     dtgvChiTietNH.AutoGenerateColumns = false;
     dtgvChiTietSP.AutoGenerateColumns = false;
     if (nh == null)
     {
         this.nh = new NhapHang(NHCtr._db);
         this.Text = "Thêm Mới Đơn Nhập Hàng";
         LoadDTGV_ChiTietSP();
         dtpkNgay.Value = DateTime.Now;
     }
     else
     {
         ViewMode = true;
         this.nh = nh;
         this.nh._set_context(NHCtr._db);
         ThongTinFormNhapHang = this.nh;
         btLuu.Enabled = false;
         btThem.Enabled = false;
         btXoa.Enabled = false;
         gbDSSanPham.Enabled = false;
         LoadDTGV_ChiTietNH();
     }
 }
        public FmThongTinSanPham(SanPham sp = null, SanPhamController spc = null)
        {
            InitializeComponent();
            dtgvHinhAnh.AutoGenerateColumns = false;
            dtgvChiTietSanPham.AutoGenerateColumns = false;
            //set primary context
            if (spc != null) SPCtr = spc;
            else SPCtr = new SanPhamController();

            HSXCtr = new HangSXController(this.SPCtr._db);
            MSCtr = new MauSacController(this.SPCtr._db);
            HACtr = new HinhAnhController(this.SPCtr._db);
            SPCTCtr = new SanPham_ChiTietController(this.SPCtr._db);
            MSCtr.timkiem();
            LoadCb_HangSX();
            if (sp == null)
            {
                this.sp = new SanPham(SPCtr._db);
                this.Text = "Thêm Mới Sản Phẩm";
            }
            else
            {
                this.sp = sp;
                this.sp._set_context(SPCtr._db);
                EditMode = true;
                ThongTinFormSanPham = this.sp;
                LoadDTGV_HinhAnh();
                LoadDTGV_ChiTietSP();
            }
        }
 public ActionResult Submit()
 {
     SanPham_ChiTietController ctr = new SanPham_ChiTietController();
     int chitietsp_id = TextLibrary.ToInt(Request["sanpham_chitietsp_id"]);
     int soluong = TextLibrary.ToInt(Request["sanpham_soluong"]);
     SanPham_ChiTiet obj = ctr.get_by_id(chitietsp_id);
     if (obj == null || soluong>obj.tonkho)
     {
         return RedirectToAction("Index","FrontHome");
     }
     //new chi tiet don hang
         ChiTiet_DonHang chitiet_donhang = new ChiTiet_DonHang();
         chitiet_donhang.sanpham_chitiet = obj;
         chitiet_donhang.soluong = soluong;
         chitiet_donhang.dongia = obj.sanpham.gia;
     //call add to cart
         this._giohang._add_to_cart(chitiet_donhang);
     //save to session
         this._save_cart_to_session();
     return RedirectToAction("Index","FrontCart");
 }
Esempio n. 4
0
        private DonHang _Clone()
        {
            DonHang obj = new DonHang();
            obj.id = this.id;
            obj.kh_diachi = this.kh_diachi;
            obj.kh_email = this.kh_email;
            obj.kh_sdt = this.kh_sdt;
            obj.kh_ten = this.kh_ten;
            obj.ngay = this.ngay;
            obj.tongtien = this.tongtien;
            obj.active = this.active;
            obj.dagiaohang = this.dagiaohang;

            ChiTiet_DonHang tmp;
            SanPham_ChiTietController ctr_ = new SanPham_ChiTietController(this._ctr._db);
            foreach (var item in this.ds_chitiet_donhang)
            {
                tmp = new ChiTiet_DonHang();
                tmp.dongia = item.dongia;
                tmp.id = item.id;
                tmp.soluong = item.soluong;
                tmp.sanpham_chitiet = ctr_.get_by_id(item.sanpham_chitiet.id);
                obj.ds_chitiet_donhang.Add(tmp);
            }
            return obj;
        }
Esempio n. 5
0
 public List<string> _update_cart(int chitietsp_id = 0, int chitietsp_soluong = 0)
 {
     List<string> validate = new List<string>();
     ChiTiet_DonHang obj = this.ds_chitiet_donhang.Where(x => x.sanpham_chitiet.id == chitietsp_id).FirstOrDefault();
     if (obj == null)
     {
         validate.Add("no_exist_fail");
         return validate;
     }
     SanPham_ChiTietController ctr = new SanPham_ChiTietController();
     SanPham_ChiTiet in_system = ctr.get_by_id(chitietsp_id);
     if (in_system.tonkho < chitietsp_soluong || chitietsp_soluong<=0)
     {
         validate.Add(chitietsp_id+ "_soluong_fail");
         this.ds_chitiet_donhang.Where(x => x.sanpham_chitiet.id == chitietsp_id).FirstOrDefault().soluong = in_system.tonkho;
         return validate;
     }
     obj.soluong = chitietsp_soluong;
     return validate;
 }
Esempio n. 6
0
 public SanPham_ChiTiet(DTDDDbContext context)
 {
     this._ctr = new SanPham_ChiTietController(context);
     this._Init();
 }
Esempio n. 7
0
 public SanPham_ChiTiet()
 {
     this._ctr = new SanPham_ChiTietController();
     this._Init();
 }