コード例 #1
0
        public JsonResult SaveDataInDatabase(ProducerVM model)
        {
            var result = false;

            try
            {
                if (model.IDProducer > 0)
                {
                    Producer Pro = db.Producers.SingleOrDefault(x => x.IDProducer == model.IDProducer);
                    Pro.NameProducer = model.NameProducer;
                    Pro.Information  = model.Information;
                    Pro.Logo         = model.Logo;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Producer Pro = new Producer();
                    Pro.NameProducer = model.NameProducer;
                    Pro.Information  = model.Information;
                    Pro.Logo         = model.Logo;

                    db.Producers.Add(Pro);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult SaveDataInDatabase(ProductTypeVM model)
        {
            var result = false;

            try
            {
                if (model.IDProductType > 0)
                {
                    ProductType Pro = db.ProductTypes.SingleOrDefault(x => x.IDProductType == model.IDProductType);
                    Pro.NameProductType = model.NameProductType;
                    Pro.Icon            = model.Icon;
                    Pro.Alias           = model.Alias;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    ProductType Pro = new ProductType();
                    Pro.NameProductType = model.NameProductType;
                    Pro.Icon            = model.Icon;
                    Pro.Alias           = model.Alias;

                    db.ProductTypes.Add(Pro);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public JsonResult SaveDataInDatabase(WareHouseVM model)
        {
            var result = false;

            try
            {
                if (model.IDWareHouse > 0)
                {
                    WareHouse War = db.WareHouses.SingleOrDefault(x => x.IDWareHouse == model.IDWareHouse);
                    War.Address = model.Address;
                    War.Amount  = model.Amount;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    WareHouse War = new WareHouse();
                    War.Address = model.Address;
                    War.Amount  = model.Amount;

                    db.WareHouses.Add(War);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
ファイル: MemberDao.cs プロジェクト: VuiPhan/WebNewNew
 public long Insert(Member member)
 {
     member.IDMemType = 3;
     member.PassWord  = MaHoa.MaHoaSangMD5(member.PassWord);
     db.Members.Add(member);
     db.SaveChanges();
     return(member.IDMember);
 }
コード例 #5
0
 public long Insert(Member employee, int IdMemType)
 {
     employee.IDMemType = IdMemType;
     employee.PassWord  = MaHoa.MaHoaSangMD5(employee.PassWord);
     db.Members.Add(employee);
     db.SaveChanges();
     return(employee.IDMember);
 }
コード例 #6
0
        public JsonResult SaveDataInDatabase(SupplierVM model)
        {
            var result = false;

            try
            {
                if (model.IDSupplier > 0)
                {
                    Supplier supplier = db.Suppliers.SingleOrDefault(x => x.IDSupplier == model.IDSupplier);
                    supplier.NameSupplier = model.NameSupplier;
                    supplier.Address      = model.Address;
                    supplier.Email        = model.Email;
                    supplier.PhoneNumber  = model.PhoneNumber;
                    supplier.Fax          = model.Fax;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Supplier supplier = new Supplier();
                    supplier.NameSupplier = model.NameSupplier;
                    supplier.Address      = model.Address;
                    supplier.Email        = model.Email;
                    supplier.PhoneNumber  = model.PhoneNumber;
                    supplier.Fax          = model.Fax;

                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public bool Update(Member model)
        {
            var admin = db.Members.Where(x => x.IDMemType == 1).SingleOrDefault();

            admin.FullName = model.FullName;
            if (admin.PassWord == model.PassWord)
            {
                admin.PassWord = model.PassWord;
            }
            else
            {
                admin.PassWord = MaHoa.MaHoaSangMD5(model.PassWord);
            }
            admin.Address     = model.Address;
            admin.Email       = model.Email;
            admin.PhoneNumber = model.PhoneNumber;
            admin.Avatar      = model.Avatar;
            admin.IDCard      = model.IDCard;
            db.SaveChanges();
            return(true);
        }
コード例 #8
0
        public JsonResult BrowseStatusOrder(int?id)
        {
            Order model = db.Orders.SingleOrDefault(n => n.IDOrder == id);

            if (model.Status == 0 || model.Status == 5)
            {
                return(Json(new
                {
                    status = false,
                    mess = "Bạn không thể thực hiện được khi đơn hàng đã hủy hoặc đơn hàng đang ở trạng thái trả hàng/Hoàn tiền",
                }, JsonRequestBehavior.AllowGet));
            }



            model.Status++;
            db.Entry(model).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(Json(new
            {
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
 public long Insert(Supplier supplier)
 {
     db.Suppliers.Add(supplier);
     db.SaveChanges();
     return(supplier.IDSupplier);
 }
コード例 #10
0
        public JsonResult SaveDataInDatabase(ProductVM model)
        {
            var result = false;

            try
            {
                if (model.IDProduct > 0)
                {
                    Product product = db.Products.SingleOrDefault(x => x.IDProduct == model.IDProduct);
                    product.NameProduct       = model.NameProduct;
                    product.Price             = model.Price;
                    product.YearManufacture   = model.YearManufacture;
                    product.Introduce         = model.Introduce;
                    product.Description       = model.Description;
                    product.Image0            = model.Image0;
                    product.Image1            = model.Image1;
                    product.Image2            = model.Image2;
                    product.Image3            = model.Image3;
                    product.SalesedQuantity   = model.SalesedQuantity;
                    product.New               = true;
                    product.DateUpdate        = Convert.ToDateTime(DateTime.Now.ToString());
                    product.IDProducer        = model.IDProducer;
                    product.IDProductType     = model.IDProductType;
                    product.IDWareHouse       = model.IDWareHouse;
                    product.Deleted           = false;
                    product.IDSupplier        = model.IDSupplier;
                    product.RemainingQuantity = model.RemainingQuantity;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Product product = new Product();
                    product.NameProduct       = model.NameProduct;
                    product.Price             = model.Price;
                    product.YearManufacture   = model.YearManufacture;
                    product.Introduce         = model.Introduce;
                    product.Description       = model.Description;
                    product.Image0            = model.Image0;
                    product.Image1            = model.Image1;
                    product.Image2            = model.Image2;
                    product.Image3            = model.Image3;
                    product.SalesedQuantity   = 0;
                    product.New               = true;
                    product.DateUpdate        = Convert.ToDateTime(DateTime.Now.ToString());
                    product.IDProducer        = model.IDProducer;
                    product.IDProductType     = model.IDProductType;
                    product.IDWareHouse       = model.IDWareHouse;
                    product.Deleted           = false;
                    product.IDSupplier        = model.IDSupplier;
                    product.RemainingQuantity = model.RemainingQuantity;

                    db.Products.Add(product);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
ファイル: ProductTypeDao.cs プロジェクト: VuiPhan/WebNewNew
 public long Insert(ProductType producttype)
 {
     db.ProductTypes.Add(producttype);
     db.SaveChanges();
     return(producttype.IDProductType);
 }
コード例 #12
0
        public JsonResult SaveDataInDatabase(ProductVM model)
        {
            var result = false;

            try
            {
                if (model.IDProduct > 0)
                {
                    Product Pro = db.Products.SingleOrDefault(x => x.Deleted == false && x.IDProduct == model.IDProduct);
                    Pro.NameProduct     = model.NameProduct;
                    Pro.Price           = model.Price;
                    Pro.YearManufacture = model.YearManufacture;
                    Pro.Introduce       = model.Introduce;
                    Pro.Description     = model.Description;
                    //Pro.Image0 = model.Image0;
                    //Pro.Image1 = model.Image1;
                    //Pro.Image2 = model.Image2;
                    //Pro.Image3 = model.Image3;
                    Pro.NumberOfPurchases = model.NumberOfPurchases;
                    Pro.New             = model.New;
                    Pro.DateUpdate      = model.DateUpdate;
                    Pro.IDProducer      = model.IDProducer;
                    Pro.IDProductType   = model.IDProductType;
                    Pro.IDSupplier      = model.IDSupplier;
                    Pro.RemainingAmount = model.RemainingAmount;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    Product Pro = new Product();
                    Pro.NameProduct     = model.NameProduct;
                    Pro.Price           = model.Price;
                    Pro.YearManufacture = model.YearManufacture;
                    Pro.Introduce       = model.Introduce;
                    Pro.Description     = model.Description;
                    //Pro.Image0 = model.Image0;
                    //Pro.Image1 = model.Image1;
                    //Pro.Image2 = model.Image2;
                    //Pro.Image3 = model.Image3;
                    Pro.NumberOfPurchases = model.NumberOfPurchases;
                    Pro.New             = model.New;
                    Pro.DateUpdate      = model.DateUpdate;
                    Pro.IDProducer      = model.IDProducer;
                    Pro.IDProductType   = model.IDProductType;
                    Pro.Deleted         = false;
                    Pro.IDSupplier      = model.IDSupplier;
                    Pro.RemainingAmount = model.RemainingAmount;

                    db.Products.Add(Pro);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
ファイル: WareHouseDao.cs プロジェクト: VuiPhan/WebNewNew
 public long Insert(WareHouse warehouse)
 {
     db.WareHouses.Add(warehouse);
     db.SaveChanges();
     return(warehouse.IDWareHouse);
 }