This commit is contained in:
Michael Robles
2024-07-07 11:27:40 -07:00
parent e04f2b793a
commit d60d438d38
9 changed files with 34 additions and 9 deletions
Binary file not shown.
+29 -7
View File
@@ -26,7 +26,6 @@ namespace compabetov2
{ {
private int numeroPagina = 1; // Variable para rastrear el número de página actual private int numeroPagina = 1; // Variable para rastrear el número de página actual
private Point lastPoint; private Point lastPoint;
private Point lastAutoScrollPosition;
private List<Variante> productos; private List<Variante> productos;
public decimal total = 0; public decimal total = 0;
private LoginModel loginPrincipal; private LoginModel loginPrincipal;
@@ -48,6 +47,9 @@ namespace compabetov2
private void InitializeFlowLayout() private void InitializeFlowLayout()
{ {
flowLayoutPanel3.AutoScroll = true;
// Inicializar el flowLayoutPanel3 (asegúrate de que ya está creado en tu formulario) // Inicializar el flowLayoutPanel3 (asegúrate de que ya está creado en tu formulario)
// Habilitar eventos táctiles simulados // Habilitar eventos táctiles simulados
@@ -59,7 +61,7 @@ namespace compabetov2
private void FlowLayoutPanel3_MouseDown(object sender, MouseEventArgs e) private void FlowLayoutPanel3_MouseDown(object sender, MouseEventArgs e)
{ {
lastPoint = new Point(e.X, e.Y); lastPoint = new Point(e.X, e.Y);
flowLayoutPanel3.Capture = false; flowLayoutPanel3.Capture = true;
} }
private void FlowLayoutPanel3_MouseMove(object sender, MouseEventArgs e) private void FlowLayoutPanel3_MouseMove(object sender, MouseEventArgs e)
@@ -70,7 +72,11 @@ namespace compabetov2
int deltaY = lastPoint.Y - e.Y; int deltaY = lastPoint.Y - e.Y;
// Ajustar la dirección del desplazamiento // Ajustar la dirección del desplazamiento
flowLayoutPanel3.AutoScrollPosition = new Point(flowLayoutPanel3.AutoScrollPosition.X + deltaX, flowLayoutPanel3.AutoScrollPosition.Y - deltaY); Point scrollPosition = flowLayoutPanel3.AutoScrollPosition;
scrollPosition.Offset(deltaX, deltaY);
// Ajustar la posición de desplazamiento
flowLayoutPanel3.AutoScrollPosition = new Point(-scrollPosition.X, -scrollPosition.Y);
lastPoint = new Point(e.X, e.Y); lastPoint = new Point(e.X, e.Y);
} }
@@ -79,8 +85,7 @@ namespace compabetov2
private void FlowLayoutPanel3_MouseUp(object sender, MouseEventArgs e) private void FlowLayoutPanel3_MouseUp(object sender, MouseEventArgs e)
{ {
lastPoint = new Point(e.X, e.Y); flowLayoutPanel3.Capture = false;
flowLayoutPanel3.Capture =false;
} }
@@ -137,7 +142,7 @@ namespace compabetov2
pic.Controls.Add(id); pic.Controls.Add(id);
Label precio = new Label(); Label precio = new Label();
precio.Text = "$" + producto.precio.ToString() + " - " + producto.nombre; precio.Text = "$" + producto.precioCompra.ToString() + " - " + producto.nombre;
precio.BackColor = Color.FromArgb(82, 82, 82); precio.BackColor = Color.FromArgb(82, 82, 82);
precio.ForeColor = Color.White; precio.ForeColor = Color.White;
precio.Width = 40; precio.Width = 40;
@@ -170,6 +175,10 @@ namespace compabetov2
btnMenos.BackColor = Color.FromArgb(33, 90, 255); btnMenos.BackColor = Color.FromArgb(33, 90, 255);
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e) btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
{ {
flowLayoutPanel3.MouseMove -= FlowLayoutPanel3_MouseMove; // Desactivar el evento MouseMove temporalmente
Point scrollPosition = flowLayoutPanel3.AutoScrollPosition; // Guardar posición de scroll actual
int numeroContador = int.Parse(contador.Text.ToString()); int numeroContador = int.Parse(contador.Text.ToString());
@@ -196,7 +205,11 @@ namespace compabetov2
{ {
MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
});
flowLayoutPanel3.AutoScrollPosition = new Point(-scrollPosition.X, -scrollPosition.Y); // Restaurar posición de scroll
flowLayoutPanel3.MouseMove += FlowLayoutPanel3_MouseMove; // Reactivar el evento MouseMove
});
@@ -213,6 +226,11 @@ namespace compabetov2
btnMas.FlatAppearance.BorderSize = 0; btnMas.FlatAppearance.BorderSize = 0;
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e) btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
{ {
flowLayoutPanel3.MouseMove -= FlowLayoutPanel3_MouseMove; // Desactivar el evento MouseMove temporalmente
Point scrollPosition = flowLayoutPanel3.AutoScrollPosition; // Guardar posición de scroll actual
if (int.Parse(contador.Text.ToString()) < 0 && !existeTocket(producto.nombre)) if (int.Parse(contador.Text.ToString()) < 0 && !existeTocket(producto.nombre))
{ {
contador.Text = "0"; contador.Text = "0";
@@ -237,6 +255,10 @@ namespace compabetov2
} }
GenerarTicket(idProducto, producto.nombre, producto.precio, int.Parse(contador.Text), total, GenerarTicket(idProducto, producto.nombre, producto.precio, int.Parse(contador.Text), total,
Path.Combine(Application.StartupPath, "Resources", producto.img)); Path.Combine(Application.StartupPath, "Resources", producto.img));
flowLayoutPanel3.AutoScrollPosition = new Point(-scrollPosition.X, -scrollPosition.Y); // Restaurar posición de scroll
flowLayoutPanel3.MouseMove += FlowLayoutPanel3_MouseMove; // Reactivar el evento MouseMove
}); });
HUD.Controls.Add(btnMenos); HUD.Controls.Add(btnMenos);
Binary file not shown.
Binary file not shown.
+3 -2
View File
@@ -512,7 +512,8 @@ namespace compabetov2.database
int cantidadIndex = reader.GetOrdinal("cantidad"); int cantidadIndex = reader.GetOrdinal("cantidad");
int imgIndex = reader.GetOrdinal("img"); int imgIndex = reader.GetOrdinal("img");
int fkProductoIndex = reader.GetOrdinal("fk_producto"); int fkProductoIndex = reader.GetOrdinal("fk_producto");
decimal precioCompra = reader.GetOrdinal("precioCompra"); int precioCompraIndex = reader.GetOrdinal("precioCompra");
while (reader.Read()) while (reader.Read())
{ {
@@ -524,7 +525,7 @@ namespace compabetov2.database
reader.GetInt32(cantidadIndex), reader.GetInt32(cantidadIndex),
reader.GetString(imgIndex), reader.GetString(imgIndex),
reader.GetInt32(fkProductoIndex), reader.GetInt32(fkProductoIndex),
precioCompra reader.GetDecimal(precioCompraIndex)
); );
productos.Add(producto); productos.Add(producto);
Binary file not shown.
@@ -180,3 +180,5 @@ C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.a
C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.RegistroVentas.resources C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.RegistroVentas.resources
C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.Ventas.Importe.resources C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.Ventas.Importe.resources
C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.Ventas.Importe1.resources C:\Users\compa\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.Ventas.Importe1.resources
C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.AgregarImporte.resources
C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.visualizarImportes.resources
Binary file not shown.
Binary file not shown.