/** * Author | Arcelia Aguirre * Description | Inicializar el form * Date | 23-02-2018 * Parameters | object sender, EventArgs e */ private void frm_signIn_Load(object sender, EventArgs e) { TypeUser typeUser = new TypeUser(); TypeNotStudent typeNotStudent = new TypeNotStudent(); Career career = new Career(); UserCICE userCICE = new UserCICE(); Student.Student student = new Student.Student(); try { /*Combobox*/ typeUser.load_cmbbxTypeUser(ds, cmbbx_typeUser); typeNotStudent.load_cmbbxReport(ds, cmbbx_report); typeNotStudent.load_cmbbxReport(ds, cmbbx_type); typeNotStudent.load_cmbbxReport(ds, cmbbx_typeRegister); career.load_cmbbxCarrer(ds, cmbbx_carrer); career.load_cmbbxCarrer(ds, cmbbox_careerStudent); DataTable dt = cmbbx_typeRegister.DataSource as DataTable; DataRow row = dt.NewRow(); row["description_typeNotStudent"] = "Alumno"; dt.Rows.Add(row); cmbbx_typeRegister.SelectedIndex = cmbbx_typeRegister.Items.Count - 1; /*Grid*/ career.load_dtgdCareer(ds, dtgd_career); typeNotStudent.load_dtgdTypeNotStudent(ds, dtgd_typeNotStudent); typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); userCICE.load_dtgdUser(ds, dtgd_user); student.load_dtgdStudent(ds, dtgd_student); /*DataBase*/ DataBaseSettings dataBaseSettings = new DataBaseSettings(); btn_create.Enabled = dataBaseSettings.ifExist().Rows.Count == 0 ? true : false; btn_drop.Enabled = !btn_create.Enabled; } catch { Button[] component = { btn_create, btn_drop, btn_seeder, btn_delete, btn_deleteDuplicate }; PROPS.enableButton(component); //PROPS.messageError(""); } }
/** * 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); }
/** * Author | Juan Pablo Espiniza * Description | Eliminar estudiante * Date | 08-03-2018 * Parameters | object sender, DataGridViewCellEventArgs e */ private void dtgd_student_CellContentClick(object sender, DataGridViewCellEventArgs e) { TextBox[] component = { txt_idStudent, txt_numberStudent, txt_nameStudent, txt_fatherLasnameStudent, txt_motherLasnameStudent, txt_semesterStudent }; Student.Student student = new Student.Student(); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (this.dtgd_student.Columns[e.ColumnIndex].Name.Equals("delete_student")) { if (MessageBox.Show("¿Seguro que quieres borrar el Estudiante?", "Borrar", MessageBoxButtons.YesNo) == DialogResult.Yes) { student.delete(Int32.Parse(dtgd_student.CurrentRow.Cells["id_student"].Value.ToString())); } student.load_dtgdStudent(ds, dtgd_student); return; } else if (this.dtgd_student.Columns[e.ColumnIndex].Name.Equals("edit_student")) { if (cmbbx_typeRegister.Items.Count != cmbbx_typeRegister.SelectedIndex + 1 && cmbbx_typeRegister.SelectedValue is int) { txt_semesterStudent.Enabled = false; cmbbox_careerStudent.Enabled = false; txt_idStudent.Text = dtgd_student.CurrentRow.Cells["id_student"].Value.ToString(); txt_numberStudent.Text = dtgd_student.CurrentRow.Cells["number"].Value.ToString(); txt_nameStudent.Text = dtgd_student.CurrentRow.Cells["name"].Value.ToString(); txt_fatherLasnameStudent.Text = dtgd_student.CurrentRow.Cells["father_last_name"].Value.ToString(); txt_motherLasnameStudent.Text = dtgd_student.CurrentRow.Cells["mother_last_name"].Value.ToString(); cmbbox_careerStudent.SelectedValue = 0; } else { txt_semesterStudent.Enabled = true; cmbbox_careerStudent.Enabled = true; txt_idStudent.Text = dtgd_student.CurrentRow.Cells["id_student"].Value.ToString(); txt_numberStudent.Text = dtgd_student.CurrentRow.Cells["number"].Value.ToString(); txt_nameStudent.Text = dtgd_student.CurrentRow.Cells["student_name"].Value.ToString(); txt_fatherLasnameStudent.Text = dtgd_student.CurrentRow.Cells["student_father_last_name"].Value.ToString(); txt_motherLasnameStudent.Text = dtgd_student.CurrentRow.Cells["student_mother_last_name"].Value.ToString(); txt_semesterStudent.Text = dtgd_student.CurrentRow.Cells["semester"].Value.ToString(); cmbbox_careerStudent.SelectedValue = Int32.Parse(dtgd_student.CurrentRow.Cells["id_career"].Value.ToString()); } } }
/** * 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); } }