Beispiel #1
0
        private CreateEmployeeView CreateEmployeeView(ref string message)
        {
            CreateEmployeeView employee = new CreateEmployeeView();

            if (txtName.Text.Length == 0)
            {
                message += "Field name must be filled\n";
            }
            else if (txtName.Text.Length > 50)
            {
                message += "The field name must contain no more than 50 characters\n";
            }

            employee.Name = txtName.Text;

            int Payment = 0;

            if (txtPayment.Text.Length == 0)
            {
                message += "Field payment must be filled\n";
            }
            else if (!Int32.TryParse(txtPayment.Text, out Payment))
            {
                message += "Incorrectly entered the field payment\n";
            }
            else if (Payment < 0)
            {
                message += "Field Payment must be positive\n";
            }

            employee.Payment = Payment;

            if (radioFixedPayment.Checked)
            {
                employee.PaymentType = PaymentType.FixedPayment;
            }
            else if (radioHourlyPayment.Checked)
            {
                employee.PaymentType = PaymentType.HourlyPayment;
            }
            else
            {
                message += "Type of payment must be selected\n";
            }

            if (!checkDatabase.Checked && !checkFile.Checked)
            {
                message += "Write source must be selected\n";
            }

            employee.WriteDatabase = checkDatabase.Checked;
            employee.WriteFile = checkFile.Checked;

            return employee;
        }
Beispiel #2
0
        public void AddEmployee(CreateEmployeeView createEmployeeView)
        {
            EmployeeBase employeeBase = Mapper.Map<EmployeeBase>(createEmployeeView);

            if (createEmployeeView.WriteDatabase)
                AddEmployeeBd(employeeBase);

            if (createEmployeeView.WriteFile)
            {
                Thread thread = new Thread(() => AddEmployeeFile(employeeBase));
                thread.Start();
            }
        }