Esempio n. 1
0
        protected void btnSubmitPerson_Click(object sender, EventArgs e)
        {
            em = new Service1Client();

            if (Session["SubmitAction"].ToString() == "Edit")
            {
                Person person = em.GetPersonById(int.Parse(Session["PersonId"].ToString()));
                person.BirthDate = new DateTime(this.calDOB.SelectedDate.Year, this.calDOB.SelectedDate.Month, this.calDOB.SelectedDate.Day);
                person.FirstName = this.txtFirstName.Text;
                person.LastName  = this.txtLastName.Text;
                person.PersonId  = int.Parse(Session["PersonId"].ToString());
                em.SavePerson(person);
            }
            else if (Session["SubmitAction"].ToString() == "Add")
            {
                Person   pers = new Person();
                DateTime DOB  = new DateTime(calDOB.SelectedDate.Year, calDOB.SelectedDate.Month, calDOB.SelectedDate.Day);
                pers.BirthDate = DOB;
                pers.FirstName = this.txtFirstName.Text;
                pers.LastName  = this.txtLastName.Text;
                em             = new Service1Client();
                em.AddPerson(pers);
            }

            BindGridPersons();
            this.MultiView1.SetActiveView(ViewGridPerson);
        }
Esempio n. 2
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     this.lblError.Visible = false;
     if (Session["PersonId"] != null)
     {
         em = new Service1Client();
         int    id   = int.Parse(Session["PersonId"].ToString());
         Person pers = em.GetPersonById(id);
         //Delete action
         em.DeletePerson(pers);
         BindGridPersons();
     }
     else
     {
         this.lblError.Visible = true;
         this.lblError.Text    = "Please select a row.";
     }
 }
Esempio n. 3
0
 protected void btnEdit_Click(object sender, EventArgs e)
 {
     this.GridEmployee.Visible = false;
     this.btnEditEmp.Visible   = false;
     Session["SubmitAction"]   = "Edit";
     this.lblError.Visible     = false;
     if (Session["PersonId"] != null)
     {
         em = new Service1Client();
         this.MultiView1.SetActiveView(ViewSavePerson);
         int      id   = int.Parse(Session["PersonId"].ToString());
         Person   pers = em.GetPersonById(id);
         DateTime DOB  = new DateTime(pers.BirthDate.Year, pers.BirthDate.Month, pers.BirthDate.Day);
         this.calDOB.SelectedDate = DOB;
         this.calDOB.VisibleDate  = DOB;
         this.txtFirstName.Text   = pers.FirstName.ToString();
         this.txtLastName.Text    = pers.LastName.ToString();
     }
     else
     {
         this.lblError.Visible = true;
         this.lblError.Text    = "Please select a row.";
     }
 }