Example #1
0
        public string AdoEditar()
        {
            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "adoDB_SBX.db3");
                bool   exists = File.Exists(dbPath);

                if (exists)
                {
                    connection = new SqliteConnection("Data Source=" + dbPath);
                    connection.Open();

                    var commandsInsert = new[] {
                        " UPDATE  [Cliente] SET [Nombre] = '" + Nombre + "',[Ciudad] = '" + Ciudad + "',[Direccion] = '" + Direccion + "',[Telefono] = '" + Telefono + "',[Celular] = '" + Celular + "',[Email] = '" + Email + "',[SitioWeb] = '" + SitioWeb + "' " +
                        " WHERE  [DNI] = '" + DNI.Trim() + "'"
                    };
                    foreach (var command in commandsInsert)
                    {
                        using (var c = connection.CreateCommand())
                        {
                            c.CommandText = command;
                            var i = c.ExecuteNonQuery();
                        }
                    }

                    output = "Cliente Editado correctamente";
                    connection.Close();
                }
                else
                {
                    output += "No existe base de datos";
                }
            }
            catch (Exception ex)
            {
                output = "Error: " + ex.Message;
            }

            return(output);
        }
Example #2
0
        public string AdoEliminar()
        {
            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "adoDB_SBX.db3");
                bool   exists = File.Exists(dbPath);

                if (exists)
                {
                    connection = new SqliteConnection("Data Source=" + dbPath);
                    connection.Open();

                    var commandsInsert = new[] {
                        " DELETE FROM  [Cliente] " +
                        " WHERE  [DNI] = '" + DNI.Trim() + "'"
                    };
                    foreach (var command in commandsInsert)
                    {
                        using (var c = connection.CreateCommand())
                        {
                            c.CommandText = command;
                            var i = c.ExecuteNonQuery();
                        }
                    }

                    output = "Cliente eliminado correctamente";
                    connection.Close();
                }
                else
                {
                    output += "No existe base de datos";
                }
            }
            catch (Exception ex)
            {
                output = "Error: " + ex.Message;
            }

            return(output);
        }