public TaskNew(Formulario Padre, MySQL_DB Connection, int ID) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; InitializeComponent(); this.Padre = Padre; this.Connection = Connection; this.task_ID = ID; this.Padre.Size = new System.Drawing.Size(476, 503); Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_NOMBRE FROM CUR_CURSOS WHERE CUR_USR_ID_PK = " + Padre.getUsrID().ToString()); if (Connection.Conectar()) { Connection.Desconectar(); } for (int x = 0; x < Connection.countRows(); x++) { TXT_COMBO_CURSO.Items.Add(Connection.getData(x, 0)); } if (task_ID != -1) { this.BTN_CREARTAREA.Content = "Guardar los cambios"; this.BTN_BORRAR.Visibility = System.Windows.Visibility.Visible; Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT * FROM TAR_TAREAS WHERE TAR_ID_PK = " + this.task_ID.ToString()); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_TITULO.Text = Connection.getData(0, 1); TXT_DESCRIPCION.Text = Connection.getData(0, 2); if (!(string.IsNullOrEmpty(Connection.getData(0, 3)))) { TXT_F_OBJETIVO.Text = DateTime.Parse(Connection.getData(0, 3)).ToShortDateString(); } TXT_COMBO_PRIORIDAD.SelectedIndex = int.Parse(Connection.getData(0, 6)); TXT_COMBO_TIPO.SelectedIndex = int.Parse(Connection.getData(0, 7)); if (int.Parse(Connection.getData(0, 5)) != -1) { string asg_ID = Connection.getData(0, 5); Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_NOMBRE FROM CUR_CURSOS WHERE CUR_ID_PK = (SELECT ASG_CUR_ID_PK FROM ASG_ASIGNATURAS WHERE ASG_ID_PK = " + asg_ID + ")"); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_COMBO_CURSO.Text = Connection.getData(0, 0); TXT_COMBO_ASIGNATURA.Items.Clear(); Connection.ChangeTable("ASG_ASIGNATURAS", null); Connection.ChangeSelect("SELECT ASG_NOMBRE FROM ASG_ASIGNATURAS WHERE ASG_CUR_ID_PK = (SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_NOMBRE LIKE '" + TXT_COMBO_CURSO.Items[TXT_COMBO_CURSO.SelectedIndex].ToString() + "')"); if (Connection.Conectar()) { Connection.Desconectar(); } for (int x = 0; x < Connection.countRows(); x++) { TXT_COMBO_ASIGNATURA.Items.Add(Connection.getData(x, 0)); } Connection.ChangeTable("ASG_ASIGNATURAS", null); Connection.ChangeSelect("SELECT ASG_NOMBRE FROM ASG_ASIGNATURAS WHERE ASG_ID_PK = (SELECT TAR_ASG_ID_PK FROM TAR_TAREAS WHERE TAR_ID_PK = " + this.task_ID.ToString() + ")"); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_COMBO_ASIGNATURA.Text = Connection.getData(0, 0); } } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }
public OrganizerSchedules(Formulario Padre, MySQL_DB Connection, int subject_ID) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; InitializeComponent(); this.Padre = Padre; this.Connection = Connection; this.subject_ID = subject_ID; this.Padre.Size = new System.Drawing.Size(476, 503); Connection.ChangeTable("ASG_ASIGNATURAS", null); Connection.ChangeSelect("SELECT ASG_NOMBRE FROM ASG_ASIGNATURAS WHERE ASG_CUR_ID_PK IN (SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + ")"); if (Connection.Conectar()) { Connection.Desconectar(); } for (int x = 0; x < Connection.countRows(); x++) { FILTRO.Items.Add(Connection.getData(x, 0)); } LISTA.Children.Add(new TaskBlankSpace()); if (subject_ID == -1) { Connection.ChangeTable("HOR_HORARIOS", null); Connection.ChangeSelect("SELECT HOR_ID_PK FROM HOR_HORARIOS WHERE HOR_ASG_ID_PK IN (SELECT ASG_ID_PK FROM ASG_ASIGNATURAS WHERE ASG_CUR_ID_PK IN (SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + ")) ORDER BY HOR_ASG_ID_PK ASC, HOR_F_COMIENZO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_schedules = Connection.countRows(); if (num_schedules > 0) { for (int x = 0; x < num_schedules; x++) { Connection.ChangeTable("HOR_HORARIOS", null); Connection.ChangeSelect("SELECT HOR_ID_PK FROM HOR_HORARIOS WHERE HOR_ASG_ID_PK IN (SELECT ASG_ID_PK FROM ASG_ASIGNATURAS WHERE ASG_CUR_ID_PK IN (SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + ")) ORDER BY HOR_ASG_ID_PK ASC, HOR_F_COMIENZO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } LISTA.Children.Add(new Schedule(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } } else { Connection.ChangeTable("HOR_HORARIOS", null); Connection.ChangeSelect("SELECT HOR_ID_PK FROM HOR_HORARIOS WHERE HOR_ASG_ID_PK = " + this.subject_ID + " ORDER BY HOR_ASG_ID_PK ASC, HOR_F_COMIENZO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_subjects = Connection.countRows(); if (num_subjects > 0) { for (int x = 0; x < num_subjects; x++) { Connection.ChangeTable("HOR_HORARIOS", null); Connection.ChangeSelect("SELECT HOR_ID_PK FROM HOR_HORARIOS WHERE HOR_ASG_ID_PK = " + this.subject_ID + " ORDER BY HOR_ASG_ID_PK ASC, HOR_F_COMIENZO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } LISTA.Children.Add(new Schedule(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } } LISTA.Children.Add(new TaskBlankSpace()); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }
public OrganizerNewSchedule(Formulario Padre, MySQL_DB Connection, int ID) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; InitializeComponent(); this.Padre = Padre; this.Connection = Connection; this.schedule_ID = ID; this.Padre.Size = new System.Drawing.Size(476, 503); Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_NOMBRE FROM CUR_CURSOS WHERE CUR_USR_ID_PK = " + Padre.getUsrID().ToString()); if (Connection.Conectar()) { Connection.Desconectar(); } for (int x = 0; x < Connection.countRows(); x++) { TXT_COMBO_CURSO.Items.Add(Connection.getData(x, 0)); } if (schedule_ID != -1) { this.BTN_CREARHORARIO.Content = "Guardar los cambios"; this.BTN_BORRAR.Visibility = System.Windows.Visibility.Visible; Connection.ChangeTable("HOR_HORARIOS", null); Connection.ChangeSelect("SELECT * FROM HOR_HORARIOS WHERE HOR_ID_PK = " + this.schedule_ID.ToString()); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_H_COMIENZO.Text = Connection.getData(0, 2); TXT_H_FINALIZACION.Text = Connection.getData(0, 3); set_Days(Connection.getData(0, 4)); string asg_ID = Connection.getData(0, 1); Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_NOMBRE FROM CUR_CURSOS WHERE CUR_ID_PK = (SELECT ASG_CUR_ID_PK FROM ASG_ASIGNATURAS WHERE ASG_ID_PK = " + asg_ID + ")"); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_COMBO_CURSO.Text = Connection.getData(0, 0); TXT_COMBO_ASIGNATURA.Items.Clear(); Connection.ChangeTable("ASG_ASIGNATURAS", null); Connection.ChangeSelect("SELECT ASG_NOMBRE FROM ASG_ASIGNATURAS WHERE ASG_CUR_ID_PK = (SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_NOMBRE LIKE '" + TXT_COMBO_CURSO.Items[TXT_COMBO_CURSO.SelectedIndex].ToString() + "')"); if (Connection.Conectar()) { Connection.Desconectar(); } for (int x = 0; x < Connection.countRows(); x++) { TXT_COMBO_ASIGNATURA.Items.Add(Connection.getData(x, 0)); } Connection.ChangeTable("ASG_ASIGNATURAS", null); Connection.ChangeSelect("SELECT ASG_NOMBRE FROM ASG_ASIGNATURAS WHERE ASG_ID_PK = (SELECT HOR_ASG_ID_PK FROM HOR_HORARIOS WHERE HOR_ID_PK = " + this.schedule_ID.ToString() + ")"); if (Connection.Conectar()) { Connection.Desconectar(); } TXT_COMBO_ASIGNATURA.Text = Connection.getData(0, 0); } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }
public OrganizerCourses(Formulario Padre, MySQL_DB Connection, bool old_courses) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; InitializeComponent(); this.Padre = Padre; this.Connection = Connection; this.old_courses = old_courses; this.Padre.Size = new System.Drawing.Size(476, 503); LISTA.Children.Add(new TaskBlankSpace()); if (old_courses) { BTN_OLDCOURSES.Content = "Cursos actuales"; Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_F_FINAL < DATE_FORMAT(NOW(),'%Y-%m-%d') AND CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + " ORDER BY CUR_NOMBRE ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_courses = Connection.countRows(); if (num_courses > 0) { for (int x = 0; x < num_courses; x++) { Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_F_FINAL < DATE_FORMAT(NOW(),'%Y-%m-%d') AND CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + " ORDER BY CUR_NOMBRE ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } LISTA.Children.Add(new Course(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } } else { Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_F_FINAL >= DATE_FORMAT(NOW(),'%Y-%m-%d') AND CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + " ORDER BY CUR_NOMBRE ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_courses = Connection.countRows(); if (num_courses > 0) { for (int x = 0; x < num_courses; x++) { Connection.ChangeTable("CUR_CURSOS", null); Connection.ChangeSelect("SELECT CUR_ID_PK FROM CUR_CURSOS WHERE CUR_F_FINAL >= DATE_FORMAT(NOW(),'%Y-%m-%d') AND CUR_USR_ID_PK = " + Padre.getUsrID().ToString() + " ORDER BY CUR_NOMBRE ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } LISTA.Children.Add(new Course(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } } LISTA.Children.Add(new TaskBlankSpace()); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }
public TaskList(Formulario Padre, MySQL_DB Connection, int ID_Filtro) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; InitializeComponent(); this.Padre = Padre; this.Connection = Connection; this.ID_Filtro = ID_Filtro; this.Padre.Size = new System.Drawing.Size(476, 503); LISTA.Children.Add(new TaskBlankSpace()); switch (ID_Filtro) { case 0: //Fecha-Limite Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_task = Connection.countRows(); if (num_task > 0) { string separatordate = "Sin fecha"; if (!(string.IsNullOrEmpty(Connection.getData(0, 1)))) { separatordate = DateTime.Parse(Connection.getData(0, 1)).ToLongDateString(); if (DateTime.Parse(separatordate).CompareTo(DateTime.Now.Date) == 0) { LISTA.Children.Add(new TaskSeparator("Hoy, " + separatordate)); } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } for (int x = 0; x < num_task; x++) { Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } if (!(string.IsNullOrEmpty(Connection.getData(x, 1)))) { if (separatordate != DateTime.Parse(Connection.getData(x, 1)).ToLongDateString()) { separatordate = DateTime.Parse(Connection.getData(x, 1)).ToLongDateString(); LISTA.Children.Add(new TaskBlankSpace()); if (DateTime.Parse(separatordate).CompareTo(DateTime.Now.Date) == 0) { LISTA.Children.Add(new TaskSeparator("Hoy, " + separatordate)); } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } } } LISTA.Children.Add(new Task(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } break; case 1: //Asignatura Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO,ASG_NOMBRE FROM TAR_TAREAS LEFT OUTER JOIN ASG_ASIGNATURAS ON ASG_ID_PK = TAR_ASG_ID_PK WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY ASG_NOMBRE ASC, TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } num_task = Connection.countRows(); if (num_task > 0) { string separatorcourse = Connection.getData(0, 2); if (string.IsNullOrEmpty(separatorcourse)) { LISTA.Children.Add(new TaskSeparator("Otras tareas")); } else { LISTA.Children.Add(new TaskSeparator(Connection.getData(0, 2))); } for (int x = 0; x < num_task; x++) { Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO,ASG_NOMBRE FROM TAR_TAREAS LEFT OUTER JOIN ASG_ASIGNATURAS ON ASG_ID_PK = TAR_ASG_ID_PK WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY ASG_NOMBRE ASC, TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } if (separatorcourse != Connection.getData(x, 2)) { separatorcourse = Connection.getData(x, 2); LISTA.Children.Add(new TaskBlankSpace()); if (string.IsNullOrEmpty(separatorcourse)) { LISTA.Children.Add(new TaskSeparator("Otras tareas")); } else { LISTA.Children.Add(new TaskSeparator(separatorcourse)); } } LISTA.Children.Add(new Task(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } break; case 2: //Prioridad Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_PRIORIDAD FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_PRIORIDAD DESC, TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } num_task = Connection.countRows(); if (num_task > 0) { string separatorprioridad = Connection.getData(0, 1); switch (int.Parse(separatorprioridad)) { case 2: LISTA.Children.Add(new TaskSeparator("Prioridad Alta")); break; case 1: LISTA.Children.Add(new TaskSeparator("Prioridad Media")); break; case 0: LISTA.Children.Add(new TaskSeparator("Prioridad Baja")); break; } for (int x = 0; x < num_task; x++) { Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_PRIORIDAD FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_PRIORIDAD DESC, TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } if (separatorprioridad != Connection.getData(x, 1)) { separatorprioridad = Connection.getData(x, 1); LISTA.Children.Add(new TaskBlankSpace()); switch (int.Parse(separatorprioridad)) { case 2: LISTA.Children.Add(new TaskSeparator("Prioridad Alta")); break; case 1: LISTA.Children.Add(new TaskSeparator("Prioridad Media")); break; case 0: LISTA.Children.Add(new TaskSeparator("Prioridad Baja")); break; } } LISTA.Children.Add(new Task(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Visibility = Visibility.Visible; } break; case 3: //Completadas BTN_COMPLETADAS.Content = "Ver Pendientes"; Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND NOT ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } int num_task_completed = Connection.countRows(); if (num_task_completed > 0) { string separatordate = "Sin fecha"; if (!(string.IsNullOrEmpty(Connection.getData(0, 1)))) { separatordate = DateTime.Parse(Connection.getData(0, 1)).ToLongDateString(); if (DateTime.Parse(separatordate).CompareTo(DateTime.Now.Date) == 0) { LISTA.Children.Add(new TaskSeparator("Hoy, " + separatordate)); } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } for (int x = 0; x < num_task_completed; x++) { Connection.ChangeTable("TAR_TAREAS", null); Connection.ChangeSelect("SELECT TAR_ID_PK,TAR_F_OBJETIVO FROM TAR_TAREAS WHERE TAR_USR_ID_PK = " + Padre.getUsrID().ToString() + " AND NOT ISNULL(TAR_F_COMPLETADA) ORDER BY TAR_F_OBJETIVO ASC"); if (Connection.Conectar()) { Connection.Desconectar(); } if (!(string.IsNullOrEmpty(Connection.getData(x, 1)))) { if (separatordate != DateTime.Parse(Connection.getData(x, 1)).ToLongDateString()) { separatordate = DateTime.Parse(Connection.getData(x, 1)).ToLongDateString(); LISTA.Children.Add(new TaskBlankSpace()); if (DateTime.Parse(separatordate).CompareTo(DateTime.Now.Date) == 0) { LISTA.Children.Add(new TaskSeparator("Hoy, " + separatordate)); } else { LISTA.Children.Add(new TaskSeparator(separatordate)); } } } LISTA.Children.Add(new Task(Padre, Connection, int.Parse(Connection.getData(x, 0)))); } } else { LBL_NOTFOUND.Content = "No tienes tareas completadas"; LBL_NOTFOUND.Visibility = Visibility.Visible; } break; } LISTA.Children.Add(new TaskBlankSpace()); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }