예제 #1
0
        private void Button_Click_Add(object sender, RoutedEventArgs e)
        {
            string   massage     = "";
            Employee newEmployee = new Employee();

            newEmployee.FirstName = First_Name.Text;
            newEmployee.LastName  = Last_Name.Text;
            newEmployee.StartDate = StartDate.SelectedDate.Value.Date.ToLongDateString();
            if (!string.IsNullOrEmpty(Salary.Text))
            {
                newEmployee.Salary = Convert.ToInt32(Salary.Text);
            }
            else
            {
                newEmployee.Salary = 0;
            }
            validitor.Check(newEmployee);
            if (!validitor.IsValid())
            {
                foreach (var error in validitor.Erorrs)
                {
                    massage = string.Join(" and ", validitor.Erorrs);
                }
                MessageBox.Show(massage);
            }
            else
            {
                repo.Add(newEmployee);
            }
            this.EmployeeList.ItemsSource = repo.GetAll();
            First_Name.Clear();
            Last_Name.Clear();
            Salary.Clear();
        }
예제 #2
0
        /*private void AddAdvisor_FormClosing(object sender, FormClosingEventArgs e)
         * {
         *  //MessageBox.Show("succeeded");
         *  Initial init = Program.getInstance();
         *  init.Show();
         * }*/

        public void clearfields()
        {
            FirstName.Clear();
            LastName.Clear();
            Contact.Clear();
            Email.Clear();
            Contact.Clear();
            Salary.Clear();
            Designation.SelectedIndex = -1;
            Gender.SelectedIndex      = -1;
        }
예제 #3
0
        private void button6_Click(object sender, EventArgs e) //adding driver
        {
            string name, pass, status, salary;
            string id;

            name   = NameD.Text;
            pass   = PassD.Text;
            id     = idd.Text;
            status = Status.Text;
            salary = Salary.Text;
            bool existid   = false;
            bool existname = false;

            if (name.Length == 0 || pass.Length == 0 || id.Length == 0 || status.Length == 0 || salary.Length == 0)
            {
                MessageBox.Show("Please complete the new driver information");
            }
            if (int.Parse(salary) < 0)
            {
                MessageBox.Show("salary can't be in negative ");
                Salary.Clear();
            }
            else
            {
                for (int i = 0; i < Form0.loadData.List_Driver.Count(); i++)
                {
                    if (Form0.loadData.List_Driver[i].getDriverId() == int.Parse(id))
                    {
                        existid = true;
                    }

                    if (name == Form0.loadData.List_Driver[i].getDriverName())
                    {
                        existname = true;
                    }
                }
                if (existid == true || existname == true)
                {
                    MessageBox.Show("Driver id or name  already exists");
                    NameD.Clear();

                    idd.Clear();
                }
                else
                {
                    Driver d1 = new Driver(name, pass, int.Parse(id), int.Parse(salary), status);
                    Form0.loadData.List_Driver.Add(d1);
                    newcar.Visible      = false;
                    newdriver.Visible   = false;
                    reporttrips.Visible = false;
                }
            }
        }
예제 #4
0
 private void NewRecord_Click(object sender, EventArgs e)
 {
     empl_ID.Clear();
     EmployeeName.Clear();
     Address.Clear();
     MobileNo.Clear();
     Email.Clear();
     BloodGroup.ResetText();
     Department.ResetText();
     DateOfJoining.ResetText();
     Salary.Clear();
     BasicWorkingTime.Clear();
     //this.Close();
     //EmployeeRegistration emp_registration = new EmployeeRegistration();
     //emp_registration.Show();
 }