estadisticas en proceso

This commit is contained in:
Carlos Sandoval
2024-06-26 03:49:02 -06:00
parent a610343abe
commit d81f706053
17 changed files with 661 additions and 155 deletions
+106 -28
View File
@@ -32,16 +32,20 @@
this.dgvDia = new System.Windows.Forms.DataGridView();
this.Producto = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Precio = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.precioCompra = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Cantidad = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Total = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.totalNeto = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.btnBuscar = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.dgvMes = new System.Windows.Forms.DataGridView();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PrecioCompraMes = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.totalNetoMes = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lbProductDia = new System.Windows.Forms.Label();
this.lbVendedorDia = new System.Windows.Forms.Label();
this.lbTotalDia = new System.Windows.Forms.Label();
@@ -51,6 +55,9 @@
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.lbDiaSEnvio = new System.Windows.Forms.Label();
this.lbMesSEnvio = new System.Windows.Forms.Label();
this.lbTotalDiaNeto = new System.Windows.Forms.Label();
this.btnVentasDia = new System.Windows.Forms.Button();
this.btnVentasMes = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgvDia)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvMes)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
@@ -70,13 +77,16 @@
this.dgvDia.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Producto,
this.Precio,
this.precioCompra,
this.Cantidad,
this.Total});
this.Total,
this.totalNeto});
this.dgvDia.Location = new System.Drawing.Point(24, 199);
this.dgvDia.Name = "dgvDia";
this.dgvDia.RowHeadersWidth = 51;
this.dgvDia.Size = new System.Drawing.Size(443, 150);
this.dgvDia.Size = new System.Drawing.Size(599, 150);
this.dgvDia.TabIndex = 1;
this.dgvDia.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDia_CellContentClick);
//
// Producto
//
@@ -84,7 +94,7 @@
this.Producto.MinimumWidth = 6;
this.Producto.Name = "Producto";
this.Producto.ReadOnly = true;
this.Producto.Width = 125;
this.Producto.Width = 250;
//
// Precio
//
@@ -92,7 +102,13 @@
this.Precio.MinimumWidth = 6;
this.Precio.Name = "Precio";
this.Precio.ReadOnly = true;
this.Precio.Width = 125;
this.Precio.Width = 50;
//
// precioCompra
//
this.precioCompra.HeaderText = "Precio Compra";
this.precioCompra.Name = "precioCompra";
this.precioCompra.Width = 50;
//
// Cantidad
//
@@ -100,14 +116,20 @@
this.Cantidad.MinimumWidth = 6;
this.Cantidad.Name = "Cantidad";
this.Cantidad.ReadOnly = true;
this.Cantidad.Width = 125;
this.Cantidad.Width = 50;
//
// Total
//
this.Total.HeaderText = "Total";
this.Total.MinimumWidth = 6;
this.Total.Name = "Total";
this.Total.Width = 125;
this.Total.Width = 70;
//
// totalNeto
//
this.totalNeto.HeaderText = "Total Neto";
this.totalNeto.Name = "totalNeto";
this.totalNeto.Width = 70;
//
// btnBuscar
//
@@ -150,12 +172,14 @@
this.dgvMes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2,
this.PrecioCompraMes,
this.dataGridViewTextBoxColumn3,
this.dataGridViewTextBoxColumn4});
this.dataGridViewTextBoxColumn4,
this.totalNetoMes});
this.dgvMes.Location = new System.Drawing.Point(24, 406);
this.dgvMes.Name = "dgvMes";
this.dgvMes.RowHeadersWidth = 51;
this.dgvMes.Size = new System.Drawing.Size(443, 150);
this.dgvMes.Size = new System.Drawing.Size(599, 150);
this.dgvMes.TabIndex = 5;
//
// dataGridViewTextBoxColumn1
@@ -164,7 +188,7 @@
this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
this.dataGridViewTextBoxColumn1.ReadOnly = true;
this.dataGridViewTextBoxColumn1.Width = 125;
this.dataGridViewTextBoxColumn1.Width = 250;
//
// dataGridViewTextBoxColumn2
//
@@ -172,7 +196,13 @@
this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
this.dataGridViewTextBoxColumn2.ReadOnly = true;
this.dataGridViewTextBoxColumn2.Width = 125;
this.dataGridViewTextBoxColumn2.Width = 50;
//
// PrecioCompraMes
//
this.PrecioCompraMes.HeaderText = "Precio Compra";
this.PrecioCompraMes.Name = "PrecioCompraMes";
this.PrecioCompraMes.Width = 50;
//
// dataGridViewTextBoxColumn3
//
@@ -180,14 +210,20 @@
this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
this.dataGridViewTextBoxColumn3.ReadOnly = true;
this.dataGridViewTextBoxColumn3.Width = 125;
this.dataGridViewTextBoxColumn3.Width = 50;
//
// dataGridViewTextBoxColumn4
//
this.dataGridViewTextBoxColumn4.HeaderText = "Total";
this.dataGridViewTextBoxColumn4.MinimumWidth = 6;
this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
this.dataGridViewTextBoxColumn4.Width = 125;
this.dataGridViewTextBoxColumn4.Width = 70;
//
// totalNetoMes
//
this.totalNetoMes.HeaderText = "Total Neto";
this.totalNetoMes.Name = "totalNetoMes";
this.totalNetoMes.Width = 70;
//
// lbProductDia
//
@@ -195,7 +231,7 @@
this.lbProductDia.BackColor = System.Drawing.Color.Transparent;
this.lbProductDia.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbProductDia.ForeColor = System.Drawing.Color.Transparent;
this.lbProductDia.Location = new System.Drawing.Point(586, 197);
this.lbProductDia.Location = new System.Drawing.Point(657, 199);
this.lbProductDia.Name = "lbProductDia";
this.lbProductDia.Size = new System.Drawing.Size(153, 17);
this.lbProductDia.TabIndex = 6;
@@ -208,7 +244,7 @@
this.lbVendedorDia.BackColor = System.Drawing.Color.Transparent;
this.lbVendedorDia.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbVendedorDia.ForeColor = System.Drawing.Color.Transparent;
this.lbVendedorDia.Location = new System.Drawing.Point(586, 257);
this.lbVendedorDia.Location = new System.Drawing.Point(657, 261);
this.lbVendedorDia.Name = "lbVendedorDia";
this.lbVendedorDia.Size = new System.Drawing.Size(113, 17);
this.lbVendedorDia.TabIndex = 7;
@@ -233,7 +269,7 @@
this.lbTotalMes.BackColor = System.Drawing.Color.Transparent;
this.lbTotalMes.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbTotalMes.ForeColor = System.Drawing.Color.Transparent;
this.lbTotalMes.Location = new System.Drawing.Point(330, 560);
this.lbTotalMes.Location = new System.Drawing.Point(333, 575);
this.lbTotalMes.Name = "lbTotalMes";
this.lbTotalMes.Size = new System.Drawing.Size(97, 17);
this.lbTotalMes.TabIndex = 9;
@@ -245,7 +281,7 @@
this.lbVendedorMes.BackColor = System.Drawing.Color.Transparent;
this.lbVendedorMes.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbVendedorMes.ForeColor = System.Drawing.Color.Transparent;
this.lbVendedorMes.Location = new System.Drawing.Point(588, 454);
this.lbVendedorMes.Location = new System.Drawing.Point(659, 457);
this.lbVendedorMes.Name = "lbVendedorMes";
this.lbVendedorMes.Size = new System.Drawing.Size(111, 17);
this.lbVendedorMes.TabIndex = 11;
@@ -258,7 +294,7 @@
this.lbProductoMes.BackColor = System.Drawing.Color.Transparent;
this.lbProductoMes.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbProductoMes.ForeColor = System.Drawing.Color.Transparent;
this.lbProductoMes.Location = new System.Drawing.Point(588, 396);
this.lbProductoMes.Location = new System.Drawing.Point(657, 387);
this.lbProductoMes.Name = "lbProductoMes";
this.lbProductoMes.Size = new System.Drawing.Size(153, 17);
this.lbProductoMes.TabIndex = 10;
@@ -271,7 +307,7 @@
this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pictureBox2.Image = global::compabetov2.Properties.Resources.check1;
this.pictureBox2.Location = new System.Drawing.Point(785, 560);
this.pictureBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.pictureBox2.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(75, 56);
this.pictureBox2.TabIndex = 28;
@@ -296,12 +332,44 @@
this.lbMesSEnvio.BackColor = System.Drawing.Color.Transparent;
this.lbMesSEnvio.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbMesSEnvio.ForeColor = System.Drawing.Color.Transparent;
this.lbMesSEnvio.Location = new System.Drawing.Point(270, 577);
this.lbMesSEnvio.Location = new System.Drawing.Point(266, 601);
this.lbMesSEnvio.Name = "lbMesSEnvio";
this.lbMesSEnvio.Size = new System.Drawing.Size(164, 17);
this.lbMesSEnvio.TabIndex = 30;
this.lbMesSEnvio.Text = "Total del mes sin envios:";
//
// lbTotalDiaNeto
//
this.lbTotalDiaNeto.AutoSize = true;
this.lbTotalDiaNeto.BackColor = System.Drawing.Color.Transparent;
this.lbTotalDiaNeto.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbTotalDiaNeto.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.lbTotalDiaNeto.Location = new System.Drawing.Point(70, 356);
this.lbTotalDiaNeto.Name = "lbTotalDiaNeto";
this.lbTotalDiaNeto.Size = new System.Drawing.Size(114, 16);
this.lbTotalDiaNeto.TabIndex = 31;
this.lbTotalDiaNeto.Text = "Total neto del dia:";
//
// btnVentasDia
//
this.btnVentasDia.Location = new System.Drawing.Point(876, 232);
this.btnVentasDia.Name = "btnVentasDia";
this.btnVentasDia.Size = new System.Drawing.Size(110, 23);
this.btnVentasDia.TabIndex = 32;
this.btnVentasDia.Text = "Ventas del dia";
this.btnVentasDia.UseVisualStyleBackColor = true;
this.btnVentasDia.Click += new System.EventHandler(this.btnVentasDia_Click);
//
// btnVentasMes
//
this.btnVentasMes.Location = new System.Drawing.Point(876, 421);
this.btnVentasMes.Name = "btnVentasMes";
this.btnVentasMes.Size = new System.Drawing.Size(110, 23);
this.btnVentasMes.TabIndex = 33;
this.btnVentasMes.Text = "Ventas del Mes";
this.btnVentasMes.UseVisualStyleBackColor = true;
this.btnVentasMes.Click += new System.EventHandler(this.btnVentasMes_Click);
//
// Estadiscticas
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -309,8 +377,11 @@
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255)))));
this.BackgroundImage = global::compabetov2.Properties.Resources.Form;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(955, 627);
this.ClientSize = new System.Drawing.Size(1038, 772);
this.ControlBox = false;
this.Controls.Add(this.btnVentasMes);
this.Controls.Add(this.btnVentasDia);
this.Controls.Add(this.lbTotalDiaNeto);
this.Controls.Add(this.lbMesSEnvio);
this.Controls.Add(this.lbDiaSEnvio);
this.Controls.Add(this.pictureBox2);
@@ -342,18 +413,10 @@
private System.Windows.Forms.DateTimePicker dtpBuscar;
private System.Windows.Forms.DataGridView dgvDia;
private System.Windows.Forms.DataGridViewTextBoxColumn Producto;
private System.Windows.Forms.DataGridViewTextBoxColumn Precio;
private System.Windows.Forms.DataGridViewTextBoxColumn Cantidad;
private System.Windows.Forms.DataGridViewTextBoxColumn Total;
private System.Windows.Forms.Button btnBuscar;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.DataGridView dgvMes;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
private System.Windows.Forms.Label lbProductDia;
private System.Windows.Forms.Label lbVendedorDia;
private System.Windows.Forms.Label lbTotalDia;
@@ -363,5 +426,20 @@
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Label lbDiaSEnvio;
private System.Windows.Forms.Label lbMesSEnvio;
private System.Windows.Forms.DataGridViewTextBoxColumn Producto;
private System.Windows.Forms.DataGridViewTextBoxColumn Precio;
private System.Windows.Forms.DataGridViewTextBoxColumn precioCompra;
private System.Windows.Forms.DataGridViewTextBoxColumn Cantidad;
private System.Windows.Forms.DataGridViewTextBoxColumn Total;
private System.Windows.Forms.DataGridViewTextBoxColumn totalNeto;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private System.Windows.Forms.DataGridViewTextBoxColumn PrecioCompraMes;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
private System.Windows.Forms.DataGridViewTextBoxColumn totalNetoMes;
private System.Windows.Forms.Label lbTotalDiaNeto;
private System.Windows.Forms.Button btnVentasDia;
private System.Windows.Forms.Button btnVentasMes;
}
}
+126 -88
View File
@@ -15,7 +15,9 @@ namespace compabetov2
{
public partial class Estadiscticas : Form
{
Dictionary<string, List<Dictionary<string, dynamic>>> resumen;
private List<VentaModel> ventasDia;
private List<VentaModel> ventasMes;
public Estadiscticas()
{
InitializeComponent();
@@ -33,11 +35,15 @@ namespace compabetov2
string fechaBuscaStr = dtpBuscar.Text;
DateTime.TryParseExact(fechaBuscaStr, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime fechaBuscar);
resumen = service.estadisticas(fechaBuscar);
ventasDia = service.conseguirVentasDia(fechaBuscar);
ventasMes = service.conseguirVentasMes(fechaBuscar);
List<DetalleVentaModel> productosMes = estadisticasMes();
List<DetalleVentaModel> productosDia = estadisticasDia();
decimal totalmes = totalMes();
decimal totaldia = totalDia();
decimal totaldianeto = totalDiaNeto();
Dictionary<string, List<Envio>> envios = service.conseguirEnvioMes(fechaBuscar);
Dictionary<string,dynamic> estadisticas = new Dictionary<string, dynamic>
@@ -55,6 +61,7 @@ namespace compabetov2
{ "productoMasVendido", prodctoMasVendido(productosDia) },
{ "mejorVendedor", mejorVenderdorDia() },
{ "totalDia", totalDia()},
{ "totalNetoDia", totaldianeto },
{ "EnvioCantidad", totalDiaSinEnvio(envios) },
}
}
@@ -74,74 +81,118 @@ namespace compabetov2
}
private decimal totalMes()
{
List<Dictionary<string, dynamic>> mes = resumen["mes"];
return calcularTotal(mes);
}
private decimal totalDia()
{
List<Dictionary<string, dynamic>> dia = resumen["dia"];
return calcularTotal(dia);
}
private decimal calcularTotal(List<Dictionary<string, dynamic>> resumen)
{
decimal total = 0;
foreach (Dictionary<string, dynamic> venta_y_detalles in resumen)
foreach(VentaModel venta in ventasMes)
{
VentaModel venta = venta_y_detalles["venta"];
total += venta.total;
}
return total;
}
private List<DetalleVentaModel> estadisticasDia()
private decimal totalDia()
{
//solo copie y pegue le metodo estadisticas dia y cambie el key en resumen de mes a dia
List<Dictionary<string, dynamic>> mes = resumen["dia"];
decimal total = 0;
List<DetalleVentaModel> detallesMes = new List<DetalleVentaModel>();
foreach (Dictionary<string, dynamic> venta_y_detalles in mes)
foreach (VentaModel venta in ventasDia)
{
foreach (DetalleVentaModel detallesVenta in venta_y_detalles["detalles"])
total += venta.total;
}
return total;
}
private decimal totalDiaNeto()
{
decimal total = 0;
foreach (VentaModel venta in ventasDia)
{
List<DetalleVentaModel> detalles = service.conseguirDetallesVenta(venta);
decimal totalDetalle = 0;
foreach(DetalleVentaModel detalle in detalles)
{
totalDetalle += detalle.cantidad * (detalle.producto.precio - detalle.producto.precioCompra);
}
total += totalDetalle;
}
return total;
}
private List<DetalleVentaModel> estadisticasMes()
{
List<DetalleVentaModel> detallesMes = new List<DetalleVentaModel>();
//recorre las ventas del mes
foreach (VentaModel venta in ventasMes)
{
//consigue los detalles de la venta
List<DetalleVentaModel> detallesVenta = service.conseguirDetallesVenta(venta);
//recorre los detalles de la venta
foreach (DetalleVentaModel detalle in detallesVenta)
{
int totalElementos = detallesMes.Count;
int contador = 0;
for (int i = 0; i <= totalElementos; i++)
{
contador++;
//si no encuentra el producto lo agrega
if (i == totalElementos)
{
DetalleVentaModel detalleAgregar = new DetalleVentaModel(detallesVenta.cantidad, detallesVenta.producto, detallesVenta.idVenta);
DetalleVentaModel detalleAgregar = new DetalleVentaModel(detalle.cantidad, detalle.producto, detalle.idVenta);
detallesMes.Add(detalleAgregar);
break;
}
DetalleVentaModel producto = detallesMes[i];
if (producto.producto.nombre.Equals(detallesVenta.producto.nombre))
//si encuentra el produco solo aumneta la cantidad
if (producto.producto.nombre.Equals(detalle.producto.nombre))
{
producto.cantidad += detallesVenta.cantidad;
producto.cantidad += detalle.cantidad;
break;
}
}
}
}
return detallesMes;
}
private List<DetalleVentaModel> estadisticasDia()
{
List<DetalleVentaModel> detallesDia = new List<DetalleVentaModel>();
//recorre las ventas del mes
foreach (VentaModel venta in ventasDia)
{
//consigue los detalles de la venta
List<DetalleVentaModel> detallesVenta = service.conseguirDetallesVenta(venta);
//recorre los detalles de la venta
foreach (DetalleVentaModel detalle in detallesVenta)
{
int totalElementos = detallesDia.Count;
int contador = 0;
for (int i = 0; i <= totalElementos; i++)
{
contador++;
//si no encuentra el producto lo agrega
if (i == totalElementos)
{
DetalleVentaModel detalleAgregar = new DetalleVentaModel(detalle.cantidad, detalle.producto, detalle.idVenta);
detallesDia.Add(detalleAgregar);
break;
}
//si no existe el producto lo agrega
DetalleVentaModel producto = detallesDia[i];
//si encuentra el produco solo aumneta la cantidad
if (producto.producto.nombre.Equals(detalle.producto.nombre))
{
producto.cantidad += detalle.cantidad;
break;
}
}
if (contador == 0)
{
detallesMes.Add(detallesVenta);
}
}
}
return detallesMes;
return detallesDia;
}
private void mostrarDatos(Dictionary<string, dynamic> estadisticas)
@@ -159,20 +210,27 @@ namespace compabetov2
// Crear celdas para la nueva fila
DataGridViewCell productoN = new DataGridViewTextBoxCell();
DataGridViewCell precio = new DataGridViewTextBoxCell();
DataGridViewCell precioCompra = new DataGridViewTextBoxCell();
DataGridViewCell cantidad = new DataGridViewTextBoxCell();
DataGridViewCell total = new DataGridViewTextBoxCell();
DataGridViewCell totalNeto = new DataGridViewTextBoxCell();
// Establecer los valores de las celdas (puedes ajustar según tu necesidad)
productoN.Value = $"{producto.producto.nombre}";
precio.Value = $"{producto.producto.precio}";
precioCompra.Value = $"{producto.producto.precioCompra}";
cantidad.Value = $"{producto.cantidad}";
total.Value = $"{producto.cantidad * producto.producto.precio}";
totalNeto.Value = $"{producto.cantidad * (producto.producto.precio - producto.producto.precioCompra)}";
// Agregar las celdas a la fila
nuevaFila.Cells.Add(productoN);
nuevaFila.Cells.Add(precio);
nuevaFila.Cells.Add(precioCompra);
nuevaFila.Cells.Add(cantidad);
nuevaFila.Cells.Add(total);
nuevaFila.Cells.Add(totalNeto);
// Agregar la nueva fila al DataGridView
dgvMes.Rows.Add(nuevaFila);
@@ -195,20 +253,26 @@ namespace compabetov2
// Crear celdas para la nueva fila
DataGridViewCell productoN = new DataGridViewTextBoxCell();
DataGridViewCell precio = new DataGridViewTextBoxCell();
DataGridViewCell precioCompra = new DataGridViewTextBoxCell();
DataGridViewCell cantidad = new DataGridViewTextBoxCell();
DataGridViewCell total = new DataGridViewTextBoxCell();
DataGridViewCell totalNeto = new DataGridViewTextBoxCell();
// Establecer los valores de las celdas (puedes ajustar según tu necesidad)
productoN.Value = $"{producto.producto.nombre}";
precio.Value = $"{producto.producto.precio}";
precioCompra.Value = $"{producto.producto.precioCompra}";
cantidad.Value = $"{producto.cantidad}";
total.Value = $"{producto.cantidad * producto.producto.precio}";
totalNeto.Value = $"{producto.cantidad * (producto.producto.precio - producto.producto.precioCompra)}";
// Agregar las celdas a la fila
nuevaFila.Cells.Add(productoN);
nuevaFila.Cells.Add(precio);
nuevaFila.Cells.Add(precioCompra);
nuevaFila.Cells.Add(cantidad);
nuevaFila.Cells.Add(total);
nuevaFila.Cells.Add(totalNeto);
// Agregar la nueva fila al DataGridView
dgvDia.Rows.Add(nuevaFila);
@@ -219,61 +283,19 @@ namespace compabetov2
lbProductDia.Text = $"Producto mas vendido: {estadisticas["dia"]["productoMasVendido"]}";
lbVendedorDia.Text = $"Mejor vendedor: {estadisticas["dia"]["mejorVendedor"]}";
lbDiaSEnvio.Text = $"Total del dia sin envios: ${totalSinEnvioDia}";
lbTotalDiaNeto.Text = $"Total neto del dia: ${estadisticas["dia"]["totalNetoDia"]}";
}
private List<DetalleVentaModel> estadisticasMes()
{
List<Dictionary<string, dynamic>> mes = resumen["mes"];
List <DetalleVentaModel> detallesMes = new List<DetalleVentaModel>();
foreach (Dictionary<string, dynamic> venta_y_detalles in mes)
{
foreach (DetalleVentaModel detallesVenta in venta_y_detalles["detalles"])
{
int totalElementos = detallesMes.Count;
int contador = 0;
for(int i = 0; i <= totalElementos; i++) {
contador++;
//si no encuentra el producto lo agrega
if (i == totalElementos)
{
DetalleVentaModel detalleAgregar = new DetalleVentaModel(detallesVenta.cantidad, detallesVenta.producto, detallesVenta.idVenta);
detallesMes.Add(detalleAgregar);
break;
}
DetalleVentaModel producto = detallesMes[i];
//si encuentra el produco solo aumneta la cantidad
if (producto.producto.nombre.Equals(detallesVenta.producto.nombre))
{
producto.cantidad += detallesVenta.cantidad;
break;
}
//si no existe el producto lo agrega
}
if(contador == 0)
{
detallesMes.Add(detallesVenta);
}
}
}
return detallesMes;
}
private string mejorVenderdorMes()
{
List<Dictionary<string, dynamic>> mes = resumen["mes"];
string mejorVendedor = "";
int contadorNumeroVentas = 0;
Dictionary<string,int> empleados = new Dictionary<string,int>();
foreach(Dictionary<string, dynamic> venta_y_detalle in mes)
foreach(VentaModel venta in ventasMes)
{
VentaModel venta = venta_y_detalle["venta"];
if (empleados.ContainsKey(venta.responzable))
{
@@ -303,7 +325,6 @@ namespace compabetov2
string productoMasVendido = "";
int cantidadProducto = 0;
foreach(DetalleVentaModel producto in productos)
{
if(producto.cantidad > cantidadProducto)
@@ -318,14 +339,12 @@ namespace compabetov2
private string mejorVenderdorDia()
{
List<Dictionary<string, dynamic>> mes = resumen["dia"];
string mejorVendedor = "";
int contadorNumeroVentas = 0;
Dictionary<string, int> empleados = new Dictionary<string, int>();
foreach (Dictionary<string, dynamic> venta_y_detalle in mes)
foreach (VentaModel venta in ventasDia)
{
VentaModel venta = venta_y_detalle["venta"];
if (empleados.ContainsKey(venta.responzable))
{
@@ -383,5 +402,24 @@ namespace compabetov2
{
this.Close();
}
private void dgvDia_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void btnVentasDia_Click(object sender, EventArgs e)
{
RegistroVentas ventana = new RegistroVentas(ventasDia,this);
ventana.Owner = this;
ventana.Show();
}
private void btnVentasMes_Click(object sender, EventArgs e)
{
RegistroVentas ventana = new RegistroVentas(ventasMes, this);
ventana.Owner = this;
ventana.Show();
}
}
}
+48
View File
@@ -123,22 +123,70 @@
<metadata name="Precio.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="precioCompra.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Cantidad.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Total.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="totalNeto.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Producto.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Precio.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="precioCompra.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Cantidad.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Total.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="totalNeto.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PrecioCompraMes.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="totalNetoMes.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PrecioCompraMes.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="totalNetoMes.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
+100
View File
@@ -0,0 +1,100 @@
namespace compabetov2
{
partial class RegistroVentas
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panelVentas = new System.Windows.Forms.FlowLayoutPanel();
this.lbContador = new System.Windows.Forms.Label();
this.btnMenos = new System.Windows.Forms.Button();
this.btnMas = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// panelVentas
//
this.panelVentas.AutoScroll = true;
this.panelVentas.Location = new System.Drawing.Point(23, 48);
this.panelVentas.Name = "panelVentas";
this.panelVentas.Size = new System.Drawing.Size(393, 547);
this.panelVentas.TabIndex = 0;
//
// lbContador
//
this.lbContador.AutoSize = true;
this.lbContador.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbContador.Location = new System.Drawing.Point(171, 13);
this.lbContador.Name = "lbContador";
this.lbContador.Size = new System.Drawing.Size(96, 24);
this.lbContador.TabIndex = 0;
this.lbContador.Text = "1000-1000";
//
// btnMenos
//
this.btnMenos.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnMenos.Location = new System.Drawing.Point(77, 12);
this.btnMenos.Name = "btnMenos";
this.btnMenos.Size = new System.Drawing.Size(75, 30);
this.btnMenos.TabIndex = 1;
this.btnMenos.Text = "-";
this.btnMenos.UseVisualStyleBackColor = true;
this.btnMenos.Click += new System.EventHandler(this.btnMenos_Click);
//
// btnMas
//
this.btnMas.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnMas.Location = new System.Drawing.Point(292, 13);
this.btnMas.Name = "btnMas";
this.btnMas.Size = new System.Drawing.Size(75, 30);
this.btnMas.TabIndex = 2;
this.btnMas.Text = "+";
this.btnMas.UseVisualStyleBackColor = true;
this.btnMas.Click += new System.EventHandler(this.btnMas_Click);
//
// RegistroVentas
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(447, 607);
this.Controls.Add(this.btnMas);
this.Controls.Add(this.btnMenos);
this.Controls.Add(this.lbContador);
this.Controls.Add(this.panelVentas);
this.Name = "RegistroVentas";
this.Text = "RegistroVentas";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.FlowLayoutPanel panelVentas;
private System.Windows.Forms.Label lbContador;
private System.Windows.Forms.Button btnMenos;
private System.Windows.Forms.Button btnMas;
}
}
+103
View File
@@ -0,0 +1,103 @@
using compabetov2.database;
using compabetov2.database.modelos;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace compabetov2
{
public partial class RegistroVentas : Form
{
List<VentaModel> ventas;
Estadiscticas ventanaPadre;
public RegistroVentas(List<VentaModel> ventas,Estadiscticas ventanaPadre)
{
InitializeComponent();
this.ventanaPadre = ventanaPadre;
this.ventas = ventas;
llenarPanel();
}
private void llenarPanel()
{
foreach(VentaModel venta in ventas)
{
TableLayoutPanel carta = new TableLayoutPanel();
carta.ColumnCount = 1;
carta.RowCount = 2;
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 75F));
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));
carta.Width = 700;
carta.Height = 170;
FlowLayoutPanel infoPanel = new FlowLayoutPanel();
infoPanel.FlowDirection = FlowDirection.TopDown;
infoPanel.Dock = DockStyle.Fill;
Label lbFecha = new Label();
lbFecha.Text = $"Fecha: {venta.fecha}";
lbFecha.Font = new Font(lbFecha.Font.FontFamily, 12);
lbFecha.Width = 700;
Label lbResponzable = new Label();
lbResponzable.Text = $"Responzable: {venta.responzable}";
lbResponzable.Font = new Font(lbResponzable.Font.FontFamily, 12);
lbResponzable.Width = 700;
Label lbTotal = new Label();
lbTotal.Text = $"Total: {venta.total}";
lbTotal.Font = new Font(lbTotal.Font.FontFamily, 12);
lbTotal.Width = 700;
TableLayoutPanel botonesPanel = new TableLayoutPanel();
botonesPanel.RowCount = 1;
botonesPanel.ColumnCount = 4;
botonesPanel.Dock = DockStyle.Fill;
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
Button btnDetalles = new Button();
btnDetalles.Text = "Detalles";
btnDetalles.Dock = DockStyle.Fill;
btnDetalles.FlatStyle = FlatStyle.Flat;
btnDetalles.FlatAppearance.BorderSize = 0;
btnDetalles.BackColor = Color.FromArgb(33, 90, 255);
btnDetalles.Font = new Font(btnDetalles.Font.FontFamily, 16);
btnDetalles.ForeColor = Color.White;
btnDetalles.Click += new EventHandler(delegate (object sender, EventArgs e)
{
});
infoPanel.Controls.Add(lbFecha);
infoPanel.Controls.Add(lbTotal);
infoPanel.Controls.Add(lbResponzable);
botonesPanel.Controls.Add(btnDetalles, 0, 0);
carta.Controls.Add(infoPanel, 0, 0);
carta.Controls.Add(botonesPanel, 0, 1);
panelVentas.Controls.Add(carta);
}
}
private void btnMenos_Click(object sender, EventArgs e)
{
}
private void btnMas_Click(object sender, EventArgs e)
{
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+9
View File
@@ -273,6 +273,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RegistroVentas.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RegistroVentas.Designer.cs">
<DependentUpon>RegistroVentas.cs</DependentUpon>
</Compile>
<Compile Include="SqlServerTypes\Loader.cs" />
<Compile Include="Ventas\datosCuenta.cs">
<SubType>Form</SubType>
@@ -395,6 +401,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RegistroVentas.resx">
<DependentUpon>RegistroVentas.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Ventas\datosCuenta.resx">
<DependentUpon>datosCuenta.cs</DependentUpon>
</EmbeddedResource>
+46 -37
View File
@@ -427,18 +427,32 @@ namespace compabetov2.database
return DAO.concluirEnvioDAO(envio, detallesEnvio, importes);
}
public static Dictionary<string, List<Dictionary<string,dynamic>>> estadisticas(DateTime fecha)
public static List<VentaModel> conseguirVentasMes(DateTime fecha)
{
Dictionary<string, List<Dictionary<string, dynamic>>> resumen = new Dictionary<string, List<Dictionary<string, dynamic>>>();
List<Dictionary<string, dynamic>> listMes = new List<Dictionary<string, dynamic>>();
List<Dictionary<string, dynamic>> listDia = new List<Dictionary<string, dynamic>>();
List<VentaModel> ventasMes = new List<VentaModel>();
SQLiteDataReader readerVentas = DAO.conseguirVentasMesDAO(fecha);
while (readerVentas.Read())
{
VentaModel venta = new VentaModel(
readerVentas.GetDecimal(2),//total
(int)readerVentas.GetInt64(0),//id
readerVentas.GetString(1),//fecha
readerVentas.GetString(3)//resposable
);
ventasMes.Add(venta);
}
return ventasMes;
}
public static List<VentaModel> conseguirVentasDia(DateTime fecha)
{
List<VentaModel> ventasDia = new List<VentaModel>();
SQLiteDataReader readerVentas = DAO.conseguirVentasMesDAO(fecha);
string formato = "dd/MM/yyyy";
while (readerVentas.Read())
{
Dictionary<string,dynamic> dicVenta = new Dictionary<string,dynamic>();
VentaModel venta = new VentaModel(
readerVentas.GetDecimal(2),
(int)readerVentas.GetInt64(0),
@@ -446,45 +460,16 @@ namespace compabetov2.database
readerVentas.GetString(3)
);
List<DetalleVentaModel> detallesVenta = new List<DetalleVentaModel>();
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
while (readerDetalleVenta.Read())
{
decimal precioCompra = readerDetalleVenta.GetOrdinal("precioCompra");
DetalleVentaModel detalleVenta = new DetalleVentaModel(
(int)readerDetalleVenta.GetInt64(2),
new Variante((int)readerDetalleVenta.GetInt64(3),
readerDetalleVenta["nombre"].ToString(),
readerDetalleVenta.GetDecimal(5),
(int)readerDetalleVenta.GetInt64(6),
"",
(int)readerDetalleVenta.GetInt64(8),
precioCompra)
);
detallesVenta.Add( detalleVenta );
}
dicVenta.Add("venta", venta);
dicVenta.Add("detalles", detallesVenta as List<DetalleVentaModel>);
string[] fecha_hora = venta.fecha.Split(' ');
string fechaVentaStr = fecha_hora[0];
DateTime.TryParseExact(fechaVentaStr, formato, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime fechaVenta);
if (fecha.Day == fechaVenta.Day)
{
listDia.Add(dicVenta);
ventasDia.Add(venta);
}
listMes.Add(dicVenta);
}
resumen.Add("mes", listMes);
resumen.Add("dia", listDia);
return resumen;
return ventasDia;
}
public static List<Variante> conseguirProductosFiltrados(string nombreProducto)
@@ -519,6 +504,30 @@ namespace compabetov2.database
return productos;
}
public static List<DetalleVentaModel> conseguirDetallesVenta(VentaModel venta)
{
List<DetalleVentaModel> detallesVenta = new List<DetalleVentaModel>();
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
while (readerDetalleVenta.Read())
{
decimal precioCompra = readerDetalleVenta.GetDecimal(3);
Variante variante = new Variante(
(int)readerDetalleVenta.GetInt64(5),//id
readerDetalleVenta["nombre"].ToString(),//nombre
readerDetalleVenta.GetDecimal(4),//precioVenta
(int)readerDetalleVenta.GetInt64(8),//cantidad
"",//img
(int)readerDetalleVenta.GetInt64(10),//fkProducto
precioCompra);
DetalleVentaModel detalleVenta = new DetalleVentaModel(
(int)readerDetalleVenta.GetInt64(2),
variante
);
detallesVenta.Add( detalleVenta );
}
return detallesVenta;
}
public static Dictionary<string, List<Envio>> conseguirEnvioMes(DateTime fecha)
{
Binary file not shown.
@@ -1 +1 @@
71f328ca57677b5d4698632bb6522f64a4fe76d47ddec8e1718dc439db6af453
4bc0b21d4c0f19e1e9ae1bfa37f9e96b5658ecea100004a31759a9d5405753d7
@@ -165,3 +165,4 @@ C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.a
C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.editarvariante.resources
C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.Variantes.resources
C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.admin.editarvariante.resources
C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.RegistroVentas.resources
Binary file not shown.
Binary file not shown.
Binary file not shown.