cuenta hecha
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
"\\Properties",
|
||||
"\\Properties\\DataSources"
|
||||
],
|
||||
<<<<<<< HEAD
|
||||
"SelectedNode": "\\envios.cs",
|
||||
=======
|
||||
"SelectedNode": "\\database\\DAO.cs",
|
||||
>>>>>>> 3d33ff1e16cc8960f815f7a70dbce03e3275ec89
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Generated
+10
-9
@@ -47,7 +47,7 @@
|
||||
this.panel2.BackColor = System.Drawing.Color.Transparent;
|
||||
this.panel2.Controls.Add(this.pictureBox7);
|
||||
this.panel2.Location = new System.Drawing.Point(2, 2);
|
||||
this.panel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.panel2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(234, 214);
|
||||
this.panel2.TabIndex = 8;
|
||||
@@ -56,7 +56,7 @@
|
||||
//
|
||||
this.pictureBox7.Image = global::compabetov2.Properties.Resources.HomeroMenu;
|
||||
this.pictureBox7.Location = new System.Drawing.Point(48, 28);
|
||||
this.pictureBox7.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.pictureBox7.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pictureBox7.Name = "pictureBox7";
|
||||
this.pictureBox7.Size = new System.Drawing.Size(190, 197);
|
||||
this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
@@ -73,7 +73,7 @@
|
||||
this.button1.Image = global::compabetov2.Properties.Resources.Menui1;
|
||||
this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.button1.Location = new System.Drawing.Point(2, 220);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0);
|
||||
this.button1.Size = new System.Drawing.Size(234, 93);
|
||||
@@ -92,7 +92,7 @@
|
||||
this.button2.Image = global::compabetov2.Properties.Resources.estadisticasi;
|
||||
this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.button2.Location = new System.Drawing.Point(2, 317);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0);
|
||||
this.button2.Size = new System.Drawing.Size(234, 93);
|
||||
@@ -111,7 +111,7 @@
|
||||
this.button3.Image = global::compabetov2.Properties.Resources.productoi;
|
||||
this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.button3.Location = new System.Drawing.Point(2, 414);
|
||||
this.button3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.button3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0);
|
||||
this.button3.Size = new System.Drawing.Size(234, 93);
|
||||
@@ -129,7 +129,7 @@
|
||||
this.button4.Image = global::compabetov2.Properties.Resources.reportesi;
|
||||
this.button4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.button4.Location = new System.Drawing.Point(2, 511);
|
||||
this.button4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.button4.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button4.Name = "button4";
|
||||
this.button4.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0);
|
||||
this.button4.Size = new System.Drawing.Size(234, 93);
|
||||
@@ -147,7 +147,7 @@
|
||||
this.button5.Image = global::compabetov2.Properties.Resources.sesionc;
|
||||
this.button5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.button5.Location = new System.Drawing.Point(2, 608);
|
||||
this.button5.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.button5.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.button5.Name = "button5";
|
||||
this.button5.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0);
|
||||
this.button5.Size = new System.Drawing.Size(234, 93);
|
||||
@@ -165,7 +165,7 @@
|
||||
this.flowLayoutPanel1.Controls.Add(this.button4);
|
||||
this.flowLayoutPanel1.Controls.Add(this.button5);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(-1, -1);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(243, 862);
|
||||
this.flowLayoutPanel1.TabIndex = 8;
|
||||
@@ -185,10 +185,11 @@
|
||||
this.ClientSize = new System.Drawing.Size(1370, 749);
|
||||
this.Controls.Add(this.panelCuenta);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "cuentas";
|
||||
this.Text = "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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+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.
Binary file not shown.
@@ -1 +1 @@
|
||||
58c239bc3e838a0c02c2b5a03d125ff99004200327e2ff69d1038564eb7b7c64
|
||||
e667a4e3b4d9c621799848a8f3cd089577a0f35fe509181b78fb7de1d38d3880
|
||||
|
||||
@@ -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