public int ChangePassword(ref Employees employees, string old_password, string new_password, string confim_passoword)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("ChangePassword(ref Employees employees, string old_password, string new_password, string confim_passowrd)");
             if (!old_password.Equals(Global.Employees.Password))
             {
                 return(INIT.VERIFY);
             }
             if (!new_password.Equals(confim_passoword))
             {
                 return(INIT.FAIL);
             }
             employees.Password = new_password;
             myShoeStoreEntities.Employees.AddOrUpdate(employees);
             myShoeStoreEntities.SaveChanges();
             return(INIT.SUSSESS);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #2
0
 public List <Import> Read()
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("List<Import> Read()");
             return(myShoeStoreEntities.Import.Where(import => import.Done == 0 && import.Status == 1).ToList().Select(import =>
                                                                                                                       new Import
             {
                 Import_ID = import.Import_ID,
                 ImportBy = import.ImportBy,
                 ImportDate = import.ImportDate,
                 Note = import.Note,
                 Done = import.Done,
                 Status = import.Status,
                 Employees = import.Employees,
                 Export = import.Export,
                 Shoes = import.Shoes
             }).ToList());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #3
0
 public void Create(ref ModelShoes modelShoes)
 {
     using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
     {
         modelShoes.Status = 1;
         modelShoes        = myShoeStoreEntities.ModelShoes.Add(modelShoes);
         myShoeStoreEntities.SaveChanges();
     }
 }
Example #4
0
 public void Update(Import import)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             myShoeStoreEntities.Import.AddOrUpdate(import);
             myShoeStoreEntities.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #5
0
 public List <Company> Read()
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Read()");
             return(myShoeStoreEntities.Company.Where(c => c.Status == 1).ToList());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #6
0
 public void Create(ref Import import)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             import = myShoeStoreEntities.Import.Add(import);//khong hieu tai sao ko lay het thong tin lien quan
             myShoeStoreEntities.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
 public List <Log> Read()
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Read()");
             return(myShoeStoreEntities.Log.ToList());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
 public Employees GetEmployee(long employee_id)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Employees GetEmployee(long employee_id)");
             return(myShoeStoreEntities.Employees.Find(employee_id));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #9
0
 public void Update(Company company)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Update(Company company)");
             myShoeStoreEntities.Company.AddOrUpdate(company);
             myShoeStoreEntities.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
 public void Create(ref Log log)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Read()");
             log = myShoeStoreEntities.Log.Add(log);
             myShoeStoreEntities.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
 public void UpdateEmployee(Employees employees)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("UpdateEmployee(Employees employees)");
             myShoeStoreEntities.Employees.AddOrUpdate(employees);
             myShoeStoreEntities.SaveChanges();
             Console.WriteLine("Chỉnh sửa thông tin thành công");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #12
0
 public Company Create(Company company)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Create(string name)");
             company = myShoeStoreEntities.Company.Add(company);
             myShoeStoreEntities.SaveChanges();
             return(company);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #13
0
 public List <ModelShoes> Read()
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Read()");
             return(myShoeStoreEntities.ModelShoes.Where(m => m.Status == 1).ToList().Select(m => new ModelShoes {
                 ModelShoes_ID = m.ModelShoes_ID, NameShoese = m.NameShoese, CompanyID = m.CompanyID, TypeID = m.TypeID, Company = m.Company, TypeShoe = m.TypeShoe
             }).ToList());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #14
0
 public void Delete(TypeShoe typeShoe)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Delete(int id)");
             typeShoe.Status = 0;
             myShoeStoreEntities.TypeShoe.AddOrUpdate(typeShoe);
             if (myShoeStoreEntities.SaveChanges() != 1)
             {
                 throw new Exception();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #15
0
 public TypeShoe Create(string typeName)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Create(string typeName)");
             TypeShoe typeShoe = new TypeShoe();
             typeShoe.TypeName = typeName;
             typeShoe.Status   = 1;
             typeShoe          = myShoeStoreEntities.TypeShoe.Add(typeShoe);
             myShoeStoreEntities.SaveChanges();
             return(typeShoe);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
 public Employees Login(string username, string password)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Employees Login(string username, string password)");
             var employees = myShoeStoreEntities.Employees.Where(e => e.UserName == username && e.Password == password).SingleOrDefault();
             if (employees != null)
             {
                 return(employees);
             }
             return(null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #17
0
 public void Delete(ModelShoes modelShoes)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Delete(ModelShoes modelShoes)");
             modelShoes.Status = 0;
             myShoeStoreEntities.ModelShoes.AddOrUpdate(modelShoes);
             if (myShoeStoreEntities.SaveChanges() != 1)
             {
                 throw new Exception();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #18
0
 public void Delete(Import import, string note, long action_By, string action_Date)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Console.WriteLine("Delete(int id)");
             var        shoes   = import.Shoes.ToList();
             List <Log> listlog = new List <Log>();
             for (int i = shoes.Count - 1; i >= 0; i--)
             {
                 Log log = new Log();
                 log.Shoes_ID    = shoes[i].Shoes_ID;
                 log.Action_By   = action_By;
                 log.Action_Date = action_Date;
                 log.Action      = INIT.DELETE;
                 log.Amout       = shoes[i].Amount;
                 log.Note        = note;
                 log             = myShoeStoreEntities.Log.Add(log);
                 listlog.Add(log);
                 shoes[i].Status = 0;
                 myShoeStoreEntities.Shoes.AddOrUpdate(shoes[i]);
             }
             import.Status = 0;
             myShoeStoreEntities.Import.AddOrUpdate(import);
             myShoeStoreEntities.SaveChanges();
             for (int i = listlog.Count - 1; i >= 0; i--)
             {
                 Facade.EditUI(listlog[i]);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Example #19
0
 public Company Delete(int id)
 {
     try
     {
         using (MyShoeStoreEntities myShoeStoreEntities = new MyShoeStoreEntities())
         {
             Company company = Global.ListCompany.Where(c => c.Companny_ID == id).SingleOrDefault();
             Console.WriteLine("Delete(Company company)");
             company.Status = 0;
             myShoeStoreEntities.Company.AddOrUpdate(company);
             if (myShoeStoreEntities.SaveChanges() != 1)
             {
                 throw new Exception();
             }
             return(company);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }