descargo detalles1
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
],
|
||||
<<<<<<< HEAD
|
||||
"SelectedNode": "\\Solution.sln",
|
||||
=======
|
||||
"SelectedNode": "\\envios.cs",
|
||||
>>>>>>> 010f91469a9ca650f92e32a39a66a4e1428f5b62
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
Generated
+8
@@ -46,6 +46,7 @@
|
||||
//
|
||||
this.panel2.BackColor = System.Drawing.Color.Transparent;
|
||||
this.panel2.Controls.Add(this.pictureBox7);
|
||||
|
||||
this.panel2.Location = new System.Drawing.Point(3, 2);
|
||||
this.panel2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panel2.Name = "panel2";
|
||||
@@ -72,6 +73,7 @@
|
||||
this.button1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.button1.Image = global::compabetov2.Properties.Resources.Menui1;
|
||||
this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
||||
this.button1.Location = new System.Drawing.Point(3, 269);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.button1.Name = "button1";
|
||||
@@ -91,8 +93,10 @@
|
||||
this.button2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.button2.Image = global::compabetov2.Properties.Resources.estadisticasi;
|
||||
this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
||||
this.button2.Location = new System.Drawing.Point(3, 387);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
|
||||
this.button2.Size = new System.Drawing.Size(312, 114);
|
||||
@@ -110,6 +114,7 @@
|
||||
this.button3.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.button3.Image = global::compabetov2.Properties.Resources.productoi;
|
||||
this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
||||
this.button3.Location = new System.Drawing.Point(3, 505);
|
||||
this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.button3.Name = "button3";
|
||||
@@ -128,6 +133,7 @@
|
||||
this.button4.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.button4.Image = global::compabetov2.Properties.Resources.reportesi;
|
||||
this.button4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
||||
this.button4.Location = new System.Drawing.Point(3, 623);
|
||||
this.button4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.button4.Name = "button4";
|
||||
@@ -146,6 +152,7 @@
|
||||
this.button5.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.button5.Image = global::compabetov2.Properties.Resources.sesionc;
|
||||
this.button5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
||||
this.button5.Location = new System.Drawing.Point(3, 741);
|
||||
this.button5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.button5.Name = "button5";
|
||||
@@ -190,6 +197,7 @@
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "cuentas";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.cuentas_Load);
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
|
||||
|
||||
+42
-7
@@ -51,6 +51,7 @@ namespace compabetov2
|
||||
private void llenarPanel()
|
||||
{
|
||||
List<Cuenta> cuentas = service.conseguirCuentaDAO();
|
||||
panelCuenta.Controls.Clear();
|
||||
|
||||
foreach (Cuenta cuenta in cuentas)
|
||||
{
|
||||
@@ -59,8 +60,8 @@ namespace compabetov2
|
||||
carta.ColumnCount = 2;
|
||||
carta.Height = 100;
|
||||
carta.Width = 820;
|
||||
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 70F));
|
||||
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F));
|
||||
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 55F));
|
||||
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 45F));
|
||||
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
carta.BackColor = Color.Gray;
|
||||
|
||||
@@ -90,9 +91,10 @@ namespace compabetov2
|
||||
TableLayoutPanel HUDPanel = new TableLayoutPanel();
|
||||
HUDPanel.Dock = DockStyle.Fill;
|
||||
HUDPanel.RowCount = 1;
|
||||
HUDPanel.ColumnCount = 2;
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||
HUDPanel.ColumnCount = 3;
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUDPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
|
||||
Button btnVer = new Button();
|
||||
@@ -106,7 +108,7 @@ namespace compabetov2
|
||||
btnVer.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
|
||||
string mensaje = "";
|
||||
string mensaje = $"Cliente: {cuenta.cliente}\n";
|
||||
foreach (DetalleCuentaModel detalle in detalles)
|
||||
{
|
||||
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
|
||||
@@ -114,6 +116,29 @@ namespace compabetov2
|
||||
MessageBox.Show(mensaje);
|
||||
});
|
||||
|
||||
Button btnSaldar = new Button();
|
||||
btnSaldar.Text = "Saldar";
|
||||
btnSaldar.Dock = DockStyle.Fill;
|
||||
btnSaldar.FlatStyle = FlatStyle.Flat;
|
||||
btnSaldar.FlatAppearance.BorderSize = 0;
|
||||
btnSaldar.BackColor = Color.FromArgb(33, 90, 255);
|
||||
btnSaldar.Font = new Font(btnVer.Font.FontFamily, 16);
|
||||
btnSaldar.ForeColor = Color.White;
|
||||
btnSaldar.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("¿Está seguro de que desea saldar esta cuenta?",
|
||||
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
|
||||
if (service.saldarCuenta(cuenta, detalles))
|
||||
{
|
||||
llenarPanel();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button btnEliminar = new Button();
|
||||
btnEliminar.Text = "Cancelar";
|
||||
btnEliminar.Dock = DockStyle.Fill;
|
||||
@@ -124,14 +149,19 @@ namespace compabetov2
|
||||
btnEliminar.ForeColor = Color.White;
|
||||
btnEliminar.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("¿Está seguro de que desea eliminar este registro?",
|
||||
DialogResult result = MessageBox.Show("¿Está seguro de que desea cancelar este registro?",
|
||||
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
if (service.cancelarCuenta(cuenta.id))
|
||||
{
|
||||
llenarPanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
HUDPanel.Controls.Add(btnVer);
|
||||
HUDPanel.Controls.Add(btnSaldar);
|
||||
HUDPanel.Controls.Add(btnEliminar);
|
||||
|
||||
|
||||
@@ -148,5 +178,10 @@ namespace compabetov2
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void cuentas_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+124
-2
@@ -915,7 +915,7 @@ namespace compabetov2.database
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "SELECT * FROM cuenta";
|
||||
string sql = "SELECT * FROM cuenta WHERE estado = 'ACTIVO'";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
@@ -945,6 +945,8 @@ namespace compabetov2.database
|
||||
string sqlCuenta = "INSERT INTO cuenta (total, fecha, estado, descripcion) VALUES(@total, @fecha, 'ACTIVO', @descripcion);";
|
||||
string sqlDetalle = "INSERT INTO detalle_cuenta (fk_cuenta, fk_producto, cantidad) VALUES(@fk_cuenta, @fk_producto, @cantidad);";
|
||||
string sqlIdCuenta = "SELECT idCuenta FROM cuenta ORDER BY idCuenta DESC LIMIT 1";
|
||||
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
|
||||
string sqlProductoUpdate = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto";
|
||||
|
||||
SQLiteCommand commandCuenta = new SQLiteCommand(sqlCuenta, conexion);
|
||||
commandCuenta.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
@@ -968,6 +970,23 @@ namespace compabetov2.database
|
||||
commandDetalle.Parameters.AddWithValue("@fk_producto", detalleCuenta.producto.idProducto);
|
||||
commandDetalle.Parameters.AddWithValue("@cantidad", detalleCuenta.cantidad);
|
||||
commandDetalle.ExecuteNonQuery();
|
||||
|
||||
//modificar stock
|
||||
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
|
||||
commandProdcutoStock.Parameters.AddWithValue("@idproducto", detalleCuenta.producto.idProducto);
|
||||
SQLiteDataReader stockReader = commandProdcutoStock.ExecuteReader();
|
||||
|
||||
int stockActual = -1;
|
||||
while (stockReader.Read())
|
||||
{
|
||||
stockActual = int.Parse(stockReader["stock"].ToString());
|
||||
|
||||
}
|
||||
|
||||
SQLiteCommand commandProdcutoUpdate = new SQLiteCommand(sqlProductoUpdate, conexion);
|
||||
commandProdcutoUpdate.Parameters.AddWithValue("@stock", stockActual - detalleCuenta.cantidad);
|
||||
commandProdcutoUpdate.Parameters.AddWithValue("@idproducto", detalleCuenta.producto.idProducto);
|
||||
commandProdcutoUpdate.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
@@ -999,7 +1018,7 @@ namespace compabetov2.database
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "Select p.nombre , dc.cantidad from detalle_cuenta dc, Producto p WHERE dc.fk_producto = p.idproducto and dc.fk_cuenta = @fk_cuenta;";
|
||||
string sql = "Select p.idproducto, p.nombre , dc.cantidad from detalle_cuenta dc, Producto p WHERE dc.fk_producto = p.idproducto and dc.fk_cuenta = @fk_cuenta;";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@fk_cuenta", idCuenta);
|
||||
reader = command.ExecuteReader();
|
||||
@@ -1014,6 +1033,109 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool cancelarCuentaDAO(int idCuenta)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||
{
|
||||
conexion.Open();
|
||||
|
||||
using (var transaccion = conexion.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sqlCuenta = "UPDATE cuenta SET estado ='CANCELADO' WHERE idCuenta = @idCuenta;";
|
||||
|
||||
SQLiteCommand commandCuenta = new SQLiteCommand(sqlCuenta, conexion);
|
||||
commandCuenta.Parameters.AddWithValue("@idCuenta", idCuenta);
|
||||
commandCuenta.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 saldarCuentaDAO(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||
{
|
||||
conexion.Open();
|
||||
|
||||
using (var transaccion = conexion.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sqlVenta = "INSERT INTO venta (fecha, total) VALUES(@fecha, @total);";
|
||||
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_producto, cantidad) VALUES(@idVenta, @idProducto, @cantidada);";
|
||||
string sqlCuenta = "UPDATE cuenta SET estado ='SALDADO' WHERE idCuenta = @idCuenta;";
|
||||
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
|
||||
|
||||
|
||||
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
||||
commandVenta.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
commandVenta.Parameters.AddWithValue("@total", cuenta.total);
|
||||
commandVenta.ExecuteNonQuery();
|
||||
|
||||
SQLiteCommand commandCuenta = new SQLiteCommand(sqlCuenta, conexion);
|
||||
commandCuenta.Parameters.AddWithValue("@idCuenta", cuenta.id);
|
||||
|
||||
SQLiteCommand commandConsulta = new SQLiteCommand(sqlIdVenta, conexion);
|
||||
SQLiteDataReader reader = commandConsulta.ExecuteReader();
|
||||
|
||||
long idVenta = -1;
|
||||
while (reader.Read())
|
||||
{
|
||||
idVenta = reader.GetInt64(0);
|
||||
}
|
||||
foreach (DetalleCuentaModel detalleCuenta in detallesCuentas)
|
||||
{
|
||||
MessageBox.Show(detalleCuenta.producto.idProducto.ToString());
|
||||
SQLiteCommand commandEmpleado = new SQLiteCommand(sqlDetalle, conexion);
|
||||
commandEmpleado.Parameters.AddWithValue("@idVenta", idVenta);
|
||||
commandEmpleado.Parameters.AddWithValue("@idProducto", detalleCuenta.producto.idProducto);
|
||||
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleCuenta.cantidad);
|
||||
commandEmpleado.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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void crearDB()
|
||||
{
|
||||
|
||||
+13
-2
@@ -263,14 +263,25 @@ namespace compabetov2.database
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
int idProducto = (int)reader.GetInt64(0);
|
||||
DetalleCuentaModel detalleCuenta = new DetalleCuentaModel(
|
||||
new Producto(0, reader["nombre"].ToString()),
|
||||
(int)reader.GetInt64(1)
|
||||
new Producto(idProducto, reader["nombre"].ToString()),
|
||||
(int)reader.GetInt64(2)
|
||||
);
|
||||
detallesCuentas.Add(detalleCuenta);
|
||||
}
|
||||
|
||||
return detallesCuentas;
|
||||
}
|
||||
|
||||
public static bool cancelarCuenta(int idCuenta)
|
||||
{
|
||||
return DAO.cancelarCuentaDAO(idCuenta);
|
||||
}
|
||||
|
||||
public static bool saldarCuenta(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas)
|
||||
{
|
||||
return DAO.saldarCuentaDAO(cuenta, detallesCuentas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
04b35c54eccc37d11ee5587dfd28c3431df872e63afd80729ce6fb26c7e0a185
|
||||
c506c9a4722d6b00cf81dc1234eccc10baea5625c04c57095cc6ec95193a0f16
|
||||
|
||||
@@ -113,3 +113,8 @@ C:\Users\Googl\Documents\compabetoOG\bin\Debug\SqlServerTypes\x86\msvcr120.dll
|
||||
C:\Users\Googl\Documents\compabetoOG\bin\Debug\SqlServerTypes\x86\SqlServerSpatial140.dll
|
||||
C:\Users\Googl\Documents\compabetoOG\bin\Debug\Microsoft.SqlServer.Types.dll
|
||||
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.verproductos.resources
|
||||
C:\Users\carsu\source\repos\compabetoOG\bin\Debug\SqlServerTypes\x64\msvcr120.dll
|
||||
C:\Users\carsu\source\repos\compabetoOG\bin\Debug\SqlServerTypes\x64\SqlServerSpatial140.dll
|
||||
C:\Users\carsu\source\repos\compabetoOG\bin\Debug\SqlServerTypes\x86\msvcr120.dll
|
||||
C:\Users\carsu\source\repos\compabetoOG\bin\Debug\SqlServerTypes\x86\SqlServerSpatial140.dll
|
||||
C:\Users\carsu\source\repos\compabetoOG\bin\Debug\Microsoft.SqlServer.Types.dll
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user