diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index 079dccf..b27c6a8 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index fd80244..1bd1e0e 100644 Binary files a/bin/Debug/compabetov2.exe and b/bin/Debug/compabetov2.exe differ diff --git a/bin/Debug/compabetov2.pdb b/bin/Debug/compabetov2.pdb index b7f4346..b9373f1 100644 Binary files a/bin/Debug/compabetov2.pdb and b/bin/Debug/compabetov2.pdb differ diff --git a/bin/Debug/data.db b/bin/Debug/data.db index fd8c616..1e2530b 100644 Binary files a/bin/Debug/data.db and b/bin/Debug/data.db differ diff --git a/database/DAO.cs b/database/DAO.cs index f0dae2e..1651539 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -147,8 +147,8 @@ namespace compabetov2.database var db_conexion = new Conexion(); try { - using (SQLiteConnection conexion = db_conexion.get_connection()) - { + SQLiteConnection conexion = db_conexion.get_connection(); + conexion.Open(); string sql = "SELECT * FROM Producto INNER JOIN Categoria ON Producto.fk_idcategoria = Categoria.idcategoria"; @@ -156,7 +156,6 @@ namespace compabetov2.database reader = command.ExecuteReader(); return reader; - } } catch (SQLiteException ex) { MessageBox.Show(ex.Message); @@ -184,7 +183,7 @@ namespace compabetov2.database 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("@precio", producto.precion); command.Parameters.AddWithValue("@img", producto.img); diff --git a/database/service.cs b/database/service.cs index 48e3a21..b40a626 100644 --- a/database/service.cs +++ b/database/service.cs @@ -26,17 +26,17 @@ namespace compabetov2.database while (reader.Read()) { Categoria categoria = new Categoria( - (int)reader["idcategoria"], + int.Parse(reader["idcategoria"].ToString()), reader["nombre"].ToString(), reader["descripcion"].ToString()); Producto producto = new Producto( - (int)reader["idproducto"], + int.Parse(reader["idproducto"].ToString()), reader["nombre"].ToString(), reader["descripcion"].ToString(), - (decimal)reader["precio"], + decimal.Parse(reader["precio"].ToString()), reader["img"].ToString(), - (int)reader["stock"], + int.Parse(reader["stock"].ToString()), categoria); productos.Add(producto); diff --git a/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 10a1a65..4382aa9 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 13a0f52..6fd8f5d 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache index 339d4f0..8f1bb2d 100644 --- a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache +++ b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -953cb31f9b6e74dde952aba09707a9add648ded1 +424f6d4f8bcbc47e89c98d2fa689cb77dffd9f6b5116717e9e8dca5ece3777d7 diff --git a/obj/Debug/compabetov2.csproj.GenerateResource.cache b/obj/Debug/compabetov2.csproj.GenerateResource.cache index 0a4d64a..563c250 100644 Binary files a/obj/Debug/compabetov2.csproj.GenerateResource.cache and b/obj/Debug/compabetov2.csproj.GenerateResource.cache differ diff --git a/obj/Debug/compabetov2.exe b/obj/Debug/compabetov2.exe index fd80244..1bd1e0e 100644 Binary files a/obj/Debug/compabetov2.exe and b/obj/Debug/compabetov2.exe differ diff --git a/obj/Debug/compabetov2.pdb b/obj/Debug/compabetov2.pdb index b7f4346..b9373f1 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ diff --git a/vender.Designer.cs b/vender.Designer.cs index a2fdb5a..c442a1e 100644 --- a/vender.Designer.cs +++ b/vender.Designer.cs @@ -65,11 +65,12 @@ // lblfecha // this.lblfecha.AutoSize = true; - this.lblfecha.Font = new System.Drawing.Font("Poppins SemiBold", 30F); + this.lblfecha.Font = new System.Drawing.Font("Microsoft Sans Serif", 30F); this.lblfecha.ForeColor = System.Drawing.Color.Navy; - this.lblfecha.Location = new System.Drawing.Point(494, 105); + this.lblfecha.Location = new System.Drawing.Point(370, 85); + this.lblfecha.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.lblfecha.Name = "lblfecha"; - this.lblfecha.Size = new System.Drawing.Size(193, 88); + this.lblfecha.Size = new System.Drawing.Size(126, 46); this.lblfecha.TabIndex = 13; this.lblfecha.Text = "label2"; this.lblfecha.TextAlign = System.Drawing.ContentAlignment.TopCenter; @@ -78,11 +79,12 @@ // lblhora // this.lblhora.AutoSize = true; - this.lblhora.Font = new System.Drawing.Font("Poppins SemiBold", 60F); + 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(681, -13); + this.lblhora.Location = new System.Drawing.Point(511, -11); + this.lblhora.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.lblhora.Name = "lblhora"; - this.lblhora.Size = new System.Drawing.Size(365, 177); + this.lblhora.Size = new System.Drawing.Size(249, 91); this.lblhora.TabIndex = 12; this.lblhora.Text = "label1"; this.lblhora.Click += new System.EventHandler(this.lblhora_Click); @@ -91,24 +93,27 @@ // this.flowLayoutPanel2.BackgroundImage = global::compabetov2.Properties.Resources.rec; this.flowLayoutPanel2.Controls.Add(this.panel1); - this.flowLayoutPanel2.Location = new System.Drawing.Point(1605, -1); + this.flowLayoutPanel2.Location = new System.Drawing.Point(1204, -1); + this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Size = new System.Drawing.Size(324, 1192); + this.flowLayoutPanel2.Size = new System.Drawing.Size(243, 968); this.flowLayoutPanel2.TabIndex = 11; // // panel1 // this.panel1.BackColor = System.Drawing.Color.Transparent; this.panel1.Controls.Add(this.pictureBox9); - this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Location = new System.Drawing.Point(2, 2); + this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(312, 263); + this.panel1.Size = new System.Drawing.Size(234, 214); this.panel1.TabIndex = 8; // // pictureBox9 // this.pictureBox9.Image = global::compabetov2.Properties.Resources.HomeroMenu; - this.pictureBox9.Location = new System.Drawing.Point(64, 35); + this.pictureBox9.Location = new System.Drawing.Point(48, 28); + this.pictureBox9.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox9.Name = "pictureBox9"; this.pictureBox9.Size = new System.Drawing.Size(190, 197); this.pictureBox9.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; @@ -125,23 +130,26 @@ this.flowLayoutPanel1.Controls.Add(this.button4); this.flowLayoutPanel1.Controls.Add(this.button5); this.flowLayoutPanel1.Location = new System.Drawing.Point(-1, 0); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(324, 1199); + this.flowLayoutPanel1.Size = new System.Drawing.Size(243, 974); 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, 3); + this.panel2.Location = new System.Drawing.Point(2, 2); + this.panel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(312, 263); + this.panel2.Size = new System.Drawing.Size(234, 214); this.panel2.TabIndex = 8; // // pictureBox7 // this.pictureBox7.Image = global::compabetov2.Properties.Resources.HomeroMenu; - this.pictureBox7.Location = new System.Drawing.Point(64, 35); + this.pictureBox7.Location = new System.Drawing.Point(48, 28); + this.pictureBox7.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox7.Name = "pictureBox7"; this.pictureBox7.Size = new System.Drawing.Size(190, 197); this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; @@ -153,14 +161,15 @@ 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("Poppins SemiBold", 15F); + 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, 272); + this.button1.Location = new System.Drawing.Point(2, 220); + this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button1.Name = "button1"; - this.button1.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.button1.Size = new System.Drawing.Size(312, 115); + this.button1.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); + this.button1.Size = new System.Drawing.Size(234, 93); this.button1.TabIndex = 8; this.button1.Text = "Menú"; this.button1.UseVisualStyleBackColor = false; @@ -170,14 +179,15 @@ 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("Poppins SemiBold", 15F); + 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, 393); + this.button2.Location = new System.Drawing.Point(2, 317); + this.button2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button2.Name = "button2"; - this.button2.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.button2.Size = new System.Drawing.Size(312, 115); + this.button2.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); + this.button2.Size = new System.Drawing.Size(234, 93); this.button2.TabIndex = 9; this.button2.Text = "Estadisticas"; this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -188,14 +198,15 @@ 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("Poppins SemiBold", 15F); + 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, 514); + this.button3.Location = new System.Drawing.Point(2, 414); + this.button3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button3.Name = "button3"; - this.button3.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.button3.Size = new System.Drawing.Size(312, 115); + this.button3.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); + this.button3.Size = new System.Drawing.Size(234, 93); this.button3.TabIndex = 10; this.button3.Text = "Productos"; this.button3.UseVisualStyleBackColor = false; @@ -205,14 +216,15 @@ this.button4.BackColor = System.Drawing.Color.Transparent; this.button4.FlatAppearance.BorderSize = 0; this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button4.Font = new System.Drawing.Font("Poppins SemiBold", 15F); + this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); this.button4.ForeColor = System.Drawing.SystemColors.ButtonHighlight; this.button4.Image = global::compabetov2.Properties.Resources.reportesi; this.button4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.button4.Location = new System.Drawing.Point(3, 635); + this.button4.Location = new System.Drawing.Point(2, 511); + this.button4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button4.Name = "button4"; - this.button4.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.button4.Size = new System.Drawing.Size(312, 115); + this.button4.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); + this.button4.Size = new System.Drawing.Size(234, 93); this.button4.TabIndex = 11; this.button4.Text = "Reportes"; this.button4.UseVisualStyleBackColor = false; @@ -222,51 +234,52 @@ 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("Poppins SemiBold", 15F); + 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, 756); + this.button5.Location = new System.Drawing.Point(2, 608); + this.button5.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button5.Name = "button5"; - this.button5.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.button5.Size = new System.Drawing.Size(312, 115); + this.button5.Padding = new System.Windows.Forms.Padding(38, 0, 0, 0); + this.button5.Size = new System.Drawing.Size(234, 93); this.button5.TabIndex = 12; this.button5.Text = "Salir"; this.button5.UseVisualStyleBackColor = false; - // - // timer1 - // - // // flowLayoutPanel3 // - this.flowLayoutPanel3.Location = new System.Drawing.Point(326, 283); + this.flowLayoutPanel3.Location = new System.Drawing.Point(244, 230); + this.flowLayoutPanel3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.flowLayoutPanel3.Name = "flowLayoutPanel3"; - this.flowLayoutPanel3.Size = new System.Drawing.Size(1273, 946); + this.flowLayoutPanel3.Size = new System.Drawing.Size(955, 769); this.flowLayoutPanel3.TabIndex = 14; + this.flowLayoutPanel3.Paint += new System.Windows.Forms.PaintEventHandler(this.flowLayoutPanel3_Paint); // // textBox1 // this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); - this.textBox1.Location = new System.Drawing.Point(365, 229); + this.textBox1.Location = new System.Drawing.Point(274, 186); + this.textBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(398, 36); + this.textBox1.Size = new System.Drawing.Size(300, 30); this.textBox1.TabIndex = 15; // // textBox2 // this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); - this.textBox2.Location = new System.Drawing.Point(792, 229); + this.textBox2.Location = new System.Drawing.Point(594, 186); + this.textBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(398, 36); + this.textBox2.Size = new System.Drawing.Size(300, 30); this.textBox2.TabIndex = 16; // // vender // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; - this.ClientSize = new System.Drawing.Size(1924, 1055); + this.ClientSize = new System.Drawing.Size(1028, 609); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.flowLayoutPanel3); @@ -274,6 +287,7 @@ this.Controls.Add(this.lblhora); this.Controls.Add(this.flowLayoutPanel2); this.Controls.Add(this.flowLayoutPanel1); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "vender"; this.Text = "vender"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; diff --git a/vender.cs b/vender.cs index 9a9f36d..0cf707a 100644 --- a/vender.cs +++ b/vender.cs @@ -1,12 +1,16 @@ -using System; +using compabetov2.database; +using compabetov2.database.modelos; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; namespace compabetov2 { @@ -18,13 +22,122 @@ namespace compabetov2 private int cantidad = 0; private bool masBtnPresionado = false; private bool menosBtnPresionado = false; - + private List productos; + private List cartas = new List(); + private decimal total = 0; public vender() { InitializeComponent(); + getData(); + llenarLayout(); + } + + private void llenarLayout() + { + foreach (Producto producto in productos) + { + + TableLayoutPanel carta = new TableLayoutPanel(); + carta.ColumnCount = 1; + carta.RowCount = 2; + + carta.RowStyles.Add(new RowStyle(SizeType.Percent, 80F)); + carta.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); + + carta.Width = 200; + carta.Height = 300; + + PictureBox pic = new PictureBox(); + pic.Dock = DockStyle.Fill; + pic.SizeMode = PictureBoxSizeMode.Zoom; + pic.Image = Properties.Resources.Modelo; + pic.BackgroundImageLayout = ImageLayout.Stretch; + pic.Tag = producto.idProducto; + + Label id = new Label(); + id.Text = producto.idProducto.ToString(); + id.BackColor = Color.FromArgb(82, 82, 82); + id.ForeColor = Color.White; + id.Width = 20; + id.Font = new Font(id.Font, FontStyle.Bold); + id.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + pic.Controls.Add(id); + + Label precio = new Label(); + precio.Text = "$5";// + producto.precion.ToString(); + precio.BackColor = Color.FromArgb(82, 82, 82); + precio.ForeColor = Color.White; + precio.Width = 40; + precio.Font = new Font(id.Font, FontStyle.Bold); + precio.Dock = DockStyle.Bottom; + pic.Controls.Add(precio); + + TableLayoutPanel HUD = new TableLayoutPanel(); + HUD.ColumnCount = 3; + HUD.RowCount = 1; + HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + + Label contador = new Label(); + contador.Text = "0"; + contador.Dock = DockStyle.Fill; + contador.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + contador.Font = new Font(contador.Font.FontFamily, 30); + + Button btnMenos = new Button(); + btnMenos.Text = "-"; + btnMenos.Width = 25; + btnMenos.Height = 25; + btnMenos.Font = new Font(btnMenos.Font.FontFamily, 30); + btnMenos.ForeColor = Color.White; + btnMenos.Dock = DockStyle.Fill; + btnMenos.FlatStyle = FlatStyle.Flat; + btnMenos.FlatAppearance.BorderSize = 0; + btnMenos.BackColor = Color.FromArgb(33, 90, 255); + btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e) + { + int numeroContador = int.Parse(contador.Text.ToString()); + contador.Text = (numeroContador - 1).ToString(); + total -= producto.precion; + }); + + + + Button btnMas = new Button(); + btnMas.Text = "+"; + btnMas.Width = 25; + btnMas.Height = 25; + btnMas.Dock = DockStyle.Fill; + 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.Click += new EventHandler(delegate (object sender, EventArgs e) + { + int numeroContador = int.Parse(contador.Text.ToString()); + contador.Text = (numeroContador + 1).ToString(); + total += producto.precion; + }); + + HUD.Controls.Add(btnMenos); + HUD.Controls.Add(contador); + HUD.Controls.Add(btnMas); + + carta.Controls.Add(pic, 0, 0); + carta.Controls.Add(HUD, 0, 1); + cartas.Add(carta); + flowLayoutPanel3.Controls.Add(carta); + } + } + + private void getData() + { + this.productos = service.conseguirProductos(); } private void vender_Load(object sender, EventArgs e) @@ -53,10 +166,13 @@ namespace compabetov2 } - + private void flowLayoutPanel3_Paint(object sender, PaintEventArgs e) + { - } + + } +}