예제 #1
0
 private void sbmt_btn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string gndr = "";
         if (num_id_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your id");
         }
         else if (f_name_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your first name");
         }
         else if (l_name_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your last name");
         }
         else if (phne_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your phone");
         }
         else if (p_code_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your postal code");
         }
         else if (city_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your city");
         }
         else if (strt_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your street");
         }
         else if (house_num_txb.Text == "")
         {
             msg_lsb.Items.Add("Failure! Enter your house number");
         }
         else if (female_rdb.IsChecked == false && male_rdb.IsChecked == false)
         {
             msg_lsb.Items.Add("Failure Enter your gender");
         }
         else if (emp_cmbbx.SelectedItem == null)
         {
             msg_lsb.Items.Add("Failure! Select your Type");
         }
         else
         {
             if (male_rdb.IsChecked == true)
             {
                 gndr = "male";
             }
             else
             {
                 gndr = "female";
             }
             employee_type employee_Type = db1.employee_type.ToArray()[emp_cmbbx.SelectedIndex];
             postal_code   postal_Code   = new postal_code {
                 postal_c = Convert.ToInt32(p_code_txb.Text), city = city_txb.Text, street = strt_txb.Text, house_number = Convert.ToInt32(house_num_txb.Text)
             };
             int number_id = 0;
             number_id = Convert.ToInt32(num_id_txb.Text);
             employee employ = new employee {
                 is_working_now = "not at shift", deleted = "exist", id_number = num_id_txb.Text, first_name = f_name_txb.Text, last_name = l_name_txb.Text, phone = phne_txb.Text, gender = gndr, employee_type_id = emp_cmbbx.SelectedIndex + 1, employee_type = employee_Type
             };
             db1.employee.Add(employ);
             employ.Id = Organize_employee_id();
             if (Checking_postal_code(postal_Code))
             {
                 List <postal_code> pc = new List <postal_code>();
                 pc = db1.postal_code.ToList();
                 foreach (postal_code p in pc)
                 {
                     if (p.postal_c == postal_Code.postal_c)
                     {
                         employ.postal_code_postal_c = p.postal_c;
                         employ.postal_code          = p;
                     }
                 }
             }
             else
             {
                 db1.postal_code.Add(postal_Code);
                 employ.postal_code          = postal_Code;
                 employ.postal_code_postal_c = Convert.ToInt32(p_code_txb.Text);
             }
             this.db1.SaveChanges();
             this.Close();
         }
     }
     catch
     {
         MessageBox.Show("Failure! the number id of the worker is already existent in the system", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
         this.Close();
     }
 }
예제 #2
0
        private void sbmt_btn_Click(object sender, RoutedEventArgs e)
        {
            string   p_method = "";
            employee emp      = new employee();

            if (name_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter the expense' name");
            }
            else if (price_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter the expense' price");
            }
            else if (year_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter the expense' year");
            }
            else if (month_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter the expense' month");
            }
            else if (day_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter the expense' day");
            }

            else if (emp_dtgrid.SelectedItem == null)
            {
                msg_lsb.Items.Add("Failure! Select your identity");
            }
            else if (pay_mth_cmbbx.SelectedItem == null)
            {
                msg_lsb.Items.Add("Failure! Select the payment method");
            }
            else
            {
                if (pay_mth_cmbbx.SelectedItem == credit)
                {
                    p_method = "credit";
                }
                else
                {
                    p_method = "cash";
                }
                emp = (employee)emp_dtgrid.SelectedItem;
                date dt = new date {
                    year = Int32.Parse(year_txb.Text), month = Int32.Parse(month_txb.Text), day = Int32.Parse(day_txb.Text)
                };
                expense expnse = new expense {
                    date = dt, employee = emp, name = name_txb.Text, pay_method = p_method, price = Int32.Parse(price_txb.Text), employee_name = emp.name
                };
                db1.date.Add(dt);
                db1.expense.Add(expnse);
                db1.SaveChanges();
                expense_dtgrid.Visibility            = Visibility.Visible;
                date_dtgrid.Visibility               = Visibility.Visible;
                date_dtgrid.ItemsSource              = db1.date.ToList();
                expense_dtgrid.ItemsSource           = db1.expense.ToList();
                date_dtgrid.Columns[4].Visibility    = Visibility.Collapsed;
                expense_dtgrid.Columns[4].Visibility = Visibility.Collapsed;
                expense_dtgrid.Columns[5].Visibility = Visibility.Collapsed;
                expense_dtgrid.Columns[7].Visibility = Visibility.Collapsed;
                expense_dtgrid.Columns[8].Visibility = Visibility.Collapsed;
            }
        }
예제 #3
0
        private void sbmt_btn_Click(object sender, RoutedEventArgs e)
        {
            int    slryphour = 0;
            string gndr      = "";

            if (num_id_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your id");
            }
            else if (name_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your name");
            }
            else if (phne_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your phone");
            }
            else if (city_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your city");
            }
            else if (strt_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your street");
            }
            else if (house_num_txb.Text == "")
            {
                msg_lsb.Items.Add("Failure! Enter your house number");
            }
            else if (female_rdb.IsChecked == false && male_rdb.IsChecked == false)
            {
                msg_lsb.Items.Add("Failure Enter your gender");
            }
            else if (emp_cmbbx.SelectedItem == null)
            {
                msg_lsb.Items.Add("Failure! Select your Type");
            }
            else
            {
                if (male_rdb.IsChecked == true)
                {
                    gndr = "male";
                }
                else
                {
                    gndr = "female";
                }
                if (emp_cmbbx.Text == "Manager")
                {
                    slryphour = 120;
                }
                else if (emp_cmbbx.Text == "Chef")
                {
                    slryphour = 32;
                }
                else if (emp_cmbbx.Text == "Shift manager")
                {
                    slryphour = 38;
                }
                else
                {
                    slryphour = 29;
                }
                msg_lsb.Items.Add("The worker have been added");
                employee_type employee_Type = db1.employee_type.Add(new employee_type {
                    type = emp_cmbbx.Text, salaryperhour = slryphour
                });
                postal_code postal_Code = db1.postal_code.Add(new postal_code {
                    city = city_txb.Text, street = strt_txb.Text, house_number = house_num_txb.Text
                });
                employee employ = new employee {
                    deleted = 0, id_number = num_id_txb.Text, name = name_txb.Text, phone = phne_txb.Text, gender = gndr, employee_type = employee_Type, postal_code = postal_Code
                };

                db1.employee.Add(employ);
                emp_dtgrid.ItemsSource = db1.employee.ToList();
                this.db1.SaveChanges();
                this.Close();
            }
        }