Esempio n. 1
0
        public bool Insertar_Usuario(string Nombre, string Apellido, string Telefono, string Direccion, string Contraseña)
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Insert Into Usuario Values(((Select Count(Id) From Usuario)+1),'" + Nombre + "','" + Apellido + "','" + Telefono + "','" + Direccion + "','" + Encriptar.GetSHA1(Contraseña) + "','" + Tipo_Users + "')", Cadena);

                int query = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Alerta.MostrarNotificacion("Error", Ex.Message, 300);
            }

            return(false);
        }
Esempio n. 2
0
        public bool Insertar_Venta()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Insert Into Venta Values(((Select count(Id_Venta) From Venta)+1),'" + Nombre + "','" + Cantidad + "',(Select Id From Usuario Where Id ='" + Id_Usuario + "'),'" + String.Format("{0:d}", DateTime.Now.Date) + "','" + Total + "')", Cadena);

                int query = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0)
                {
                    Alerta.MostrarNotificacion("Venta", "Producto Vendido " + Nombre, 300);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Alerta.MostrarNotificacion("Error", Ex.Message, 300);
            }
            Cadena.Close();
            return(false);
        }
Esempio n. 3
0
        public bool Actualizar_Cantidad()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Update Inventario Set Cantidad = (Select (Select Cantidad From Inventario Where Producto='" + Nombre + "') - '" + Cantidad + "') Where Producto = '" + Nombre + "';", Cadena);
                int query = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0)
                {
                    Alerta.MostrarNotificacion("Venta", "Producto Vendido " + Nombre, 300);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            Cadena.Close();
            return(false);
        }
Esempio n. 4
0
        public bool Actualizar()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Update Inventario Set Producto='" + Nombre + "', Tipo='" + Tipo + "', Cantidad='" + Cantidad + "', Precio_Compra='" + Precio_Compra + "',Precio_Unitario='" + Precio_Unitario + "',Fecha_Compra='" + Fecha_Compra + "',Fecha_Vencimiento= '" + Fecha_Vencimiento + "' where Id= '" + Codigo + "'", Cadena);

                int query = Command.ExecuteNonQuery();

                Command = new SQLiteCommand("Update Costos_TP set Total_CP = (Select (Select Cantidad From Inventario Where Id='" + Codigo + "') * (Select Precio_Compra From Inventario Where Id='" + Codigo + "') Where Id_Producto='" + Codigo + "');", Cadena);

                int trigger = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0 && trigger > 0)
                {
                    Alerta.MostrarNotificacion("Actualizacion", "Producto " + Nombre + " Actualizado", 300);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            Cadena.Close();
            return(false);
        }
Esempio n. 5
0
        public bool Eliminar()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Delete From Inventario Where Id='" + Codigo + "'", Cadena);

                int query = Command.ExecuteNonQuery();

                Command = new SQLiteCommand("Delete From Costos_TP Where Id_Producto = '" + Codigo + "'", Cadena);

                int trigger = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0 && trigger > 0)
                {
                    Alerta.MostrarNotificacion("Eliminacion", "Producto Eliminado", 300);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            Cadena.Close();
            return(false);
        }
Esempio n. 6
0
        public bool Insert_Inventario()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Insert Into Inventario Values('" + Codigo + "','" + Upper.ConvertFirtsCharToUpperString(Nombre) + "','" + Upper.ConvertFirtsCharToUpperString(Tipo) + "','" + Cantidad + "','" + Precio_Compra + "','" + Precio_Unitario + "','" + String.Format("{0:d}", Fecha_Compra.Date) + "','" + String.Format("{0:d}", Fecha_Vencimiento.Date) + "');", Cadena);

                int query = Command.ExecuteNonQuery();

                Command = new SQLiteCommand("Insert Into Costos_TP Values(((Select Count(Id_Costo) From Costos_TP)+1),'" + Codigo + "',(Select (Select Cantidad From Inventario Where Id='" + Codigo + "') * (Select Precio_Compra From Inventario Where Id='" + Codigo + "')));", Cadena);

                int trigger = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0 && trigger > 0)
                {
                    Alerta.MostrarNotificacion("Insercion", "Producto " + Nombre + " Insertado", 300);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            return(false);
        }
Esempio n. 7
0
        public bool Actualizar_Usuario(string Nombre, string Apellido, string Telefono, string Direccion, string Contraseña)
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Update Usuario Set Nombre='" + Nombre + "',Apellido= '" + Apellido + "',Telefono='" + Telefono + "',Direccion='" + Direccion + "',Contrasena='" + Encriptar.GetSHA1(Contraseña) + "' Where Id='" + Id_Usuario + "'", Cadena);

                int query = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Alerta.MostrarNotificacion("Error", Ex.Message, 300);
            }

            return(false);
        }
Esempio n. 8
0
        public bool EliminarUsuario()
        {
            Conectar();
            try
            {
                Command = new SQLiteCommand("Delete From Usuario Where Id='" + Id_Usuario + "'", Cadena);

                int query = Command.ExecuteNonQuery();

                Cadena.Close();

                if (query > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SQLiteException Ex)
            {
                Alerta.MostrarNotificacion("Error", Ex.Message, 300);
            }

            return(false);
        }
Esempio n. 9
0
 void EliminarToolStripMenuItemClick(object sender, EventArgs e)
 {
     Co.Codigo = Id.ToString();
     Co.Conectar();
     if (Co.Eliminar())
     {
         ActualizarGrid();
         MessageBox.Show("Producto Eliminado");
         Alerta.MostrarNotificacion("Eliminacion", "Producto Eliminado", 300);
     }
     else
     {
         MessageBox.Show("Producto No Eliminado!!!");
     }
 }
Esempio n. 10
0
        public void Cargar_Usuarios(List <string> Pro)
        {
            Cadena.Open();
            try
            {
                Command = new SQLiteCommand("Select * From Usuario", Cadena);
                Reader  = Command.ExecuteReader();

                while (Reader.Read())
                {
                    Pro.Add(Reader["Nombre"].ToString());

                    Alerta.MostrarNotificacion("Iniciando", "Cargando Usuarios", 100);
                }
                Cadena.Close();
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            Cadena.Close();
        }
Esempio n. 11
0
 void MainFormLoad(object sender, EventArgs e)
 {
     Alerta.MostrarNotificacion("Saludos", "Bienvenida " + Usuario.Text, 300);
 }