Mermas Design

This commit is contained in:
Michael Robles
2024-01-22 02:36:18 -07:00
parent 2db5006ebb
commit 38de489250
67 changed files with 364 additions and 186 deletions
+222
View File
@@ -0,0 +1,222 @@
namespace compabetov2
{
partial class inventario
{
/// <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.lblhora = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.panel2 = new System.Windows.Forms.Panel();
this.pictureBox7 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.btnAgregarStock = new System.Windows.Forms.Button();
this.stockPanel = new System.Windows.Forms.FlowLayoutPanel();
this.flowLayoutPanel1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
this.SuspendLayout();
//
// lblhora
//
this.lblhora.AutoSize = true;
this.lblhora.Font = new System.Drawing.Font("Microsoft Sans Serif", 60F);
this.lblhora.ForeColor = System.Drawing.Color.MediumBlue;
this.lblhora.Location = new System.Drawing.Point(933, 9);
this.lblhora.Name = "lblhora";
this.lblhora.Size = new System.Drawing.Size(299, 113);
this.lblhora.TabIndex = 10;
this.lblhora.Text = "Stock";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.BackgroundImage = global::compabetov2.Properties.Resources.rec;
this.flowLayoutPanel1.Controls.Add(this.panel2);
this.flowLayoutPanel1.Controls.Add(this.button1);
this.flowLayoutPanel1.Controls.Add(this.button2);
this.flowLayoutPanel1.Controls.Add(this.button3);
this.flowLayoutPanel1.Controls.Add(this.button5);
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(324, 1061);
this.flowLayoutPanel1.TabIndex = 8;
//
// panel2
//
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";
this.panel2.Size = new System.Drawing.Size(312, 263);
this.panel2.TabIndex = 8;
//
// pictureBox7
//
this.pictureBox7.Image = global::compabetov2.Properties.Resources.HomeroMenu;
this.pictureBox7.Location = new System.Drawing.Point(64, 34);
this.pictureBox7.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBox7.Name = "pictureBox7";
this.pictureBox7.Size = new System.Drawing.Size(190, 197);
this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox7.TabIndex = 8;
this.pictureBox7.TabStop = false;
//
// button1
//
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.FlatAppearance.BorderSize = 0;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
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";
this.button1.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button1.Size = new System.Drawing.Size(312, 114);
this.button1.TabIndex = 8;
this.button1.Text = "Menú";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.Transparent;
this.button2.FlatAppearance.BorderSize = 0;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
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);
this.button2.TabIndex = 9;
this.button2.Text = "Estadisticas";
this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.button2.UseVisualStyleBackColor = false;
//
// button3
//
this.button3.BackColor = System.Drawing.Color.Transparent;
this.button3.FlatAppearance.BorderSize = 0;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
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";
this.button3.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button3.Size = new System.Drawing.Size(312, 114);
this.button3.TabIndex = 10;
this.button3.Text = "Productos";
this.button3.UseVisualStyleBackColor = false;
//
// button5
//
this.button5.BackColor = System.Drawing.Color.Transparent;
this.button5.FlatAppearance.BorderSize = 0;
this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
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, 623);
this.button5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.button5.Name = "button5";
this.button5.Padding = new System.Windows.Forms.Padding(51, 0, 0, 0);
this.button5.Size = new System.Drawing.Size(312, 114);
this.button5.TabIndex = 12;
this.button5.Text = "Salir";
this.button5.UseVisualStyleBackColor = false;
//
// btnAgregarStock
//
this.btnAgregarStock.Location = new System.Drawing.Point(992, 181);
this.btnAgregarStock.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnAgregarStock.Name = "btnAgregarStock";
this.btnAgregarStock.Size = new System.Drawing.Size(133, 28);
this.btnAgregarStock.TabIndex = 12;
this.btnAgregarStock.Text = "Agregar stock";
this.btnAgregarStock.UseVisualStyleBackColor = true;
this.btnAgregarStock.Click += new System.EventHandler(this.button6_Click_1);
//
// stockPanel
//
this.stockPanel.Location = new System.Drawing.Point(525, 245);
this.stockPanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.stockPanel.Name = "stockPanel";
this.stockPanel.Size = new System.Drawing.Size(1112, 638);
this.stockPanel.TabIndex = 13;
this.stockPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.stockPanel_Paint);
//
// inventario
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1827, 922);
this.Controls.Add(this.stockPanel);
this.Controls.Add(this.btnAgregarStock);
this.Controls.Add(this.lblhora);
this.Controls.Add(this.flowLayoutPanel1);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "inventario";
this.Text = "inventario";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.inventario_Load);
this.flowLayoutPanel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox7;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label lblhora;
private System.Windows.Forms.Button btnAgregarStock;
private System.Windows.Forms.FlowLayoutPanel stockPanel;
}
}
+252
View File
@@ -0,0 +1,252 @@
using compabetov2.database;
using compabetov2.database.modelos;
using compabetov2.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
namespace compabetov2
{
public partial class inventario : Form
{
private List<Producto> productos;
private LoginModel loginPrincipal;
public inventario(LoginModel loginPrincipal)
{
InitializeComponent();
llenarPanel();
this.loginPrincipal = loginPrincipal;
}
private void llenarPanel()
{
stockPanel.Controls.Clear();
productos = service.conseguirProductos();
foreach (Producto producto in productos)
{
TableLayoutPanel filaLayout = new TableLayoutPanel();
filaLayout.RowCount = 1;
filaLayout.ColumnCount = 2;
filaLayout.Height = 100;
filaLayout.Width = 830;
filaLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
filaLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
filaLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
TableLayoutPanel informacionProducto = new TableLayoutPanel();
informacionProducto.RowCount = 1;
informacionProducto.ColumnCount = 2;
informacionProducto.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
informacionProducto.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80F));
informacionProducto.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
informacionProducto.Dock = DockStyle.Fill;
Label idProducto = new Label();
idProducto.Text = producto.idProducto.ToString();
idProducto.BackColor = Color.FromArgb(82, 82, 82);
idProducto.ForeColor = Color.White;
idProducto.AutoSize = true;
idProducto.Dock = DockStyle.Left;
PictureBox imagen = new PictureBox();
string rutaImg = Path.Combine(Application.StartupPath, "Resources", producto.img);
imagen.Image = Image.FromFile(rutaImg);
imagen.Dock = DockStyle.Fill;
imagen.BackgroundImageLayout = ImageLayout.Stretch;
imagen.SizeMode = PictureBoxSizeMode.Zoom;
imagen.Controls.Add(idProducto);
Label nombreStock = new Label();
nombreStock.Text = producto.nombre + " - Stock: " + producto.stock.ToString();
nombreStock.Font = new Font(nombreStock.Font.FontFamily, 16);
nombreStock.Dock = DockStyle.Fill;
nombreStock.TextAlign = ContentAlignment.MiddleCenter;
//panel de agregar stock
TableLayoutPanel agregarPanel = new TableLayoutPanel();
agregarPanel.Dock = DockStyle.Fill;
agregarPanel.RowCount = 1;
agregarPanel.ColumnCount = 3;
agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60F));
agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
agregarPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
TextBox txtStockAgregar = new TextBox();
txtStockAgregar.Text = "0";
txtStockAgregar.Height = 60;
txtStockAgregar.Width = 200;
txtStockAgregar.Anchor = AnchorStyles.None;
txtStockAgregar.Font = new Font(txtStockAgregar.Font.FontFamily, 17);
Button btnMenos = new Button();
btnMenos.Text = "-";
btnMenos.Width = 60;
btnMenos.Height = 60;
btnMenos.Font = new Font(btnMenos.Font.FontFamily, 30);
btnMenos.ForeColor = Color.White;
btnMenos.FlatStyle = FlatStyle.Flat;
btnMenos.FlatAppearance.BorderSize = 0;
btnMenos.BackColor = Color.FromArgb(33, 90, 255);
btnMenos.Anchor = AnchorStyles.None;
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
{
try
{
int numeroContador = int.Parse(txtStockAgregar.Text);
txtStockAgregar.Text = (numeroContador - 1).ToString();
}
catch (Exception ex)
{
txtStockAgregar.Text = "0";
}
});
Button btnMas = new Button();
btnMas.Text = "+";
btnMas.Width = 60;
btnMas.Height = 60;
btnMas.Font = new Font(btnMas.Font.FontFamily, 30);
btnMas.ForeColor = Color.White;
btnMas.BackColor = Color.FromArgb(33, 90, 255);
btnMas.FlatStyle = FlatStyle.Flat;
btnMas.FlatAppearance.BorderSize = 0;
btnMas.Anchor = AnchorStyles.None;
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
{
try
{
int numeroContador = int.Parse(txtStockAgregar.Text);
txtStockAgregar.Text = (numeroContador + 1).ToString();
}catch (Exception ex)
{
txtStockAgregar.Text = "0";
}
});
informacionProducto.Controls.Add(imagen,0,0);
informacionProducto.Controls.Add(nombreStock,1,0);
agregarPanel.Controls.Add(txtStockAgregar, 0, 0);
agregarPanel.Controls.Add(btnMenos, 1, 0);
agregarPanel.Controls.Add(btnMas, 2, 0);
filaLayout.Controls.Add(informacionProducto, 0, 0);
filaLayout.Controls.Add(agregarPanel, 1, 0);
stockPanel.Controls.Add(filaLayout);
}
}
private void button1_Click(object sender, EventArgs e)
{
// Cerrar el formulario de ventas
this.Close();
// Verificar si ya hay una instancia del formulario principal
MenuPrincipal menuprincipalForm = Application.OpenForms.OfType<MenuPrincipal>().FirstOrDefault();
if (menuprincipalForm == null)
{
// Si no hay una instancia, crear una nueva
menuprincipalForm = new MenuPrincipal(loginPrincipal);
// Establecer el formulario principal como el formulario MDI padre
menuprincipalForm.MdiParent = this.MdiParent;
// Mostrar el formulario principal
menuprincipalForm.Show();
}
else
{
// Si ya hay una instancia, simplemente llevarlo al frente
menuprincipalForm.BringToFront();
}
}
private void button6_Click(object sender, EventArgs e)
{
}
private void button6_Click_1(object sender, EventArgs e)
{
List<Producto> stockNuevo = new List<Producto>();
try {
foreach (Control control in stockPanel.Controls)
{
TableLayoutPanel informacionProducto = control.Controls[0] as TableLayoutPanel;
TableLayoutPanel agregarPanel = control.Controls[1] as TableLayoutPanel;
//id
Label lbIdProducto = informacionProducto.Controls[0].Controls[0] as Label;
int idProducto = int.Parse(lbIdProducto.Text);
//stock a agregar
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
int stock = int.Parse(txtStock.Text);
if (stock != 0)
{
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
stockNuevo.Add(productoStockNuuevo);
}
}
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
for (int i = 0; i < stockNuevo.Count; i++)
{
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
}
if (stockNuevo.Count > 0)
{
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
service.aumentarStock(stockNuevo);
llenarPanel();
}
}
}
catch(Exception ex) {
MessageBox.Show("Solo debe introducir numeros","Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void inventario_Load(object sender, EventArgs e)
{
}
private void stockPanel_Paint(object sender, PaintEventArgs 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>