/** * Author | Arcelia Aguirre * Description | Limpiar campos de Usuarios * Date | 01-03-2018 * Parameters | object sender, EventArgs e */ private void btn_userCancel_Click(object sender, EventArgs e) { TextBox[] component = { txt_idUser, txt_nameUser, txt_passwordUser, txt_fatherLastnameUser, txt_motherLastnameUser }; ComboBox[] comboBox = { cmbbx_typeUser }; PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); }
/** * Author | Arcelia Aguirre * Date | 02-02-2018 * Description | Ejecutar un comando * Parameters | string command, string table, string[] paramName, object[] param valor del parámetro * Return | DataSet dt */ public DataSet loadData(string command, string table, string[] paramName, object[] param) { SqlConnection conn = new SqlConnection(Connection.CONNECTION_STRING); SqlCommand cmd = new SqlCommand(command, conn); DataSet ds = new DataSet(); DataTable dt = new DataTable(); for (int i = 0; i < paramName.Length; i++) { if (paramName[i] != null && param[i] != null) { cmd.Parameters.AddWithValue(paramName[i].ToString(), param[i]); } else { break; } } SqlDataAdapter adapt = new SqlDataAdapter(cmd); adapt = new SqlDataAdapter(cmd); try { adapt.Fill(ds, table); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return(ds); } catch { PROPS.messageError((int)PROPS.MESSAGE_ERROR.DATA_BASE_CONSOLE); return(null); } }
/** * Author | Arcelia Aguirre * Date | 19-04-2018 * Description | Limpiar campos de registros * Parameteres | object sender, KeyEventArgs e */ private void btn_cancel_Click(object sender, EventArgs e) { TextBox[] component = { txt_idStudent, txt_numberStudent, txt_nameStudent, txt_fatherLasnameStudent, txt_motherLasnameStudent, txt_semesterStudent }; ComboBox[] comboBox = { cmbbx_typeRegister, cmbbox_careerStudent }; PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); }
/** * Author | Arcelia Aguirre * Description | Agregar un usuario * Date | 23-02-2018 * Parameters | object sender, EventArgs e */ private void btn_userSave_Click(object sender, EventArgs e) { TextBox[] component = { txt_nameUser, txt_passwordUser, txt_fatherLastnameUser }; ComboBox[] comboBox = { cmbbx_typeUser }; UserCICE userCICE = new UserCICE(); 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_idUser, txt_nameUser, txt_passwordUser, txt_fatherLastnameUser, txt_motherLastnameUser }; if (txt_idUser.Text == PROPS.EMPTY) { userCICE.save(txt_nameUser.Text, txt_passwordUser.Text, txt_fatherLastnameUser.Text, txt_motherLastnameUser.Text, Int32.Parse(cmbbx_typeUser.SelectedValue.ToString())); } else { userCICE.update(Int32.Parse(txt_idUser.Text), txt_nameUser.Text, txt_passwordUser.Text, PROPS.EMPTY, txt_fatherLastnameUser.Text, txt_motherLastnameUser.Text, Int32.Parse(cmbbx_typeUser.SelectedValue.ToString())); } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); userCICE.load_dtgdUser(ds, dtgd_user); }
/** * Author | Arcelia Aguirre * Date | 09-03-2018 * Description | Funcion al iniciar sesion */ private void Login() { DataTable dt = new DataTable(); UserCICE userCICE = new UserCICE(); /*Validación*/ TextBox[] component = { txt_name, txt_password }; if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } //dt = userCICE.login(txt_name.Text, txt_password.Text); //if (dt != null) //{ // if (dt.Rows.Count == 0) // MessageBox.Show("Usuario o Password Incorrectos"); // else // { // frm_signIn frm_checkIn = new frm_signIn(); // frm_checkIn.Show(); // } //} /*Quitar*/ frm_signIn frm_checkIn2 = new frm_signIn(); frm_checkIn2.Show(); }
/** * Author | Arcelia Aguirre * Description | Generar el reporte seleccionado * Date | 19-04-2018 * Pestaña | Reportes * Parameters | object sender, EventArgs e */ private void btn_generate_Click(object sender, EventArgs e) { TextBox[] component = { txt_semester }; ComboBox[] comboBox = { cmbbx_report, cmbbx_carrer }; DateTimePicker[] dateTimePicker = { dttmpk_initialDate, dttmpk_finalDate }; /*Cargar Gird*/ PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); PROPS.clear(dateTimePicker, (int)PROPS.COMPONENT.COMPONENT_DATE_TIME); }
/** * Author | Arcelia Aguirre * Date | 19-04-2018 * Description | Limpiar campos de carga por archivo * Parameteres | object sender, KeyEventArgs e */ private void btn_cancelLoad_Click(object sender, EventArgs e) { TextBox[] component = { txt_file }; ComboBox[] comboBox = { cmbbx_type }; if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); PROPS.clear(comboBox, (int)PROPS.COMPONENT.COMPONENT_COMBO_BOX); }
/** * 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 * Description | Datos para eliminar y modificar Tipo Usuario * Date | 27-02-2018 * Parameters | object sender, DataGridViewCellEventArgs e */ private void dtgd_typeUser_CellContentClick(object sender, DataGridViewCellEventArgs e) { TextBox[] component = { txt_idTypeUser, txt_typeUserName }; TypeUser typeUser = new TypeUser(); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (this.dtgd_typeUser.Columns[e.ColumnIndex].Name.Equals("delete_typeUser")) { if (MessageBox.Show("¿Seguro que quieres borrar el Tipo de Usuario?", "Borrar", MessageBoxButtons.YesNo) == DialogResult.Yes) { typeUser.delete(Int32.Parse(dtgd_typeUser.CurrentRow.Cells["id_typeUser"].Value.ToString())); } typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); return; } else if (this.dtgd_typeUser.Columns[e.ColumnIndex].Name.Equals("edit_typeUser")) { txt_idTypeUser.Text = dtgd_typeUser.CurrentRow.Cells["id_typeUser"].Value.ToString(); txt_typeUserName.Text = dtgd_typeUser.CurrentRow.Cells["description_typeUser"].Value.ToString(); } }
/** * Author | Arcelia Aguirre * Description | Agregar nuevo tipo usuario * Date | 23-02-2018 * Parameters | object sender, EventArgs e */ private void btn_typeUserSave_Click(object sender, EventArgs e) { TextBox[] component = { txt_typeUserName }; TypeUser typeUser = new TypeUser(); if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } component = new TextBox[] { txt_idTypeUser, txt_typeUserName }; if (txt_idTypeUser.Text == PROPS.EMPTY) { typeUser.save(txt_typeUserName.Text); } else { typeUser.update(Int32.Parse(txt_idTypeUser.Text), txt_typeUserName.Text); } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); }
/** * Author | Arcelia Aguirre * Date | 21-03-2018 * Description | Acceder a la biblioteca * Parameteres | object sender, KeyEventArgs e */ private void txt_number_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txt_number.TextLength == 7) { TextBox[] component = { txt_number, txt_name, txt_numberData, txt_career, txt_signInDate }; Access.Access access = new Access.Access(); DataTable dt = access.save(txt_number.Text, txt_number.Text); if (dt != null) { try { txt_numberData.Text = dt.Rows[0]["number"].ToString(); txt_number.Text = dt.Rows[0]["number"].ToString(); txt_name.Text = dt.Rows[0]["student_name"].ToString() + " " + dt.Rows[0]["student_father_last_name"].ToString() + " " + dt.Rows[0]["student_mother_last_name"].ToString(); string semestre = dt.Rows[0]["semester"].ToString(); txt_career.Text = dt.Rows[0]["career_name"].ToString(); txt_signInDate.Text = dt.Rows[0]["signInDate"].ToString(); } catch { txt_numberData.Text = dt.Rows[0]["number"].ToString(); txt_number.Text = dt.Rows[0]["number"].ToString(); txt_name.Text = dt.Rows[0]["name"].ToString() + " " + dt.Rows[0]["father_last_name"].ToString() + " " + dt.Rows[0]["mother_last_name"].ToString(); string semestre = dt.Rows[0]["semester"].ToString(); txt_career.Text = dt.Rows[0]["description"].ToString(); txt_signInDate.Text = dt.Rows[0]["signInDate"].ToString(); } } //myTimer.Tick += new EventHandler(TimerEventProcessor); //myTimer.Interval = 2000; //myTimer.Start(); //if (exitFlag) //{ PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); //} } } }
/** * Author | Arcelia Aguirre * Description | Agregar una carrera * Date | 27-02-2018 * Parameters | object sender, EventArgs e */ private void btn_careerSave_Click(object sender, EventArgs e) { TextBox[] component = { txt_careerName, txt_careerKey }; Career career = new Career(); if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } component = new TextBox[] { txt_idCareer, txt_careerName, txt_careerKey }; if (txt_idCareer.Text == PROPS.EMPTY) { career.save(txt_careerName.Text, txt_careerKey.Text); } else { career.update(Int32.Parse(txt_idCareer.Text), txt_careerName.Text, txt_careerKey.Text); } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); career.load_dtgdCareer(ds, dtgd_career); }
/** * Author | Arcelia Aguirre * Description | Datos para eliminar y modificar carreras * Date | 27-02-2018 * Parameters | object sender, DataGridViewCellEventArgs e */ private void dtgd_career_CellContentClick(object sender, DataGridViewCellEventArgs e) { TextBox[] component = { txt_idCareer, txt_careerName, txt_careerKey }; Career career = new Career(); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (this.dtgd_career.Columns[e.ColumnIndex].Name.Equals("delete_carrer")) { if (MessageBox.Show("¿Seguro que quieres borrar la Licenciatura?", "Borrar", MessageBoxButtons.YesNo) == DialogResult.Yes) { career.delete(Int32.Parse(dtgd_career.CurrentRow.Cells["id_career"].Value.ToString())); } career.load_dtgdCareer(ds, dtgd_career); return; } else if (this.dtgd_career.Columns[e.ColumnIndex].Name.Equals("edit_carrer")) { txt_idCareer.Text = dtgd_career.CurrentRow.Cells["id_career"].Value.ToString(); txt_careerName.Text = dtgd_career.CurrentRow.Cells["career_name"].Value.ToString(); txt_careerKey.Text = dtgd_career.CurrentRow.Cells["career_key"].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); } }
/** * Author | Arcelia Aguirre * Description | Datos para eliminar y modificar usuarios * Date | 28-02-2018 * Parameters | object sender, DataGridViewCellEventArgs e */ private void dtgd_user_CellContentClick(object sender, DataGridViewCellEventArgs e) { TextBox[] component = { txt_idUser, txt_nameUser, txt_passwordUser, txt_fatherLastnameUser, txt_motherLastnameUser }; UserCICE userCICE = new UserCICE(); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (this.dtgd_user.Columns[e.ColumnIndex].Name.Equals("delete_user")) { if (MessageBox.Show("¿Seguro que quieres borrar el Usuario?", "Borrar", MessageBoxButtons.YesNo) == DialogResult.Yes) { userCICE.delete(Int32.Parse(dtgd_user.CurrentRow.Cells["id_user"].Value.ToString())); } userCICE.load_dtgdUser(ds, dtgd_user); return; } else if (this.dtgd_user.Columns[e.ColumnIndex].Name.Equals("edit_user")) { txt_idUser.Text = dtgd_user.CurrentRow.Cells["id_user"].Value.ToString(); txt_nameUser.Text = dtgd_user.CurrentRow.Cells["name_user"].Value.ToString(); cmbbx_typeUser.SelectedValue = Int32.Parse(dtgd_user.CurrentRow.Cells["id_type_user"].Value.ToString()); txt_fatherLastnameUser.Text = dtgd_user.CurrentRow.Cells["fatherLastName_user"].Value.ToString(); txt_motherLastnameUser.Text = dtgd_user.CurrentRow.Cells["motherLastName_user"].Value.ToString(); } }
/** * Author | Arcelia Aguirre * Description | El campo solo acepta caracteres númericos * Date | 23-02-2018 * Parameters | object sender, KeyPressEventArgs e */ private void onlyNumbers(object sender, KeyPressEventArgs e) { PROPS.onlyNumbers(sender, e); }
/** * Author | Arcelia Aguirre * Date | 19-04-2018 * Description | Pimera letra de cada palabra en mayuscula * Parameteres | object sender, KeyEventArgs e */ private void upper(object sender, EventArgs e) { PROPS.UpperTextBox(sender, e); }
/** * Author | Arcelia Aguirre * Description | Limpiar campos de Tipos de Usuarios * Date | 27-02-2018 * Parameters | object sender, EventArgs e */ private void btn_typeUserCancel_Click(object sender, EventArgs e) { TextBox[] component = { txt_idTypeUser, txt_typeUserName }; PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); }