protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateForm())
                {
                    return;
                }

                Person person = new Person();
                person.EmailAddress = txtEmail.Text;
                person.FirstName    = txtFirstName.Text;
                person.LastName     = txtLastName.Text;
                person.PhoneNumber  = txtPhone.Text;
                person.Genere       = ddlGenero.SelectedValue;


                personRepository = new PersonData();
                if (lblId.Text == "-1")
                {
                    lblId.Text = personRepository.SavePerson(person).ToString();
                }
                else
                {
                    person.Id = int.Parse(lblId.Text);
                    personRepository.UpdatePerson(person);
                }
            }
            catch (Exception ex)
            {
                AddMessage(ex);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns person data object with updated values.
        /// </summary>
        /// <returns>the updated person data object</returns>
        private tOsoby GetNewPersonData()
        {
            var p = GetPersonData();

            PersonData.UpdatePerson(p, service);
            return(p);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="facultyDto"></param>
        /// <returns></returns>
        public int UpdateFaculty(FacultyDto facultyDto)
        {
            int returnedValue = 0;

            try
            {
                PersonData personData = new PersonData();
                returnedValue = personData.UpdatePerson(facultyDto.Person);
                if (returnedValue > -1)
                {
                    query         = UpdateFacultyQuery(facultyDto);
                    returnedValue = dbConnect.ExecuteQueries(query, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(-1);
            }
            finally
            {
                dbConnect.CloseConnection();
            }

            return(returnedValue);
        }
Пример #4
0
        public IActionResult Edit(int id, [Bind("Id,Name,Department,Years")] Person person)
        {
            if (id != person.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                PersonData.UpdatePerson(id, person);
                return(RedirectToAction("Details", new { id = id }));
            }

            return(View(person));
        }