Exemple #1
0
        public DataTable Buscar_Producto(string Nombre)
        {
            Conectar();
            try
            {
                Adacter = new SQLiteDataAdapter("Select * From Inventario Where Producto Like '" + Upper.ConvertFirtsCharToUpperString(Nombre) + "%'", Cadena);

                Tabla = new DataTable();

                Adacter.Fill(Tabla);

                Cadena.Close();

                return(Tabla);
            }
            catch (SQLiteException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            Cadena.Close();
            return(null);
        }
Exemple #2
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);
        }