/** * Author | Juan Pablo Espinoza * Description | Agregar un estudiante * Date | 08-03-2018 * Parameters | object sender, EventArgs e */ private void btn_add_Click(object sender, EventArgs e) { TextBox[] component = { txt_numberStudent, txt_nameStudent, txt_fatherLasnameStudent, txt_semesterStudent }; ComboBox[] comboBox = { cmbbx_typeRegister, cmbbox_careerStudent }; if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } if (!PROPS.emptyComponent(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX)) { return; } component = new TextBox[] { txt_idStudent, txt_numberStudent, txt_nameStudent, txt_fatherLasnameStudent, txt_motherLasnameStudent, txt_semesterStudent }; if (cmbbx_typeRegister.Items.Count != cmbbx_typeRegister.SelectedIndex + 1 && cmbbx_typeRegister.SelectedValue is int) { NotStudent notStudent = new NotStudent(); if (txt_idStudent.Text == PROPS.EMPTY) { notStudent.save(txt_numberStudent.Text, txt_nameStudent.Text, txt_fatherLasnameStudent.Text, txt_motherLasnameStudent.Text, Int32.Parse(cmbbx_typeRegister.SelectedValue.ToString())); } else { notStudent.update(Int32.Parse(txt_idStudent.Text), txt_numberStudent.Text, txt_nameStudent.Text, txt_fatherLasnameStudent.Text, txt_motherLasnameStudent.Text, Int32.Parse(cmbbx_typeRegister.SelectedValue.ToString())); } notStudent.load_dtgdStudent(ds, dtgd_student, cmbbx_typeRegister); } else { Student.Student student = new Student.Student(); if (txt_idStudent.Text == PROPS.EMPTY) { student.save(txt_numberStudent.Text, txt_nameStudent.Text, txt_fatherLasnameStudent.Text, txt_motherLasnameStudent.Text, txt_semesterStudent.Text, Int32.Parse(cmbbox_careerStudent.SelectedValue.ToString())); } else { student.update(Int32.Parse(txt_idStudent.Text), txt_numberStudent.Text, txt_nameStudent.Text, txt_fatherLasnameStudent.Text, txt_motherLasnameStudent.Text, txt_semesterStudent.Text, Int32.Parse(cmbbox_careerStudent.SelectedValue.ToString())); } student.load_dtgdStudent(ds, dtgd_student); } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); }
private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked) { Student student = new Student(); string [] name = textBox1.Text.Split(' '); student.FirstName = name[0]; if (name.Length > 1) { student.LastName = name[1]; } else { student.LastName = ""; } student.Birthday = dateTimePicker1.Value; student.School = textBox2.Text; student.ExpGradDate = dateTimePicker2.Value; addToXml(student); } else { NotStudent notStudent = new NotStudent(); string [] name = textBox1.Text.Split(' '); notStudent.FirstName = name[0]; if (name.Length > 1) { notStudent.LastName = name[1]; } else { notStudent.LastName = ""; } notStudent.Birthday = dateTimePicker1.Value; addToXml(notStudent); MessageBox.Show("Document saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/** * Author | Arcelia Aguirre * Date | 09-03-2018 * Description | Función al cambiar el combobox * Parameteres | object sender, EventArgs e */ private void cmbbx_typeRegister_SelectedIndexChanged(object sender, EventArgs e) { TextBox[] component = { txt_idStudent, txt_numberStudent, txt_nameStudent, txt_fatherLasnameStudent, txt_motherLasnameStudent, txt_semesterStudent }; PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (cmbbox_careerStudent.Items.Count > 0) { cmbbox_careerStudent.SelectedIndex = 0; } if (cmbbx_typeRegister.Items.Count != cmbbx_typeRegister.SelectedIndex + 1 && cmbbx_typeRegister.SelectedValue is int) { txt_semesterStudent.Enabled = false; cmbbox_careerStudent.Enabled = false; NotStudent notStudent = new NotStudent(); notStudent.load_dtgdStudent(ds, dtgd_student, cmbbx_typeRegister); } else { txt_semesterStudent.Enabled = true; cmbbox_careerStudent.Enabled = true; Student.Student student = new Student.Student(); student.load_dtgdStudent(ds, dtgd_student); } }