Exemplo n.º 1
0
 public int InsertEmpoyee(Employee employee)
 {
     //  Employee employee = new Employee();
     db.Employees.Add(employee);
     db.SaveChanges();
     return(employee.ID);
 }
Exemplo n.º 2
0
        public void DeleteComment(Comment cm)
        {
            Comment cmDL = db.Comments.Find(cm.ID);

            if (cmDL != null)
            {
                db.Comments.Remove(cmDL);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public int InsertProductImage(int?ProdutsID, string URLImage)
        {
            ProductImage p = new ProductImage();

            p.ProdutsID = ProdutsID;
            p.URLImage  = URLImage;

            db.ProductImages.Add(p);
            db.SaveChanges();

            return(p.ID);
        }
Exemplo n.º 4
0
        public int InsertCategory(string name, int?position, string description, bool?Active)
        {
            Category cate = new Category();

            cate.Name         = name;
            cate.Position     = position;
            cate.Descriptions = description;
            cate.Actives      = Active;

            db.Categories.Add(cate);
            db.SaveChanges();
            return(cate.ID);
        }
Exemplo n.º 5
0
        public int InsertProduct(string NameProduct, string FullNameProduct, int?Qty, int?Price, bool?News, bool?Sale,
                                 int?PriceSale, string Color, string Size, string Maker, string Description, string Note,
                                 bool?Active, int?CreateByUserID, string[] list_Category, string UrlImage)
        {
            Product p = new Product();

            p.NameProduct        = NameProduct;
            p.FullNameProduct    = FullNameProduct;
            p.Qty                = Qty;
            p.Price              = Price;
            p.News               = News;
            p.Sale               = Sale;
            p.PriceSale          = PriceSale;
            p.Color              = Color;
            p.Size               = Size;
            p.Maker              = Maker;
            p.Description        = Description;
            p.NumberView         = 0;
            p.NumberBuy          = 0;
            p.Note               = Note;
            p.Actives            = Active;
            p.CreateByEmployeeID = CreateByUserID;
            p.CreateDate         = DateTime.Now;

            db.Products.Add(p);

            foreach (string category in list_Category)
            {
                int int_categoryid        = Int32.Parse(category);
                CF_Products_Categories pc = new CF_Products_Categories();
                pc.ProductID    = p.ID;
                pc.CategoriesID = int_categoryid;
                db.CF_Products_Categories.Add(pc);
            }
            db.SaveChanges();

            string[] urlImageDD = UrlImage.Split(',');

            foreach (string s in urlImageDD)
            {
                ProductImage proImage = new ProductImage();
                proImage.ProdutsID = p.ID;
                proImage.URLImage  = s;
                db.ProductImages.Add(proImage);
            }
            db.SaveChanges();
            return(p.ID);
        }
Exemplo n.º 6
0
        public int InsertGroupEmployee(GroupEmployee group_employee, bool[] list_access)
        {
            db.GroupEmployees.Add(group_employee);
            db.SaveChanges();
            //foreach (bool access in list_access)
            //{

            //}
            for (int i = 0; i < list_access.Length; i++)
            {
                if (list_access[i] == true)
                {
                    Authorization au = new Authorization();
                    au.AccessID        = i + 1;
                    au.GroupEmployeeID = group_employee.ID;
                    db.Authorizations.Add(au);
                }
            }
            db.SaveChanges();
            return(group_employee.ID);
        }
Exemplo n.º 7
0
        public void Update(Employee employee_new)
        {
            Employee employee_old = db.Employees.Find(employee_new.ID);

            employee_old.Name           = employee_new.Name;
            employee_old.Address        = employee_new.Address;
            employee_old.NumberPhone    = employee_new.NumberPhone;
            employee_old.Email          = employee_new.Email;
            employee_old.Login          = employee_new.Login;
            employee_old.GroupEmployee  = employee_new.GroupEmployee;
            employee_old.Password       = employee_new.Password;
            employee_old.PasswordLevel2 = employee_new.PasswordLevel2;

            db.SaveChanges();
        }
Exemplo n.º 8
0
        public void DeleteOrder(int ID)
        {
            var cf = (from table in db.CF_Orders_Products
                      where table.ProductID == ID
                      select table);

            foreach (var mem in cf)
            {
                db.CF_Orders_Products.Remove(mem);
            }
            Order order = db.Orders.Find(ID);

            if (order != null)
            {
                db.Orders.Remove(order);
                db.SaveChanges();
            }
            db.SaveChanges();
        }