Exemplo n.º 1
0
 public NhapSanPham_model(NhapSanPham nsp)
 {
     this.Id         = nsp.Id;
     this.SoLuong    = nsp.SoLuong;
     this.NgayNhap   = nsp.NgayNhap;
     this.GiaNhap    = nsp.GiaNhap;
     this.ChiNhanhId = nsp.ChiNhanh.Id;
     this.SanPhamId  = nsp.SanPham.Id;
 }
Exemplo n.º 2
0
        public int DeleteImportProduct(int id)
        {
            int success = 0;

            using (var context = new BanDoDienTuEntities())
            {
                NhapSanPham deleteimportproduct = context.NhapSanPhams.Where(mansp => mansp.MaNhap == id).FirstOrDefault();
                if (deleteimportproduct != null)
                {
                    context.NhapSanPhams.Remove(deleteimportproduct);
                    success = context.SaveChanges();
                }
            }
            return(success);
        }
Exemplo n.º 3
0
        public ActionResult AddImportProdutcToDatabase(FormCollection form)
        {
            using (var context = new BanDoDienTuEntities())
            {
                NhapSanPham nsp = new NhapSanPham();
                nsp.MaSP     = int.Parse(form["SanPham"].ToString());
                nsp.SoLuong  = int.Parse(form["SoLuong"].ToString());
                nsp.DonGia   = int.Parse(form["DonGia"].ToString());
                nsp.NgayNhap = DateTime.Parse(form["NgayNhap"].ToString());
                nsp.GhiChu   = form["Ghichu"].ToString();
                nsp.TongTien = int.Parse(form["SoLuong"].ToString()) * int.Parse(form["DonGia"].ToString());
                context.NhapSanPhams.Add(nsp);


                SanPham pro = context.SanPhams.ToList <SanPham>().Where(masp => masp.MaSP == int.Parse(form["SanPham"].ToString())).FirstOrDefault <SanPham>();
                pro.SoLuongTrongKho += int.Parse(form["SoLuong"].ToString());

                context.SaveChanges();
            }
            return(RedirectToAction("ImportProduct"));
        }