public UpdateEmployeeWindow(employee updateworker, Database1Entities1 db1, DataGrid dg)
 {
     this.db            = db1;
     this.d             = dg;
     this.updateworker1 = updateworker;
     InitializeComponent();
 }
Beispiel #2
0
        public UpdateEmployeeTable(DataGrid dg, Database1Entities1 db1)
        {
            dbSave = db1;
            d      = dg;
            var results = from table1 in db1.employee.AsEnumerable()
                          //  join table2 in db1.employee_type.AsEnumerable() on (int)table1.employee_type_id equals (int)table2.Id_Employee_Type
                          //  join table3 in db1.Postal_Code_Worker.AsEnumerable() on (int)table1.postal_code_id equals (int)table3.Id_Postal_Code_Worker
                          select new
            {
                Employee_Id = (int)table1.Id_Employee,
                iId_Number  = (string)table1.id_number,
                Name        = (string)table1.name,
                Phone       = (string)table1.phone,
                // Gender = (string)table1.gender,
                Deleted = (string)table1.deleted,

                /*employee_type_id = (int)table2.Id_Employee_Type,
                 * type = (string)table2.type,
                 * salary = (string)table2.salary,
                 * postal_code_id = (int)table3.Id_Postal_Code_Worker,
                 * city = (string)table3.city,
                 * street = (string)table3.street,
                 * house_number = (string)table3.house_number*/
            };

            InitializeComponent();
            updateGrid.ItemsSource = results.ToList();
            this.db = db1;
        }
        private void Button_Save_Changes(object sender, RoutedEventArgs e)
        {
            int price = 0;

            if (price_tb.Text != "")
            {
                try
                {
                    price = Convert.ToInt32(price_tb.Text);
                }
                catch (Exception)
                {
                    price = 0;
                }
            }
            if (pbl.CheckChanges(name_tb.Text, price, availability_cb.Text) == true)
            {
                db1 = pbl.UpdateProduct(name_tb.Text, price, availability_cb.Text, updateproduct, db1);
                this.db1.SaveChanges();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirnments!");
            }
        }
        public UpdateOrderWindow(Orders od, Database1Entities1 db1, employee emp)
        {
            this.updateorder = od;
            this.db1         = db1;
            this.emp         = emp;
            InitializeComponent();
            List <Products> lst  = db1.Products.ToList();
            List <Company>  lst2 = db1.Company.ToList();
            List <Clients>  lst3 = db1.Clients.ToList();

            foreach (Products prodcut in lst)
            {
                if (prodcut.deleted == "Avaibale")
                {
                    products_cb.Items.Add(prodcut.name);
                }
            }
            foreach (Company company in lst2)
            {
                foreach (Clients client in lst3)
                {
                    if (client.company_id == company.Id_Company && client.Deleted == "Active")
                    {
                        company_cb.Items.Add(company.compnay_name);
                        break;
                    }
                }
            }
        }
Beispiel #5
0
        public Database1Entities1 AddOrder(string clientName, DateTime orderDate, DateTime deliveryDate, string ret, int quantity, string note, employee emp, string status, Database1Entities1 db1)
        {
            Database1Entities1 db2    = new Database1Entities1();
            Clients            client = findClient(db1, clientName);

            if (client == null)
            {
                Console.WriteLine("Client does not exist!");
                return(db2);
            }

            Products product = findProduct(db1, ret);

            if (product == null)
            {
                Console.WriteLine("Product does not exist!");
                return(db2);
            }

            //Products p = db1.Products.Add(new Products { name = ChangeToString(chosen), price = Account(ret, chosen), deleted = "Active"});
            Order_Details od = db1.Order_Details.Add(new Order_Details {
                Order_Date = orderDate, Delivery_Date = deliveryDate, production_amount = quantity, Note = note, products_id = product.Id_Products
            });

            db1.Orders.Add(new Orders {
                Deleted = status, Order_Details = od, employee = new employee(emp), Clients = client
            });
            return(db1);
        }
Beispiel #6
0
        private void Button_Submit(object sender, RoutedEventArgs e)
        {
            bool check = false;

            bool[] arr1 = new bool[7];
            for (int i = 0; i < arr1.Length; i++)
            {
                arr1[i] = check;
            }
            if (Civilian_NBC_Masks.IsChecked == true)
            {
                arr1[0] = true;
            }
            if (Industrial_Masks.IsChecked == true)
            {
                arr1[1] = true;
            }
            if (Military_NBC_Masks.IsChecked == true)
            {
                arr1[2] = true;
            }
            if (Personal_NBC_Filters.IsChecked == true)
            {
                arr1[3] = true;
            }
            if (Industrial_Filters.IsChecked == true)
            {
                arr1[4] = true;
            }
            if (Huto_Injectors.IsChecked == true)
            {
                arr1[5] = true;
            }
            if (Collective_NBC_System.IsChecked == true)
            {
                arr1[6] = true;
            }
            string[] arr2 = new string[7];
            arr2[0] = Civilian_NBC_Masks.Name;
            arr2[1] = Industrial_Masks.Name;
            arr2[2] = Military_NBC_Masks.Name;
            arr2[3] = Personal_NBC_Filters.Name;
            arr2[4] = Industrial_Filters.Name;
            arr2[5] = Huto_Injectors.Name;
            arr2[6] = Civilian_NBC_Masks.Name;
            string[] ret  = csb.CheckBoxChecking(arr1, arr2);
            bool     flag = csb.CheckChanges(tCompanyName.Text, tCompanyCountry.Text, cPriority.Text, ret, tNote.Text, cStatus.Text);

            if (flag == true)
            {
                db1 = csb.InsertClient(tCompanyName.Text, tCompanyCountry.Text, cPriority.Text, ret, tNote.Text, cStatus.Text, db1);
                this.db1.SaveChanges();
                this.Close();
            }

            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirnments!");
            }
        }
Beispiel #7
0
        private void Button_Add_1(object sender, RoutedEventArgs e)
        {
            int salary = 0;

            if (tSalary.Text != "")
            {
                try
                {
                    salary = Convert.ToInt32(tSalary.Text);
                }
                catch (Exception)
                {
                    salary = 0;
                }
            }
            bool flag = ebl.CheckChanges(cType.Text, salary, tCity.Text, tStreet.Text, tNumberHouse.Text, cGender.Text, tNumberId.Text, tName.Text, tPhone.Text, cDeleted.Text);

            if (flag == true)
            {
                db1 = ebl.InsertWorker(cType.Text, salary, tCity.Text, tStreet.Text, tNumberHouse.Text, cGender.Text, tNumberId.Text, tName.Text, tPhone.Text, cDeleted.Text, db1);
                this.db1.SaveChanges();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirment!");
            }
        }
Beispiel #8
0
        public Clients findClient(Database1Entities1 db, string clientName)
        {
            List <Clients> lst = db.Clients.ToList();

            foreach (Clients client in lst)
            {
                if (client.Company.compnay_name == clientName)
                {
                    return(client);
                }
            }
            return(null);
        }
Beispiel #9
0
        public Products findProduct(Database1Entities1 db, string productName)
        {
            List <Products> lst = db.Products.ToList();

            foreach (Products prodcut in lst)
            {
                if (prodcut.name == productName)
                {
                    return(prodcut);
                }
            }
            return(null);
        }
        public UpdateEmployeeTable(Database1Entities1 db1)
        {
            this.db = db1;
            var results = from table1 in db.employee.AsEnumerable()
                          select new
            {
                Employee_Id = (int)table1.Id_Employee,
                Id_Number   = (string)table1.id_number,
                Name        = (string)table1.name,
            };

            InitializeComponent();
            this.db.SaveChanges();
            updateGrid.ItemsSource = results.ToList();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int salary = 0;

            if (tSalary.Text != "")
            {
                try
                {
                    salary = Convert.ToInt32(tSalary.Text);
                }
                catch (Exception)
                {
                    salary = 0;
                }
            }
            bool flag = ebl.CheckChanges(cType.Text, salary, tCity.Text, tStreet.Text, tNumberHouse.Text, cGender.Text, tNumberId.Text, tName.Text, tPhone.Text, cDeleted.Text);

            if (flag == true)
            {
                db = ebl.UpdateWorker(cType.Text, salary, tCity.Text, tStreet.Text, tNumberHouse.Text, cGender.Text, tNumberId.Text, tName.Text, tPhone.Text, cDeleted.Text, updateworker1, db);
                this.db.SaveChanges();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirment!");
            }

            /*    //TO DO: Validate input
             *  updateworker1.phone = tPhone.Text;
             *  updateworker1.Workers_Gender.Gender = cGender.Text;
             *  updateworker1.name = tName.Text;
             *  updateworker1.id_number = tNumberId.Text;
             *  updateworker1.deleted = cDeleted.Text;
             *  updateworker1.employee_type.type = cType.Text;
             *  updateworker1.employee_type.salary = salary;
             *  updateworker1.Postal_Code_Worker.city = tCity.Text;
             *  updateworker1.Postal_Code_Worker.street = tStreet.Text;
             *  updateworker1.Postal_Code_Worker.house_number = tNumberHouse.Text;
             *  db.Entry(updateworker1).State = System.Data.Entity.EntityState.Modified;
             *  this.db.SaveChanges();
             *  this.Close();*/
        }
        private void Button_Submit(object sender, RoutedEventArgs e)
        {
            int             sum          = 0;
            string          ret          = products_cb.Text;
            string          dateorder    = orderDate.Text;
            string          datedelivery = deliveryDate.Text;
            DateTime        orderdate    = DateTime.Parse(orderDate.Text);
            DateTime        deliverydate = DateTime.Parse(deliveryDate.Text);
            List <Products> lst          = db1.Products.ToList();
            int             quantity;

            if (quantity_tb.Text == "")
            {
                quantity = 0;
            }
            else
            {
                quantity = Int32.Parse(quantity_tb.Text);
            }
            foreach (Products product in lst)
            {
                if (product.name == products_cb.Text)
                {
                    sum = product.price;
                    break;
                }
            }
            sum = quantity * sum;
            string orderPrice = sum.ToString();

            if (obl.CheckChanges(company_cb.Text, orderdate, deliverydate, ret, quantity, orderPrice, cStatus.Text) == true)
            {
                db1 = obl.UpdateOrder(company_cb.Text, orderdate, deliverydate, ret, quantity, orderPrice, updateorder, emp, cStatus.Text, db1);
                this.db1.SaveChanges();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirnments!");
            }
        }
        private void Button_Add(object sender, RoutedEventArgs e)
        {
            string   date      = date_dp.Text;
            DateTime usingDate = new DateTime();

            if (date_dp.Text != "")
            {
                usingDate = DateTime.Parse(date_dp.Text);
            }
            if (mbl.CheckChanges(name_tb.Text, value_tb.Text, usingDate, note_tb.Text) == true)
            {
                db1 = mbl.InsertExpense(name_tb.Text, value_tb.Text, usingDate, note_tb.Text, emp, db1);
                this.db1.SaveChanges();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: you must fullfill all details/according to requirnments!");
                this.Close();
            }
            try
            {
                this.db1.SaveChanges();
                this.Close();
            }
            catch (DbEntityValidationException exc)
            {
                foreach (var eve in exc.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
Beispiel #14
0
        public Database1Entities1 UpdateOrder(string clientName, DateTime sourceDate, DateTime destinationDate, string ret, int quantity, string note, Orders updateorder, employee emp, string status, Database1Entities1 db1)
        {
            Clients  client  = findClient(db1, clientName);
            Products product = findProduct(db1, ret);

            if (client == null)
            {
                Console.WriteLine("Client does not exist!");
                return(db1);
            }


            if (product == null)
            {
                Console.WriteLine("Product does not exist!");
                return(db1);
            }
            updateorder.Clients.Company.compnay_name = clientName;
            updateorder.Deleted = status;
            updateorder.Order_Details.Delivery_Date     = sourceDate;
            updateorder.Order_Details.Order_Date        = destinationDate;
            updateorder.Order_Details.production_amount = quantity;
            updateorder.Order_Details.Note        = note;
            updateorder.Order_Details.products_id = product.Id_Products;
            //updateorder.Clients.Id_Clients = client.Id_Clients;
            // updateorder.Clients.company_id = client.company_id;

            /* updateorder.Clients.factory_occupation_id = client.factory_occupation_id;
             * updateorder.Clients.Buissnes_Priority = client.Buissnes_Priority;
             * updateorder.Clients.Note = client.Note;
             * updateorder.Clients.Deleted = client.Deleted;*/
            //updateorder.employee.Id_Employee = emp.Id_Employee;
            updateorder.employee.id_number                       = emp.id_number;
            updateorder.employee.name                            = emp.name;
            updateorder.employee.phone                           = emp.phone;
            updateorder.employee.Workers_Gender.Gender           = emp.Workers_Gender.Gender;
            updateorder.employee.employee_type.type              = emp.employee_type.type;
            updateorder.employee.employee_type.salary            = emp.employee_type.salary;
            updateorder.employee.Postal_Code_Worker.street       = emp.Postal_Code_Worker.street;
            updateorder.employee.Postal_Code_Worker.city         = emp.Postal_Code_Worker.city;
            updateorder.employee.Postal_Code_Worker.house_number = emp.Postal_Code_Worker.house_number;
            db1.Entry(updateorder).State                         = System.Data.Entity.EntityState.Modified;
            return(db1);
        }
 public AddWorker(DataGrid employeeDataGrid, Database1Entities1 db)
 {
     this.employeeDataGrid = employeeDataGrid;
     this.db1 = db;
     InitializeComponent();
 }
Beispiel #16
0
 public Database1Entities1 UpdateWorker(string type, int salary, string city, string street, string house_number, string gender, string idNumber, string name, string phone, string deleted, employee updateworker1, Database1Entities1 db)
 {
     updateworker1.phone = phone;
     updateworker1.Workers_Gender.Gender = gender;
     updateworker1.name                            = name;
     updateworker1.id_number                       = idNumber;
     updateworker1.deleted                         = deleted;
     updateworker1.employee_type.type              = type;
     updateworker1.employee_type.salary            = salary;
     updateworker1.Postal_Code_Worker.city         = city;
     updateworker1.Postal_Code_Worker.street       = street;
     updateworker1.Postal_Code_Worker.house_number = house_number;
     db.Entry(updateworker1).State                 = System.Data.Entity.EntityState.Modified;
     return(db);
 }
Beispiel #17
0
        //TMP

        /* public List<employee> GetEmployees()
         *    {
         *        return model.GetEmployees();
         *    }
         *
         * }*/

        public Database1Entities1 InsertWorker(string type, int salary, string city, string street, string house_number, string gender, string idNumber, string name, string phone, string deleted, Database1Entities1 db1)
        {
            employee_type et = db1.employee_type.Add(new employee_type {
                type = type, salary = salary
            });
            Postal_Code_Worker pc = db1.Postal_Code_Worker.Add(new Postal_Code_Worker {
                city = city, street = street, house_number = house_number
            });
            Workers_Gender wg = db1.Workers_Gender.Add(new Workers_Gender {
                Gender = gender
            });

            db1.employee.Add(new employee {
                id_number = idNumber, name = name, phone = phone, deleted = deleted, employee_type = et, Postal_Code_Worker = pc, Workers_Gender = wg
            });
            return(db1);
        }
 public UpdateProductWindow(Products p, Database1Entities1 db1)
 {
     this.updateproduct = p;
     this.db1           = db1;
     InitializeComponent();
 }
Beispiel #19
0
 public Database1Entities1 UpdateProduct(string productName, int price, string status, Products updateproduct, Database1Entities1 db1)
 {
     updateproduct.name             = productName;
     updateproduct.price            = price;
     updateproduct.deleted          = status;
     db1.Entry(updateproduct).State = System.Data.Entity.EntityState.Modified;
     return(db1);
 }
Beispiel #20
0
 private void Button_Submit(object sender, RoutedEventArgs e)
 {
     // bool flag = csb.CheckAdd(tCompany.Text,tCompanyCountry.Text,cPriority.Text,cnm,im,mnm,pnf,inf,hi,cns,tNote.Text,cStatus.Text);
     //if (flag == true)
     {
         List <Products> lst          = db1.Products.ToList();
         string          ret          = products_cb.Text;
         string          dateorder    = orderDate.Text;
         string          datedelivery = deliveryDate.Text;
         DateTime        orderdate    = new DateTime();
         if (orderDate.Text != "")
         {
             orderdate = DateTime.Parse(orderDate.Text);
         }
         DateTime deliverydate = new DateTime();
         if (orderDate.Text != "")
         {
             deliverydate = DateTime.Parse(deliveryDate.Text);
         }
         int quantity = 0;
         if (quantity_tb.Text != "")
         {
             try
             {
                 quantity = Int32.Parse(quantity_tb.Text);
             }
             catch (Exception)
             {
                 quantity = 0;
             }
         }
         foreach (Products product in lst)
         {
             if (product.name == products_cb.Text)
             {
                 ordersum = product.price;
                 break;
             }
         }
         ordersum = quantity * ordersum;
         string totalSumOrder = ordersum.ToString();
         if (obl.CheckChanges(company_cb.Text, orderdate, deliverydate, ret, quantity, totalSumOrder, cStatus.Text) == true)
         {
             db1 = obl.AddOrder(company_cb.Text, deliverydate, orderdate, ret, quantity, totalSumOrder, emp, cStatus.Text, db1);
             this.db1.SaveChanges();
             this.Close();
         }
         else
         {
             MessageBox.Show("Error: you must fullfill all details/according to requirnments!");
         }
         try
         {
             this.db1.SaveChanges();
         }
         catch (DbEntityValidationException exc)
         {
             foreach (var eve in exc.EntityValidationErrors)
             {
                 Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                   eve.Entry.Entity.GetType().Name, eve.Entry.State);
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                       ve.PropertyName, ve.ErrorMessage);
                 }
             }
             throw;
         }
     }
 }
Beispiel #21
0
        public Database1Entities1 InsertExpense(string name, string value, DateTime datetime, string note, employee emp, Database1Entities1 db1)
        {
            Expends_Type et = db1.Expends_Type.Add(new Expends_Type {
                name = name
            });

            db1.Expends_Report.Add(new Expends_Report {
                note = note, value = Convert.ToInt32(value), employee = new employee(emp), Expends_Type = et, date = datetime
            });
            return(db1);
        }
 public Database1Entities1 UpdateClient(string companyName, string companyCountry, string priority, string[] ret, string note, string status, Clients updateclient, Database1Entities1 db)
 {
     updateclient.Company.compnay_name    = companyName;
     updateclient.Company.company_country = companyCountry;
     updateclient.Buissnes_Priority       = priority;
     updateclient.Factory_Occupation.factory_occupation_name = ChangeToString(ret);
     updateclient.Note            = note;
     updateclient.Deleted         = status;
     db.Entry(updateclient).State = System.Data.Entity.EntityState.Modified;
     return(db);
 }
        public Database1Entities1 InsertClient(string companyName, string companyCountry, string priority, string[] ret, string note, string status, Database1Entities1 db1)
        {
            Company c = db1.Company.Add(new Company {
                compnay_name = companyName, company_country = companyCountry
            });
            Factory_Occupation fc = db1.Factory_Occupation.Add(new Factory_Occupation {
                factory_occupation_name = ChangeToString(ret)
            });

            db1.Clients.Add(new Clients {
                Buissnes_Priority = priority, Note = note, Deleted = status, Company = c, Factory_Occupation = fc
            });
            return(db1);
        }
 public UpdateConsumerWindow(Clients updateclient, Database1Entities1 db)
 {
     this.db           = db;
     this.updateclient = updateclient;
     InitializeComponent();
 }
Beispiel #25
0
 public Database1Entities1 AddProduct(string productName, int price, string status, Database1Entities1 db1)
 {
     db1.Products.Add(new Products {
         name = productName, price = price, deleted = status
     });
     return(db1);
 }