Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Buenas tardes, estoy teniendo un inconveniente al crear un nuevo programa de control de productos. El programa que estoy haciendo según mi idea es:

- Un formulario principal que funcionará como menú seleccionador
- Formularios hijos los cuales se abrirán dentro del formulario principal a medida que vaya necesitando el oficinista.

Mi problema es que el programa necesita realizar lo siguiente
- Stock.frm : Carga la lista del stock (Codigo y Nombre) (Hecho)
- Promos.frm: En base a la lista de stock, puede configurar una promoción con uno o más productos (stock), de esta forma se crea la promoción. Son hasta 5 productos que puede contener una promoción y había pensado 5 ComboBox, pero lo que no sé es como usar la información cargada al principio para el segundo formulario (Falta esto)

Adjunto partes del código

Translated:
Good afternoon, I'm having a problem creating a new product control program. The program I'm doing according to my idea is:

- A main form that will function as a selector menu
- Child forms which will be opened within the main form as the office member needs.

My problem is that the program needs to do the following
- Stock.frm : Loads the stock list (Code and Name) (Done)
- Promos.frm: Based on the stock list, you can set up a promotion with one or more products (stock), this creates the promotion. There are up to 5 products that can contain a promotion and I had thought 5 ComboBox, but what I do not know is how to use the information loaded at the beginning for the second form (This is missing)

Attached parts of the code
VB
Private ConnectionSQ As SQLiteConnection

Private Const ConnectionString As String = "Data Source=ControlBar.db;Version=3;"


' Tabla Stock
Public Const QueryStock As String = "SELECT * from Stock"
Public Const QueryInsertStock As String = "INSERT INTO Stock"
Public Const QueryUpdateStock As String = "UPDATE Stock"



Public Sub LoadDB()
    ' Iniciamos la base de datos
    ConnectionSQ = New SQLiteConnection(ConnectionString)
    ConnectionSQ.Open()

End Sub
Public Function WriteCommand(ByVal Query As String, ByRef DataAdapter As SQLiteDataAdapter, ByRef DataTable As DataTable) As DataTable
    Dim CommandSQ As New SQLiteCommand(Query, ConnectionSQ)

    CommandSQ = ConnectionSQ.CreateCommand()
    CommandSQ.CommandText = Query

    DataAdapter.SelectCommand = CommandSQ
    DataAdapter.Fill(DataTable)


    Return DataTable
End Function



Averigue que puedo usar el componente BindingSource

Translated:
Find out I can use the BindingSource component

VB
Private BS As New BindingSource

    Sub Main()
        Form1.Show()

        DB.LoadDB()
        BS.DataSource = DB.WriteCommand(QueryStock, AdapterStock, TableStock)
    End Sub


Otra cosa es que en el formulario le puse las siguientes lineas, para luego poder usarlas y volver a actualizar la SQLITE.¿Está bien o hay formas mejores de realizar lo que necesito hacer?

Translated:
Another thing is that in the form I put the following lines, and then be able to use them and update the SQLITE.Is it okay or are there better ways to do what I need to do?
VB
Private AdapterStock As New SQLiteDataAdapter
    Private TableStock As New DataTable




Preguntas
Si yo necesito primero cargar un stock modificable en un dataviewgrid, y luego crear promociones donde yo pueda seleccionar de una lista (que contendrá todo el stock) y así ir armando las promociones ¿Que me recomiendan o que necesito? Porque a mi se me ocurre crear los combobox necesarios y a cada uno ponerles la misma lista que el dataviewgrid, pero por ejemplo:

Si mi dataviewgrid carga lo siguiente:

Translated:
Questions
If I need to first load a modifiable stock into a dataviewgrid, and then create promotions where I can select from a list (which will contain all the stock) and thus go to assemble the promotions What do you recommend or need? Because I can think of creating the necessary comboboxes and each one putting the same list as the dataviewgrid, but for example:

If my dataviewgrid loads the following:
ID|NOMBRE|DEPOSITO1|DEPOSITO2|DEPOSITO3

Yo para el combobox, solo necesito un identificador y un nombre, para que el cliente/oficinista, seleccione y elija donde por ejemplo diga "Producto n°10" y no que aparezca "ID|NOMBRE|DEPOSITO" sino que solo el nombre. Pero despues ¿Cómo guardaria la promoción en la SqLite? Como para que el día de mañana, una vez formada la promoción y esté cargada, al seleccionarla aparezca la lista de stocks con la cual está conformada.. No se si me explico ¡Espero sus opiniones para llevar a cabo mi proyecto!

Translated:
For the combobox, I just need an identifier and a name, for the client/office worker, to select and choose where for example it says "Product no.10" and not to appear "ID" NAME DEPOSITO" but only the name. But then how would I save the promotion in SqLite? So that tomorrow, once the promotion is formed and loaded, when you select it, the list of stocks with which it is formed appears. I don't know if I explain, I look forward to your feedback to carry out my project!

What I have tried:

En base a

Based on:
VB
Private BS As New BindingSource


Pasarlo a Public, DECLARARLO en otro módulo general y luego usarlo desde cualquier formulario por ejemplo

Translated:
Pass it to Public, DECLARE it in another general module and then use it from any form for example

VB
public BS_Stock as new bindingsource


y luego en cualquier formulario poner

Translated:
and then on any form put

VB
ComboBox1.DataSource = BS_Stock.DataSource


Pero no carga nada, por lo cual volvi a probar nuevamente esto, pero con la diferencia de que lo probé sobre el mismo formulario. Y ahí lo que me mostraba el combobox Eran los elementos del dataviewgrid, pero no escrito

Translated:
But it doesn't load anything, so I tried this again, but with the difference that I tried it on the same form. And there what the combobox showed me were the elements of the dataviewgrid, but not written
Posted
Updated 13-Oct-19 17:22pm
v2
Comments
LautaroSoft 14-Oct-19 1:29am    
One idea
https://i.imgur.com/rVxdolZ.png[^]

The first idea is based on the previously created DataGridView. Dragging the selected item to one of the ComboBox

Is it a good idea to do so? Then I need to save the promotion created in another table, saving previously dragged IDS or NAMES.

What do you think?

Two idea
https://i.imgur.com/5rGvu4G.png[^]

The second idea would be to drag from DataViewGrid1 to DataViewGrid2. With the possibility of only dragging the selected element of the DataViewGrid1 and not all the elements. I think this way is more professional and will make things easier for me. Can you help me carry it out? Thank you I look forward to your opinions!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900