Cada vez más cercas del fina3
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -231,6 +231,47 @@ namespace compabetov2.database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool aumentarStockDAO(List<Producto> stockNuevo)
|
||||||
|
{
|
||||||
|
var db_conexion = new Conexion();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||||
|
{
|
||||||
|
conexion.Open();
|
||||||
|
|
||||||
|
using(var transaccion = conexion.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var item in stockNuevo)
|
||||||
|
{
|
||||||
|
string sql = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto;";
|
||||||
|
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||||
|
command.Parameters.AddWithValue("@idproducto", item.idProducto);
|
||||||
|
command.Parameters.AddWithValue("@stock", item.stock);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
transaccion.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(SQLiteException ex)
|
||||||
|
{
|
||||||
|
transaccion.Rollback();
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLiteException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool insertarCategoriaDAO(Categoria categoria)
|
public static bool insertarCategoriaDAO(Categoria categoria)
|
||||||
{
|
{
|
||||||
var db_conexion = new Conexion();
|
var db_conexion = new Conexion();
|
||||||
|
|||||||
+4
-1
@@ -125,8 +125,11 @@ namespace compabetov2.database
|
|||||||
return empleados;
|
return empleados;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool aumentarStock(List<Producto> stockNuevo)
|
||||||
|
{
|
||||||
|
return DAO.aumentarStockDAO(stockNuevo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1
@@ -214,6 +214,7 @@
|
|||||||
this.Name = "inventario";
|
this.Name = "inventario";
|
||||||
this.Text = "inventario";
|
this.Text = "inventario";
|
||||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||||
|
this.Load += new System.EventHandler(this.inventario_Load);
|
||||||
this.flowLayoutPanel1.ResumeLayout(false);
|
this.flowLayoutPanel1.ResumeLayout(false);
|
||||||
this.panel2.ResumeLayout(false);
|
this.panel2.ResumeLayout(false);
|
||||||
this.panel2.PerformLayout();
|
this.panel2.PerformLayout();
|
||||||
|
|||||||
+18
-4
@@ -27,6 +27,7 @@ namespace compabetov2
|
|||||||
|
|
||||||
private void llenarPanel()
|
private void llenarPanel()
|
||||||
{
|
{
|
||||||
|
stockPanel.Controls.Clear();
|
||||||
productos = service.conseguirProductos();
|
productos = service.conseguirProductos();
|
||||||
|
|
||||||
foreach (Producto producto in productos)
|
foreach (Producto producto in productos)
|
||||||
@@ -179,24 +180,37 @@ namespace compabetov2
|
|||||||
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
||||||
int stock = int.Parse(txtStock.Text);
|
int stock = int.Parse(txtStock.Text);
|
||||||
|
|
||||||
|
if(stock > 0) {
|
||||||
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
||||||
stockNuevo.Add(productoStockNuuevo);
|
stockNuevo.Add(productoStockNuuevo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
||||||
for(int i = 0; i < stockNuevo.Count; i++)
|
for(int i = 0; i < stockNuevo.Count; i++)
|
||||||
{
|
{
|
||||||
if (stockNuevo[i].stock > 0)
|
|
||||||
{
|
|
||||||
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(stockNuevo.Count > 0)
|
||||||
|
{
|
||||||
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
// Código para realizar la acción
|
service.aumentarStock(stockNuevo);
|
||||||
|
llenarPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inventario_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
953cb31f9b6e74dde952aba09707a9add648ded1
|
424f6d4f8bcbc47e89c98d2fa689cb77dffd9f6b5116717e9e8dca5ece3777d7
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+19
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -18,6 +19,7 @@ namespace compabetov2
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
llenarGrid();
|
llenarGrid();
|
||||||
|
limpiarCampos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,6 +123,23 @@ namespace compabetov2
|
|||||||
btnEliminar.Enabled = false;
|
btnEliminar.Enabled = false;
|
||||||
btnAgregar.Enabled = true;
|
btnAgregar.Enabled = true;
|
||||||
dataGridView1.Enabled = false;
|
dataGridView1.Enabled = false;
|
||||||
|
limpiarCampos();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void limpiarCampos()
|
||||||
|
{
|
||||||
|
txtnombrepersonal.Text = "";
|
||||||
|
txtapellidopersonal.Text = "";
|
||||||
|
dtpfechapersonal.Text = "";
|
||||||
|
cbestadopersonal.Text = "";
|
||||||
|
txtcallepersonal.Text = "";
|
||||||
|
txtcoloniapersonal.Text = "";
|
||||||
|
txtcodigopersonal.Text = "";
|
||||||
|
txtnoextpersonal.Text = "";
|
||||||
|
txtnointpersonal.Text = "";
|
||||||
|
txtreferenciapersonal.Text = "";
|
||||||
|
dtpnacimientopersonal.Text = "";
|
||||||
|
txttelefonopersonal.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Data;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -54,7 +55,8 @@ namespace compabetov2
|
|||||||
PictureBox pic = new PictureBox();
|
PictureBox pic = new PictureBox();
|
||||||
pic.Dock = DockStyle.Fill;
|
pic.Dock = DockStyle.Fill;
|
||||||
pic.SizeMode = PictureBoxSizeMode.Zoom;
|
pic.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
pic.Image = Properties.Resources.Modelo;
|
string rutaImg = Path.Combine(Application.StartupPath, "Resources", producto.img);
|
||||||
|
pic.Image = Image.FromFile(rutaImg);
|
||||||
pic.BackgroundImageLayout = ImageLayout.Stretch;
|
pic.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
pic.Tag = producto.idProducto;
|
pic.Tag = producto.idProducto;
|
||||||
|
|
||||||
@@ -140,7 +142,7 @@ namespace compabetov2
|
|||||||
|
|
||||||
// Obtener información del Label id y precio
|
// Obtener información del Label id y precio
|
||||||
int idProducto = int.Parse(id.Text);
|
int idProducto = int.Parse(id.Text);
|
||||||
decimal precioProducto;
|
decimal precioProducto = producto.precion;
|
||||||
if (decimal.TryParse(precio.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out precioProducto))
|
if (decimal.TryParse(precio.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out precioProducto))
|
||||||
{
|
{
|
||||||
// Generar ticket y agregarlo al flowLayoutPanel2
|
// Generar ticket y agregarlo al flowLayoutPanel2
|
||||||
@@ -149,7 +151,7 @@ namespace compabetov2
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Manejar el caso en el que la conversión no sea exitosa
|
// Manejar el caso en el que la conversión no sea exitosa
|
||||||
MessageBox.Show("Formato de precio no válido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
//MessageBox.Show("Formato de precio no válido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generar ticket y agregarlo al flowLayoutPanel2
|
// Generar ticket y agregarlo al flowLayoutPanel2
|
||||||
|
|||||||
Reference in New Issue
Block a user