version 1.1

This commit is contained in:
carlos
2024-02-15 00:01:19 -06:00
parent 736d8be03c
commit ea999a41e8
11 changed files with 162 additions and 138 deletions
+4 -3
View File
@@ -152,7 +152,7 @@ namespace compabetov2
decimal totalVendidoMes = 0; decimal totalVendidoMes = 0;
foreach (DetalleVentaModel producto in detallesMes) foreach (DetalleVentaModel producto in detallesMes)
{ {
totalVendidoMes += producto.cantidad * producto.producto.precio; totalVendidoMes += (producto.cantidad * producto.producto.cantidad) * producto.producto.precio;
// Crear una nueva fila // Crear una nueva fila
DataGridViewRow nuevaFila = new DataGridViewRow(); DataGridViewRow nuevaFila = new DataGridViewRow();
@@ -188,7 +188,7 @@ namespace compabetov2
decimal totalVendidoDia = 0; decimal totalVendidoDia = 0;
foreach (DetalleVentaModel producto in detallesDia) foreach (DetalleVentaModel producto in detallesDia)
{ {
totalVendidoDia += producto.cantidad * producto.producto.precio; totalVendidoDia += (producto.cantidad * producto.producto.cantidad) * producto.producto.precio;
// Crear una nueva fila // Crear una nueva fila
DataGridViewRow nuevaFila = new DataGridViewRow(); DataGridViewRow nuevaFila = new DataGridViewRow();
@@ -234,6 +234,7 @@ namespace compabetov2
int contador = 0; int contador = 0;
for(int i = 0; i <= totalElementos; i++) { for(int i = 0; i <= totalElementos; i++) {
contador++; contador++;
//si no encuentra el producto lo agrega
if (i == totalElementos) if (i == totalElementos)
{ {
DetalleVentaModel detalleAgregar = new DetalleVentaModel(detallesVenta.cantidad, detallesVenta.producto, detallesVenta.idVenta); DetalleVentaModel detalleAgregar = new DetalleVentaModel(detallesVenta.cantidad, detallesVenta.producto, detallesVenta.idVenta);
@@ -242,7 +243,7 @@ namespace compabetov2
} }
DetalleVentaModel producto = detallesMes[i]; DetalleVentaModel producto = detallesMes[i];
//si encuentra el produco solo aumneta la cantidad
if (producto.producto.nombre.Equals(detallesVenta.producto.nombre)) if (producto.producto.nombre.Equals(detallesVenta.producto.nombre))
{ {
producto.cantidad += detallesVenta.cantidad; producto.cantidad += detallesVenta.cantidad;
+50 -51
View File
@@ -72,9 +72,9 @@
this.panel1.Controls.Add(this.pictureBox1); this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1258, 627); this.panel1.Size = new System.Drawing.Size(1677, 772);
this.panel1.TabIndex = 4; this.panel1.TabIndex = 4;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
// //
@@ -83,10 +83,9 @@
this.lblfecha.AutoSize = true; this.lblfecha.AutoSize = true;
this.lblfecha.Font = new System.Drawing.Font("Microsoft Sans Serif", 30F); this.lblfecha.Font = new System.Drawing.Font("Microsoft Sans Serif", 30F);
this.lblfecha.ForeColor = System.Drawing.Color.Navy; this.lblfecha.ForeColor = System.Drawing.Color.Navy;
this.lblfecha.Location = new System.Drawing.Point(582, 91); this.lblfecha.Location = new System.Drawing.Point(776, 112);
this.lblfecha.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblfecha.Name = "lblfecha"; this.lblfecha.Name = "lblfecha";
this.lblfecha.Size = new System.Drawing.Size(126, 46); this.lblfecha.Size = new System.Drawing.Size(159, 58);
this.lblfecha.TabIndex = 9; this.lblfecha.TabIndex = 9;
this.lblfecha.Text = "label2"; this.lblfecha.Text = "label2";
this.lblfecha.TextAlign = System.Drawing.ContentAlignment.TopCenter; this.lblfecha.TextAlign = System.Drawing.ContentAlignment.TopCenter;
@@ -97,10 +96,9 @@
this.lblhora.AutoSize = true; this.lblhora.AutoSize = true;
this.lblhora.Font = new System.Drawing.Font("Microsoft Sans Serif", 60F); this.lblhora.Font = new System.Drawing.Font("Microsoft Sans Serif", 60F);
this.lblhora.ForeColor = System.Drawing.Color.MediumBlue; this.lblhora.ForeColor = System.Drawing.Color.MediumBlue;
this.lblhora.Location = new System.Drawing.Point(715, -5); this.lblhora.Location = new System.Drawing.Point(953, -6);
this.lblhora.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblhora.Name = "lblhora"; this.lblhora.Name = "lblhora";
this.lblhora.Size = new System.Drawing.Size(249, 91); this.lblhora.Size = new System.Drawing.Size(318, 113);
this.lblhora.TabIndex = 8; this.lblhora.TabIndex = 8;
this.lblhora.Text = "label1"; this.lblhora.Text = "label1";
this.lblhora.Click += new System.EventHandler(this.lblhora_Click); this.lblhora.Click += new System.EventHandler(this.lblhora_Click);
@@ -114,26 +112,26 @@
this.flowLayoutPanel1.Controls.Add(this.button3); this.flowLayoutPanel1.Controls.Add(this.button3);
this.flowLayoutPanel1.Controls.Add(this.button5); this.flowLayoutPanel1.Controls.Add(this.button5);
this.flowLayoutPanel1.Location = new System.Drawing.Point(-1, 2); this.flowLayoutPanel1.Location = new System.Drawing.Point(-1, 2);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(243, 862); this.flowLayoutPanel1.Size = new System.Drawing.Size(324, 1061);
this.flowLayoutPanel1.TabIndex = 7; this.flowLayoutPanel1.TabIndex = 7;
// //
// panel2 // panel2
// //
this.panel2.BackColor = System.Drawing.Color.Transparent; this.panel2.BackColor = System.Drawing.Color.Transparent;
this.panel2.Controls.Add(this.pictureBox7); this.panel2.Controls.Add(this.pictureBox7);
this.panel2.Location = new System.Drawing.Point(2, 2); this.panel2.Location = new System.Drawing.Point(3, 2);
this.panel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(234, 214); this.panel2.Size = new System.Drawing.Size(312, 263);
this.panel2.TabIndex = 8; this.panel2.TabIndex = 8;
// //
// pictureBox7 // pictureBox7
// //
this.pictureBox7.Image = global::compabetov2.Properties.Resources.HomeroMenu; this.pictureBox7.Image = global::compabetov2.Properties.Resources.HomeroMenu;
this.pictureBox7.Location = new System.Drawing.Point(48, 28); this.pictureBox7.Location = new System.Drawing.Point(64, 34);
this.pictureBox7.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox7.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox7.Name = "pictureBox7"; this.pictureBox7.Name = "pictureBox7";
this.pictureBox7.Size = new System.Drawing.Size(190, 197); this.pictureBox7.Size = new System.Drawing.Size(190, 197);
this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
@@ -149,11 +147,11 @@
this.button1.ForeColor = System.Drawing.SystemColors.ButtonHighlight; this.button1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.button1.Image = global::compabetov2.Properties.Resources.Menui1; this.button1.Image = global::compabetov2.Properties.Resources.Menui1;
this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button1.Location = new System.Drawing.Point(2, 220); this.button1.Location = new System.Drawing.Point(3, 269);
this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); this.button1.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button1.Size = new System.Drawing.Size(234, 93); this.button1.Size = new System.Drawing.Size(312, 114);
this.button1.TabIndex = 8; this.button1.TabIndex = 8;
this.button1.Text = "Menú"; this.button1.Text = "Menú";
this.button1.UseVisualStyleBackColor = false; this.button1.UseVisualStyleBackColor = false;
@@ -168,11 +166,11 @@
this.button2.ForeColor = System.Drawing.SystemColors.ButtonHighlight; this.button2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.button2.Image = global::compabetov2.Properties.Resources.estadisticasi; this.button2.Image = global::compabetov2.Properties.Resources.estadisticasi;
this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button2.Location = new System.Drawing.Point(2, 317); this.button2.Location = new System.Drawing.Point(3, 387);
this.button2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); this.button2.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button2.Size = new System.Drawing.Size(234, 93); this.button2.Size = new System.Drawing.Size(312, 114);
this.button2.TabIndex = 9; this.button2.TabIndex = 9;
this.button2.Text = "Reportes"; this.button2.Text = "Reportes";
this.button2.UseVisualStyleBackColor = false; this.button2.UseVisualStyleBackColor = false;
@@ -187,11 +185,11 @@
this.button3.ForeColor = System.Drawing.SystemColors.ButtonHighlight; this.button3.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.button3.Image = global::compabetov2.Properties.Resources.productoi; this.button3.Image = global::compabetov2.Properties.Resources.productoi;
this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button3.Location = new System.Drawing.Point(2, 414); this.button3.Location = new System.Drawing.Point(3, 505);
this.button3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.button3.Name = "button3"; this.button3.Name = "button3";
this.button3.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); this.button3.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button3.Size = new System.Drawing.Size(234, 93); this.button3.Size = new System.Drawing.Size(312, 114);
this.button3.TabIndex = 10; this.button3.TabIndex = 10;
this.button3.Text = "Productos"; this.button3.Text = "Productos";
this.button3.UseVisualStyleBackColor = false; this.button3.UseVisualStyleBackColor = false;
@@ -205,11 +203,11 @@
this.button5.ForeColor = System.Drawing.SystemColors.ButtonHighlight; this.button5.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.button5.Image = global::compabetov2.Properties.Resources.sesionc; this.button5.Image = global::compabetov2.Properties.Resources.sesionc;
this.button5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button5.Location = new System.Drawing.Point(2, 511); this.button5.Location = new System.Drawing.Point(3, 623);
this.button5.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.button5.Name = "button5"; this.button5.Name = "button5";
this.button5.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); this.button5.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button5.Size = new System.Drawing.Size(234, 93); this.button5.Size = new System.Drawing.Size(312, 114);
this.button5.TabIndex = 12; this.button5.TabIndex = 12;
this.button5.Text = "Salir"; this.button5.Text = "Salir";
this.button5.UseVisualStyleBackColor = false; this.button5.UseVisualStyleBackColor = false;
@@ -218,10 +216,10 @@
// pictureBox4 // pictureBox4
// //
this.pictureBox4.Image = global::compabetov2.Properties.Resources.inventario; this.pictureBox4.Image = global::compabetov2.Properties.Resources.inventario;
this.pictureBox4.Location = new System.Drawing.Point(1088, 490); this.pictureBox4.Location = new System.Drawing.Point(1451, 603);
this.pictureBox4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox4.Name = "pictureBox4"; this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(220, 229); this.pictureBox4.Size = new System.Drawing.Size(293, 282);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox4.TabIndex = 6; this.pictureBox4.TabIndex = 6;
this.pictureBox4.TabStop = false; this.pictureBox4.TabStop = false;
@@ -230,10 +228,10 @@
// pictureBox5 // pictureBox5
// //
this.pictureBox5.Image = global::compabetov2.Properties.Resources.Cuentas; this.pictureBox5.Image = global::compabetov2.Properties.Resources.Cuentas;
this.pictureBox5.Location = new System.Drawing.Point(438, 490); this.pictureBox5.Location = new System.Drawing.Point(584, 603);
this.pictureBox5.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox5.Name = "pictureBox5"; this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(220, 229); this.pictureBox5.Size = new System.Drawing.Size(293, 282);
this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox5.TabIndex = 5; this.pictureBox5.TabIndex = 5;
this.pictureBox5.TabStop = false; this.pictureBox5.TabStop = false;
@@ -242,10 +240,10 @@
// pictureBox6 // pictureBox6
// //
this.pictureBox6.Image = global::compabetov2.Properties.Resources.mermas; this.pictureBox6.Image = global::compabetov2.Properties.Resources.mermas;
this.pictureBox6.Location = new System.Drawing.Point(760, 490); this.pictureBox6.Location = new System.Drawing.Point(1013, 603);
this.pictureBox6.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox6.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox6.Name = "pictureBox6"; this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(220, 229); this.pictureBox6.Size = new System.Drawing.Size(293, 282);
this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox6.TabIndex = 4; this.pictureBox6.TabIndex = 4;
this.pictureBox6.TabStop = false; this.pictureBox6.TabStop = false;
@@ -254,10 +252,10 @@
// pictureBox3 // pictureBox3
// //
this.pictureBox3.Image = global::compabetov2.Properties.Resources.Envios; this.pictureBox3.Image = global::compabetov2.Properties.Resources.Envios;
this.pictureBox3.Location = new System.Drawing.Point(1088, 170); this.pictureBox3.Location = new System.Drawing.Point(1451, 209);
this.pictureBox3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox3.Name = "pictureBox3"; this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(220, 229); this.pictureBox3.Size = new System.Drawing.Size(293, 282);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox3.TabIndex = 3; this.pictureBox3.TabIndex = 3;
this.pictureBox3.TabStop = false; this.pictureBox3.TabStop = false;
@@ -266,10 +264,10 @@
// pictureBox2 // pictureBox2
// //
this.pictureBox2.Image = global::compabetov2.Properties.Resources.Vender; this.pictureBox2.Image = global::compabetov2.Properties.Resources.Vender;
this.pictureBox2.Location = new System.Drawing.Point(438, 170); this.pictureBox2.Location = new System.Drawing.Point(584, 209);
this.pictureBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox2.Name = "pictureBox2"; this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(220, 229); this.pictureBox2.Size = new System.Drawing.Size(293, 282);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 2; this.pictureBox2.TabIndex = 2;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
@@ -278,10 +276,10 @@
// pictureBox1 // pictureBox1
// //
this.pictureBox1.Image = global::compabetov2.Properties.Resources.Personal; this.pictureBox1.Image = global::compabetov2.Properties.Resources.Personal;
this.pictureBox1.Location = new System.Drawing.Point(760, 170); this.pictureBox1.Location = new System.Drawing.Point(1013, 209);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(220, 229); this.pictureBox1.Size = new System.Drawing.Size(293, 282);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 1; this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
@@ -294,12 +292,13 @@
// //
// MenuPrincipal // MenuPrincipal
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1258, 627); this.ClientSize = new System.Drawing.Size(1677, 772);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.IsMdiContainer = true; this.IsMdiContainer = true;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "MenuPrincipal"; this.Name = "MenuPrincipal";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.MenuPrincipal_Load); this.Load += new System.EventHandler(this.MenuPrincipal_Load);
+2 -2
View File
@@ -1,4 +1,5 @@
using compabetov2.database.modelos; using compabetov2.database;
using compabetov2.database.modelos;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -194,6 +195,5 @@ namespace compabetov2
} }
} }
} }
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+82 -62
View File
@@ -23,7 +23,8 @@ namespace compabetov2.database
try try
{ {
using (SQLiteConnection conexion = db_conexion.get_connection()) { using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open(); conexion.Open();
string sql = "SELECT usuario, contra FROM Login WHERE usuario = @param0"; string sql = "SELECT usuario, contra FROM Login WHERE usuario = @param0";
@@ -87,14 +88,14 @@ namespace compabetov2.database
{ {
SQLiteConnection conexion = db_conexion.get_connection(); SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open(); conexion.Open();
string sql = "SELECT usuario, tipo FROM Login WHERE usuario = @param0"; string sql = "SELECT usuario, tipo FROM Login WHERE usuario = @param0";
SQLiteCommand command = new SQLiteCommand(sql, conexion); SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue($"@param{0}", usuario); command.Parameters.AddWithValue($"@param{0}", usuario);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
return reader; return reader;
} }
catch (SQLiteException ex) catch (SQLiteException ex)
@@ -119,7 +120,7 @@ namespace compabetov2.database
command.Parameters.AddWithValue("@usuario", loginModel.usuario); command.Parameters.AddWithValue("@usuario", loginModel.usuario);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
if(reader.Read()) if (reader.Read())
{ {
return false; return false;
} }
@@ -162,7 +163,7 @@ namespace compabetov2.database
SQLiteDataReader reader = commandConsulta.ExecuteReader(); SQLiteDataReader reader = commandConsulta.ExecuteReader();
long fkLogin = -1; long fkLogin = -1;
while(reader.Read()) while (reader.Read())
{ {
fkLogin = reader.GetInt64(0); fkLogin = reader.GetInt64(0);
} }
@@ -322,13 +323,13 @@ namespace compabetov2.database
{ {
SQLiteConnection conexion = db_conexion.get_connection(); SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open(); conexion.Open();
string sql = "SELECT * FROM Empleado WHERE idempleado > 1"; string sql = "SELECT * FROM Empleado WHERE idempleado > 1";
SQLiteCommand command = new SQLiteCommand(sql, conexion); SQLiteCommand command = new SQLiteCommand(sql, conexion);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
return reader; return reader;
} }
catch (SQLiteException ex) catch (SQLiteException ex)
@@ -381,7 +382,8 @@ namespace compabetov2.database
} }
} }
public static bool eliminarEmpleadoDAO(Empleado empleado) { public static bool eliminarEmpleadoDAO(Empleado empleado)
{
var db_conexion = new Conexion(); var db_conexion = new Conexion();
try try
@@ -436,15 +438,16 @@ namespace compabetov2.database
{ {
SQLiteConnection conexion = db_conexion.get_connection(); SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open(); conexion.Open();
string sql = "SELECT * FROM Producto INNER JOIN Categoria ON Producto.fk_idcategoria = Categoria.idcategoria"; string sql = "SELECT * FROM Producto INNER JOIN Categoria ON Producto.fk_idcategoria = Categoria.idcategoria";
SQLiteCommand command = new SQLiteCommand(sql, conexion); SQLiteCommand command = new SQLiteCommand(sql, conexion);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
return reader; return reader;
} }
catch (SQLiteException ex) { catch (SQLiteException ex)
{
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
return reader; return reader;
} }
@@ -459,7 +462,7 @@ namespace compabetov2.database
{ {
conexion.Open(); conexion.Open();
string sql = "INSERT INTO Producto (nombre, descripcion, precio,img, stock, fk_idcategoria) "+ string sql = "INSERT INTO Producto (nombre, descripcion, precio,img, stock, fk_idcategoria) " +
"VALUES (@nombre, @descripcion, @precio,@img , @stock, @idcategoria)"; "VALUES (@nombre, @descripcion, @precio,@img , @stock, @idcategoria)";
if (!producto.img.Equals("")) if (!producto.img.Equals(""))
@@ -470,7 +473,7 @@ namespace compabetov2.database
using (SQLiteCommand command = new SQLiteCommand(sql, conexion)) using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{ {
command.Parameters.AddWithValue("@nombre", producto.nombre); command.Parameters.AddWithValue("@nombre", producto.nombre);
command.Parameters.AddWithValue("@descripcion", producto.descripcion); command.Parameters.AddWithValue("@descripcion", producto.descripcion);
command.Parameters.AddWithValue("@precio", producto.precion); command.Parameters.AddWithValue("@precio", producto.precion);
command.Parameters.AddWithValue("@img", producto.img); command.Parameters.AddWithValue("@img", producto.img);
@@ -478,7 +481,7 @@ namespace compabetov2.database
command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria); command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria);
int filasAfectadas = command.ExecuteNonQuery(); int filasAfectadas = command.ExecuteNonQuery();
if(filasAfectadas > 0) { return true; } if (filasAfectadas > 0) { return true; }
else { return false; } else { return false; }
} }
} }
@@ -527,7 +530,7 @@ namespace compabetov2.database
{ {
conexion.Open(); conexion.Open();
using(var transaccion = conexion.BeginTransaction()) using (var transaccion = conexion.BeginTransaction())
{ {
try try
{ {
@@ -556,7 +559,7 @@ namespace compabetov2.database
transaccion.Commit(); transaccion.Commit();
return true; return true;
} }
catch(SQLiteException ex) catch (SQLiteException ex)
{ {
transaccion.Rollback(); transaccion.Rollback();
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
@@ -718,13 +721,13 @@ namespace compabetov2.database
{ {
SQLiteConnection conexion = db_conexion.get_connection(); SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open(); conexion.Open();
string sql = "SELECT * FROM Merma"; string sql = "SELECT * FROM Merma";
SQLiteCommand command = new SQLiteCommand(sql, conexion); SQLiteCommand command = new SQLiteCommand(sql, conexion);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
return reader; return reader;
} }
catch (SQLiteException ex) catch (SQLiteException ex)
@@ -1213,37 +1216,6 @@ namespace compabetov2.database
} }
} }
/*public static SQLiteDataReader filtrarVentaFechaMes(DateTime fecha)
{
Dictionary<string, dynamic> estadisticas = new Dictionary<string, dynamic>();
SQLiteDataReader reader = DAO.filtrarVentaFechaMesDAO(fecha);
string formatoFecha = "dd/MM/yyyy";
decimal totalDia = 0;
decimal totalMes = 0;
List<VentaModel> ventas = new List<VentaModel>();
while (reader.Read())
{
VentaModel venta = new VentaModel(
(decimal)reader["total"],
(int)reader.GetInt64(0),
reader.GetString(1)
);
string[] cadenasFech = venta.fecha.Split(' ');
DateTime.TryParseExact(cadenasFech[0], formatoFecha, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime fechaVenta);
if (fecha.Day == fechaVenta.Day)
{
totalDia += venta.total;
}
totalMes += venta.total;
ventas.Add(venta);
}
estadisticas.Add("ventasDia", totalDia);
estadisticas.Add("ventasMes", totalMes);
return estadisticas;
}*/
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio) public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio)
{ {
return DAO.crearEnvioDAO(envio, detallesEnvio); return DAO.crearEnvioDAO(envio, detallesEnvio);
@@ -1459,6 +1431,54 @@ namespace compabetov2.database
return false; return false;
} }
} }
public static bool llenarTablaVariantes()
{
List<Producto> productos = service.conseguirProductos();
var db_conexion = new Conexion();
try
{
using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open();
using (var transaccion = conexion.BeginTransaction())
{
try
{
string sql = "INSERT INTO variantes(idVariante, nombre, precio, cantidad, img, fk_producto)" +
"VALUES(@idVariante, @nombre, @precio, @cantidad, @img, @fk_producto);";
for(int i = 0; i<productos.Count; i++)
{
SQLiteCommand commandStock = new SQLiteCommand(sql, conexion);
commandStock.Parameters.AddWithValue("@idVariante", i+1);
commandStock.Parameters.AddWithValue("@nombre", productos[i].nombre);
commandStock.Parameters.AddWithValue("@precio", productos[i].precion);
commandStock.Parameters.AddWithValue("@cantidad", 1);
commandStock.Parameters.AddWithValue("@img", productos[i].img);
commandStock.Parameters.AddWithValue("@fk_producto", productos[i].idProducto);
commandStock.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 concluirEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio) public static bool concluirEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio)
{ {
+7 -3
View File
@@ -405,9 +405,13 @@ namespace compabetov2.database
{ {
DetalleVentaModel detalleVenta = new DetalleVentaModel( DetalleVentaModel detalleVenta = new DetalleVentaModel(
(int)readerDetalleVenta.GetInt64(2), (int)readerDetalleVenta.GetInt64(2),
new Variante(-1,"",0,0,"",-1) new Variante((int)readerDetalleVenta.GetInt64(3),
readerDetalleVenta["nombre"].ToString(),
) ; readerDetalleVenta.GetDecimal(5),
(int)readerDetalleVenta.GetInt64(6),
"",
(int)readerDetalleVenta.GetInt64(8))
);
detallesVenta.Add( detalleVenta ); detallesVenta.Add( detalleVenta );
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.