Example #1
0
        private void crearRecordatorio(String horaR)
        {
            String[]          fechaC       = fechaR.ToShortDateString().Split('/');
            string            fechaBD      = fechaC[2] + "/" + fechaC[1] + "/" + fechaC[0];
            String            archivo      = fechaC[0] + "-" + fechaC[1] + "-" + fechaC[2];
            String            path         = Path.Combine(Application.StartupPath, @"Eventos\" + "R" + archivo + ".age");
            string            conexion     = "Data Source=localhost;Initial Catalog=agenda;Allow User Variables=True;Persist Security Info=True;User ID=root;Password="******"call agregarRecordatorio('" + idE + "','" + fechaBD + "','" + horaR + "')";

            simpleAccess.ExecuteNonQuery(sql);
            sql = "SELECT MAX(idR) as id from recordatorio";
            var idRR = simpleAccess.ExecuteReader(sql);

            while (idRR.Read())
            {
                idR = (int)idRR["id"];
            }
            if (File.Exists(path))
            {
                using (StreamWriter writer = File.AppendText(path))
                {
                    writer.WriteLine("idR+" + idR);
                    writer.WriteLine("-idE+" + idE);
                    writer.WriteLine("-fechaR+" + fechaBD);
                    writer.WriteLine("-horaR+" + horaR);
                    writer.WriteLine("-evento+" + mTxtNombre.Text);
                    writer.WriteLine("-estado+" + "1");
                    writer.WriteLine(";");
                    writer.Close();
                }
            }
            else
            {
                using (StreamWriter writer = File.CreateText(path))
                {
                    writer.WriteLine("idR+" + idR);
                    writer.WriteLine("-idE+" + idE);
                    writer.WriteLine("-fechaR+" + fechaR);
                    writer.WriteLine("-horaR+" + horaR);
                    writer.WriteLine("-evento+" + mTxtNombre.Text);
                    writer.WriteLine("-estado+" + "1");
                    writer.WriteLine(";");
                    writer.Close();
                }
            }
        }
Example #2
0
        private void crearEvento()
        {
            String[]          fechaC        = fecha.Split('/');
            string            fechaNFormato = fechaC[2] + "/" + fechaC[1] + "/" + fechaC[0];
            String            archivo       = fechaC[0] + "-" + fechaC[1] + "-" + fechaC[2];
            String            path          = Path.Combine(Application.StartupPath, @"Eventos\" + archivo + ".age");
            String            nombre        = mTxtNombre.Text;
            string            conexion      = "Data Source=localhost;Initial Catalog=agenda;Allow User Variables=True;Persist Security Info=True;User ID=root;Password="******"call insertarEvento('" + nombre + "','" + fechaNFormato + "')";

            simpleAccess.ExecuteNonQuery(sql);
            sql = "SELECT MAX(idE) as id FROM evento";
            var idEe = simpleAccess.ExecuteReader(sql);

            while (idEe.Read())
            {
                idE = (int)idEe["id"];
            }
            simpleAccess.CloseDbConnection();
            if (File.Exists(path))
            {
                using (StreamWriter writer = File.AppendText(path))
                {
                    writer.WriteLine("idE+" + idE);
                    writer.WriteLine("-nombre+" + nombre);
                    writer.WriteLine("-fechaInicio+" + fechaNFormato);
                    writer.WriteLine(";");
                    writer.Close();
                }
            }
            else
            {
                using (StreamWriter writer = File.CreateText(path))
                {
                    writer.WriteLine("idE+" + idE);
                    writer.WriteLine("-nombre+" + nombre);
                    writer.WriteLine("-fechaInicio+" + fechaNFormato);
                    writer.WriteLine(";");
                    writer.Close();
                }
            }
            MessageBox.Show("Evento registrado");
        }
Example #3
0
        public void llenarTree()
        {
            treeView1.Nodes.Clear();
            //Se obtiene la fecha en base al label para nombrar el archivo
            String fecha = mLblFecha.Text;

            String[]          fechaC       = fecha.Split('/');
            string            fechaForm    = fechaC[2] + "/" + fechaC[1] + "/" + fechaC[0];
            string            conexion     = "Data Source=localhost;Initial Catalog=agenda;Allow Zero Datetime=true;Persist Security Info=True;User ID=root;Password="******"call verEvento('" + fechaForm + "')";
            var datos = simpleAccess.ExecuteReader(sql);

            treeView1.BeginUpdate();
            int r = 0;

            while (datos.Read())
            {
                string nombre = (string)datos["nombre"];
                int    id     = (int)datos["idE"];
                string nodoP  = nombre.Trim();
                treeView1.Nodes.Add(nodoP);
                sql = "call recordatoriosEvento(" + id + ")";
                MySqlSimpleAccess otroAccess = new MySqlSimpleAccess(conexion);
                var recordatorios            = otroAccess.ExecuteReader(sql);
                while (recordatorios.Read())
                {
                    string   fechaR        = recordatorios["fechaRecordatorio"].ToString();
                    TimeSpan horaR         = (TimeSpan)recordatorios["horaRecordatorio"];
                    String   recordatorioF = ("Recordatorio " + fechaR + " " + horaR).Trim();
                    treeView1.Nodes[r].Nodes.Add(recordatorioF);
                }
                r++;
                otroAccess.CloseDbConnection();
            }
            treeView1.EndUpdate();
            simpleAccess.CloseDbConnection();
        }
Example #4
0
 private async Task bd()
 {
     string            conexion     = "Data Source=localhost;Initial Catalog=agenda;Persist Security Info=True;User ID=root;Password="******"Eventos"), "*.age");
     await Task.Run(() =>
     {
         simpleAccess.ExecuteNonQuery("call reiniciar()");
         foreach (string txt in txtFiles)
         {
             StreamReader objRead  = new StreamReader(txt);
             ArrayList lineasTexto = new ArrayList();
             string sLine          = "";
             string evento         = "";
             string sql            = "";
             if (txt.Contains("parent"))
             {
                 while (sLine != null)
                 {
                     sLine = objRead.ReadLine();
                     if (sLine != null)
                     {
                         sql = "call insertarParent('" + sLine.ToString() + "')";
                     }
                 }
                 objRead.Close();
                 simpleAccess.ExecuteNonQuery(sql);
             }
             else if (txt.Contains("R"))
             {
                 while (sLine != null)
                 {
                     sLine = objRead.ReadLine();
                     if (sLine != null)
                     {
                         lineasTexto.Add(sLine);
                     }
                 }
                 objRead.Close();
                 foreach (String linea in lineasTexto)
                 {
                     evento += linea;
                 }
                 string[] eventos = evento.Split(';');
                 foreach (string eventoCompleto in eventos)
                 {
                     if (eventoCompleto != "")
                     {
                         string[] linea    = eventoCompleto.Split('-');
                         string[] idrCV    = linea[0].Split('+');
                         string[] ideCV    = linea[1].Split('+');
                         string[] fechaCV  = linea[2].Split('+');
                         string[] horaCV   = linea[3].Split('+');
                         string[] estadoCV = linea[5].Split('+');
                         sql = "call registroRecordatorioRespaldo('" + idrCV[1] + "','" + ideCV[1] + "','" + fechaCV[1] + "','" + horaCV[1] + "','" + estadoCV[1] + "')";
                         simpleAccess.ExecuteNonQuery(sql);
                     }
                 }
             }
             else
             {
                 while (sLine != null)
                 {
                     sLine = objRead.ReadLine();
                     if (sLine != null)
                     {
                         lineasTexto.Add(sLine);
                     }
                 }
                 objRead.Close();
                 foreach (String linea in lineasTexto)
                 {
                     evento += linea;
                 }
                 string[] eventos = evento.Split(';');
                 foreach (string eventoCompleto in eventos)
                 {
                     if (eventoCompleto != "")
                     {
                         string[] linea    = eventoCompleto.Split('-');
                         string[] idCV     = linea[0].Split('+');
                         string[] nombreCV = linea[1].Split('+');
                         string[] fechaCV  = linea[2].Split('+');
                         sql = "call insertarEventoRespaldo('" + idCV[1] + "','" + nombreCV[1] + "','" + fechaCV[1] + "')";
                         simpleAccess.ExecuteNonQuery(sql);
                     }
                 }
             }
         }
         simpleAccess.CloseDbConnection();
         MessageBox.Show("Eventos restaurados");
     });
 }
Example #5
0
        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            DateTime fechaHoy = DateTime.Today;
            string   fechaFormateada;
            int      dia   = fechaHoy.Day;
            int      mes   = fechaHoy.Month;
            int      annio = fechaHoy.Year;

            if (dia <= 9)
            {
                string diaTexto = "0" + dia;
                fechaFormateada = diaTexto + "-" + mes + "-" + annio;
            }
            else
            {
                fechaFormateada = dia + "-" + mes + "-" + annio;
            }
            string       pathR = Path.Combine(Application.StartupPath, @"Eventos\" + "R" + fechaFormateada + ".age");
            string       sLine = "", completo = "";
            StreamReader objRead     = new StreamReader(pathR);
            ArrayList    lineasTexto = new ArrayList();

            while (sLine != null)
            {
                sLine = objRead.ReadLine();
                if (sLine != null)
                {
                    lineasTexto.Add(sLine);
                }
            }
            objRead.Close();
            foreach (String linea in lineasTexto)
            {
                completo += linea;
            }
            string[] recordatorios = completo.Split(';');
            File.Delete(pathR);
            foreach (string recordatorio in recordatorios)
            {
                if (recordatorio != "")
                {
                    string[] claves = recordatorio.Split('-');
                    //Se obtiene fecha y hora del recordatorio
                    string[] eventoId = claves[0].Split('+');
                    if (eventoId[1] == idE)
                    {
                        using (StreamWriter writer = File.AppendText(pathR))
                        {
                            int repeticion = 0;
                            foreach (string clave in claves)
                            {
                                if (repeticion == 0)
                                {
                                    string[] valores = clave.Split('+');
                                    writer.WriteLine(valores[0] + "+" + valores[1]);
                                }
                                else if (repeticion == 5)
                                {
                                    string[] valores = clave.Split('+');
                                    writer.WriteLine("-" + valores[0] + "+0");
                                }
                                else
                                {
                                    string[] valores = clave.Split('+');
                                    writer.WriteLine("-" + valores[0] + "+" + valores[1]);
                                }
                                repeticion++;
                            }
                            writer.WriteLine(";");
                            writer.Close();
                        }
                    }
                    else
                    {
                        using (StreamWriter writer = File.AppendText(pathR))
                        {
                            int repeticion = 0;
                            foreach (string clave in claves)
                            {
                                if (repeticion == 0)
                                {
                                    string[] valores = clave.Split('+');
                                    writer.WriteLine(valores[0] + "+" + valores[1]);
                                }
                                else
                                {
                                    string[] valores = clave.Split('+');
                                    writer.WriteLine("-" + valores[0] + "+" + valores[1]);
                                }
                                repeticion++;
                            }
                            writer.WriteLine(";");
                            writer.Close();
                        }
                    }
                    this.Hide();
                }
            }
            string            conexion     = "Data Source=localhost;Initial Catalog=agenda;Persist Security Info=True;User ID=root;Password="******"call desactivarR(" + idE + ")";

            simpleAccess.ExecuteNonQuery(sql);
            simpleAccess.CloseDbConnection();
        }