Exemplo n.º 1
0
        /// <summary>
        /// Saves Employee using the input values
        /// </summary>
        /// <param name="firstname">First name of employee</param>
        /// <param name="lastname">Last name of employee</param>
        /// <param name="department">Name of department where employee works</param>
        public void SaveEmployee(string firstname, string lastname, string department)
        {
            Employee employee = new Employee(
                firstname,
                lastname,
                department);


            db.CreateEmployee(employee);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Кнопка подтверждения
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                // Создание сотрудника и адреса на основе данных формы
                EmployeeModel employee = new EmployeeModel(
                    TBFirstName.Text,
                    TBMiddleName.Text,
                    TBLastName.Text,
                    dtpDateOfBirth.Value,
                    TBDapartment.Text,
                    TBAbout.Text);

                AddressModel address = new AddressModel(
                    TBCountry.Text,
                    TBRegion.Text,
                    TBCity.Text,
                    TBStreetAddress.Text,
                    TBPostalCode.Text
                    );

                IDataConnection db = GlobalConfig.Connections[0];

                if ((this.EmployeeId > 0) && (this.AddressId > 0))
                {
                    employee.Id        = this.EmployeeId;
                    address.Id         = this.AddressId;
                    address.EmployeeId = this.EmployeeId;

                    db.UpdateEmployee(employee);
                    db.UpdateAddress(address);
                }
                else
                {
                    employee = db.CreateEmployee(employee);

                    address.EmployeeId = employee.Id;

                    db.CreateAddress(address);
                }
            }
        }