Ejemplo n.º 1
0
 protected void Add_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         bool found = false;
         foreach (var item in StudentList)
         {
             if (item.StudentID == int.Parse(StudentID.Text))
             {
                 found = true;
             }
         }
         if (found)
         {
             MessageLabel.Text = "Record already exists.";
         }
         else
         {
             Student newitem = new Student(int.Parse(StudentID.Text), StudentName.Text, double.Parse(StudentCredits.Text), Phone.Text);
             StudentList.Add(newitem);
             PeopleGridView.DataSource = StudentList;
             PeopleGridView.DataBind();
         }
     }
 }
Ejemplo n.º 2
0
 protected void Add_Click(object sender, EventArgs e)
 {
     MessageLabel.Text = "ID = " + StudentID.Text + " Name = " + Name.Text;
     if (Page.IsValid)
     {
         bool found = false;
         foreach (var item in People)
         {
             if (item.StudentID == int.Parse(StudentID.Text))
             {
                 found = true;
             }
         }
         if (found)
         {
             MessageLabel.Text = "Record already exists.";
         }
         else
         {
             Student newitem = new Student(int.Parse(StudentID.Text), Name.Text, double.Parse(Credits.Text), EmergencyPhoneNumber.Text);
             People.Add(newitem);
             PeopleGridView.DataSource = People;
             PeopleGridView.DataBind();
         }
     }
 }
Ejemplo n.º 3
0
        protected void Add_Click(object sender, EventArgs e)
        {
            var isValid = Validation(sender, e);

            if (isValid)
            {
                bool found = false;
                foreach (var item in Employee)
                {
                    if (item.IDNum == IDNum.Text)
                    {
                        found = true;
                    }
                }
                if (found)
                {
                    ShowMessage("Record already exists.", "alert alert-info");
                }
                else
                {
                    Employee newitem = new Employee(IDNum.Text, Name.Text, Phone.Text);
                    Employee.Add(newitem);
                    PeopleGridView.DataSource = Employee;
                    PeopleGridView.DataBind();
                    ShowMessage("Record added.", "alert alert-success");
                }
            }
        }
Ejemplo n.º 4
0
        protected void Add_Click(object sender, EventArgs e)
        {
            var isValid = Validation(sender, e);

            if (isValid)
            {
                bool found = false;
                foreach (var item in People)
                {
                    if (item.SIN == SIN.Text)
                    {
                        found = true;
                    }
                }
                if (found)
                {
                    ShowMessage("Record already exists.", "alert alert-info");
                }
                else
                {
                    Person newitem = new Person(SIN.Text, Name.Text, int.Parse(Age.Text), double.Parse(Wage.Text), Phone.Text);
                    People.Add(newitem);
                    PeopleGridView.DataSource = People;
                    PeopleGridView.DataBind();
                    ShowMessage("Record added.", "alert alert-success");
                }
            }
        }
Ejemplo n.º 5
0
 protected void Add_Click(object sender, EventArgs e)
 {
     MessageLabel.Text = "SIN = " + SIN.Text + " Name = " + Name.Text;
     if (Page.IsValid)
     {
         bool found = false;
         foreach (var item in People)
         {
             if (item.SIN == SIN.Text)
             {
                 found = true;
             }
         }
         if (found)
         {
             MessageLabel.Text = "Record already exists.";
         }
         else
         {
             Person newitem = new Person(SIN.Text, Name.Text, int.Parse(Age.Text), double.Parse(Wage.Text), Phone.Text);
             People.Add(newitem);
             PeopleGridView.DataSource = People;
             PeopleGridView.DataBind();
         }
     }
 }