diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index c077cbe..3879607 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,18 +1,7 @@ { "ExpandedNodes": [ - "", - "\\admin", -<<<<<<< HEAD -<<<<<<< HEAD - "\\Cuentas", - "\\database", -======= ->>>>>>> 24f7b01847ca194a06677fedb9c9f495654c5ce3 -======= - "\\Empleados", ->>>>>>> ae6945f7e474edb1bde1c277c092d25b221e151b - "\\Ventas" + "" ], - "SelectedNode": "\\Empleados\\EditarEmpleado1.cs", + "SelectedNode": "\\Solution.sln", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index 7854eb6..6d7e6a6 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/admin/Variantes.Designer.cs b/admin/Variantes.Designer.cs index 90413f3..37bc1d6 100644 --- a/admin/Variantes.Designer.cs +++ b/admin/Variantes.Designer.cs @@ -28,13 +28,38 @@ /// private void InitializeComponent() { + this.VariantePanel = new System.Windows.Forms.FlowLayoutPanel(); + this.btnAgregar = new System.Windows.Forms.Button(); this.SuspendLayout(); // + // VariantePanel + // + this.VariantePanel.AutoScroll = true; + this.VariantePanel.BackColor = System.Drawing.SystemColors.Control; + this.VariantePanel.Location = new System.Drawing.Point(13, 59); + this.VariantePanel.Name = "VariantePanel"; + this.VariantePanel.Size = new System.Drawing.Size(1146, 516); + this.VariantePanel.TabIndex = 16; + // + // btnAgregar + // + this.btnAgregar.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAgregar.Location = new System.Drawing.Point(543, 12); + this.btnAgregar.Name = "btnAgregar"; + this.btnAgregar.Size = new System.Drawing.Size(94, 40); + this.btnAgregar.TabIndex = 17; + this.btnAgregar.Text = "Agregar"; + this.btnAgregar.UseVisualStyleBackColor = true; + this.btnAgregar.Click += new System.EventHandler(this.btnAgregar_Click); + // // Variantes // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 697); + this.ClientSize = new System.Drawing.Size(1171, 587); + this.Controls.Add(this.btnAgregar); + this.Controls.Add(this.VariantePanel); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "Variantes"; this.Text = "Variantes"; this.Load += new System.EventHandler(this.Variantes_Load); @@ -43,5 +68,8 @@ } #endregion + + private System.Windows.Forms.FlowLayoutPanel VariantePanel; + private System.Windows.Forms.Button btnAgregar; } } \ No newline at end of file diff --git a/admin/Variantes.cs b/admin/Variantes.cs index 3fba69e..4ca55eb 100644 --- a/admin/Variantes.cs +++ b/admin/Variantes.cs @@ -1,8 +1,11 @@ -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.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,16 +16,156 @@ namespace compabetov2.admin public partial class Variantes : Form { private crud ventanaPadre; - public Variantes(crud ventanaPadre) + private Producto producto; + private List variantes = new List(); + public Variantes(crud ventanaPadre, Producto producto) { this.ventanaPadre = ventanaPadre; + this.producto = producto; InitializeComponent(); - + llenarLayout(); + } + + public void llenarLayout() + { + VariantePanel.Controls.Clear(); + variantes.Clear(); + variantes = service.conseguirVariante(producto.idProducto); + + + foreach (Variante variante in variantes) + { + TableLayoutPanel filaLayout = new TableLayoutPanel(); + filaLayout.RowCount = 1; + filaLayout.ColumnCount = 2; + filaLayout.Height = 100; + filaLayout.Width = 1115; + 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 = variante.idVariante.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", variante.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 = variante.nombre + " - $" + variante.precio; + nombreStock.Font = new Font(nombreStock.Font.FontFamily, 14); + 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 = 2; + agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + agregarPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + agregarPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + + Button btnEditar = new Button(); + btnEditar.Text = "Editar"; + btnEditar.Font = new Font(btnEditar.Font.FontFamily, 20); + btnEditar.ForeColor = Color.White; + btnEditar.FlatStyle = FlatStyle.Flat; + btnEditar.FlatAppearance.BorderSize = 0; + btnEditar.BackColor = Color.FromArgb(33, 90, 255); + btnEditar.Dock = DockStyle.Fill; + btnEditar.Click += new EventHandler(delegate (object sender, EventArgs e) + { + + }); + + + Button btnEliminar = new Button(); + btnEliminar.Text = "Eliminar"; + btnEliminar.Font = new Font(btnEliminar.Font.FontFamily, 20); + btnEliminar.ForeColor = Color.White; + btnEliminar.FlatStyle = FlatStyle.Flat; + btnEliminar.FlatAppearance.BorderSize = 0; + btnEliminar.BackColor = Color.Red; + btnEliminar.Dock = DockStyle.Fill; + btnEliminar.Click += new EventHandler(delegate (object sender, EventArgs e) + { + DialogResult result = MessageBox.Show($"¿Está seguro de que desea eliminar el producto {producto.nombre}?", + "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + if (service.eliminarProducto(producto)) + { + //eliminar imagen antigua + string destinationFolder = Path.Combine(Application.StartupPath, "Resources"); + string imagenEliminada = Path.Combine(destinationFolder, producto.img); + llenarLayout(); + //se pone a esperar 1 segundo antes de eliminar la imagen + //esto para que al programa le de tiempo de dejar de utilizar la imagen y no lance una excepcion + Timer timer = new Timer(); + timer.Interval = 1000; // 1 segundos + timer.Tick += delegate (object sender2, EventArgs e2) + { + try + { + File.Delete(imagenEliminada); + timer.Stop(); + } + catch (Exception ex) + { + // Manejar la excepción de eliminación de archivo temporal + Console.WriteLine("Error al eliminar archivo temporal: " + ex.Message); + } + }; + timer.Start(); + + } + } + }); + + + + informacionProducto.Controls.Add(imagen, 0, 0); + informacionProducto.Controls.Add(nombreStock, 1, 0); + + agregarPanel.Controls.Add(btnEditar, 0, 0); + agregarPanel.Controls.Add(btnEliminar, 1, 0); + + filaLayout.Controls.Add(informacionProducto, 0, 0); + filaLayout.Controls.Add(agregarPanel, 1, 0); + VariantePanel.Controls.Add(filaLayout); + } } private void Variantes_Load(object sender, EventArgs e) { } + + private void btnAgregar_Click(object sender, EventArgs e) + { + addvariante ventana = new addvariante(producto,this); + ventana.Owner = this; + ventana.Show(); + } } } diff --git a/admin/addvariante.Designer.cs b/admin/addvariante.Designer.cs index 7e813f5..84a7222 100644 --- a/admin/addvariante.Designer.cs +++ b/admin/addvariante.Designer.cs @@ -32,11 +32,11 @@ this.label2 = new System.Windows.Forms.Label(); this.txtNombre = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.txtCantidad = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.lbImg = new System.Windows.Forms.Label(); - this.textBox2 = new System.Windows.Forms.TextBox(); + this.txtPrecioCompra = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); @@ -47,10 +47,9 @@ // txtPrecio // this.txtPrecio.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtPrecio.Location = new System.Drawing.Point(250, 252); - this.txtPrecio.Margin = new System.Windows.Forms.Padding(4); + this.txtPrecio.Location = new System.Drawing.Point(188, 205); this.txtPrecio.Name = "txtPrecio"; - this.txtPrecio.Size = new System.Drawing.Size(399, 30); + this.txtPrecio.Size = new System.Drawing.Size(300, 26); this.txtPrecio.TabIndex = 37; // // label2 @@ -59,20 +58,18 @@ this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.ForeColor = System.Drawing.Color.Transparent; - this.label2.Location = new System.Drawing.Point(245, 209); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(184, 170); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(89, 29); + this.label2.Size = new System.Drawing.Size(69, 24); this.label2.TabIndex = 38; this.label2.Text = "Precio:"; // // txtNombre // this.txtNombre.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtNombre.Location = new System.Drawing.Point(250, 163); - this.txtNombre.Margin = new System.Windows.Forms.Padding(4); + this.txtNombre.Location = new System.Drawing.Point(188, 132); this.txtNombre.Name = "txtNombre"; - this.txtNombre.Size = new System.Drawing.Size(399, 30); + this.txtNombre.Size = new System.Drawing.Size(300, 26); this.txtNombre.TabIndex = 35; // // label1 @@ -81,21 +78,19 @@ this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.ForeColor = System.Drawing.Color.Transparent; - this.label1.Location = new System.Drawing.Point(245, 121); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(184, 98); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(107, 29); + this.label1.Size = new System.Drawing.Size(84, 24); this.label1.TabIndex = 36; this.label1.Text = "Nombre:"; // - // textBox1 + // txtCantidad // - this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(250, 337); - this.textBox1.Margin = new System.Windows.Forms.Padding(4); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(399, 30); - this.textBox1.TabIndex = 39; + this.txtCantidad.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtCantidad.Location = new System.Drawing.Point(188, 274); + this.txtCantidad.Name = "txtCantidad"; + this.txtCantidad.Size = new System.Drawing.Size(300, 26); + this.txtCantidad.TabIndex = 39; // // label3 // @@ -103,10 +98,9 @@ this.label3.BackColor = System.Drawing.Color.Transparent; this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.ForeColor = System.Drawing.Color.Transparent; - this.label3.Location = new System.Drawing.Point(245, 294); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(184, 239); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(115, 29); + this.label3.Size = new System.Drawing.Size(89, 24); this.label3.TabIndex = 40; this.label3.Text = "Cantidad:"; // @@ -114,12 +108,14 @@ // this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.button1.Location = new System.Drawing.Point(250, 393); + this.button1.Location = new System.Drawing.Point(188, 319); + this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(103, 46); + this.button1.Size = new System.Drawing.Size(77, 37); this.button1.TabIndex = 42; this.button1.Text = "Subir"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // lbImg // @@ -127,21 +123,19 @@ this.lbImg.BackColor = System.Drawing.Color.Transparent; this.lbImg.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbImg.ForeColor = System.Drawing.Color.Transparent; - this.lbImg.Location = new System.Drawing.Point(360, 399); - this.lbImg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbImg.Location = new System.Drawing.Point(270, 324); this.lbImg.Name = "lbImg"; - this.lbImg.Size = new System.Drawing.Size(99, 29); + this.lbImg.Size = new System.Drawing.Size(78, 24); this.lbImg.TabIndex = 41; this.lbImg.Text = "Imagen:"; // - // textBox2 + // txtPrecioCompra // - this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox2.Location = new System.Drawing.Point(250, 488); - this.textBox2.Margin = new System.Windows.Forms.Padding(4); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(399, 30); - this.textBox2.TabIndex = 43; + this.txtPrecioCompra.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtPrecioCompra.Location = new System.Drawing.Point(188, 396); + this.txtPrecioCompra.Name = "txtPrecioCompra"; + this.txtPrecioCompra.Size = new System.Drawing.Size(300, 26); + this.txtPrecioCompra.TabIndex = 43; // // label4 // @@ -149,10 +143,9 @@ this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.ForeColor = System.Drawing.Color.Transparent; - this.label4.Location = new System.Drawing.Point(245, 455); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(184, 370); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(181, 29); + this.label4.Size = new System.Drawing.Size(141, 24); this.label4.TabIndex = 44; this.label4.Text = "Precio Compra:"; // @@ -161,39 +154,43 @@ this.pictureBox2.BackColor = System.Drawing.Color.Transparent; this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox2.Image = global::compabetov2.Properties.Resources.check1; - this.pictureBox2.Location = new System.Drawing.Point(353, 540); + this.pictureBox2.Location = new System.Drawing.Point(265, 439); + this.pictureBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox2.Name = "pictureBox2"; - this.pictureBox2.Size = new System.Drawing.Size(100, 69); + this.pictureBox2.Size = new System.Drawing.Size(75, 56); this.pictureBox2.TabIndex = 46; this.pictureBox2.TabStop = false; + this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click); // // pictureBox1 // this.pictureBox1.BackColor = System.Drawing.Color.Transparent; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox1.Image = global::compabetov2.Properties.Resources.cancel1; - this.pictureBox1.Location = new System.Drawing.Point(459, 540); + this.pictureBox1.Location = new System.Drawing.Point(344, 439); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(100, 69); + this.pictureBox1.Size = new System.Drawing.Size(75, 56); this.pictureBox1.TabIndex = 45; this.pictureBox1.TabStop = false; + this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); // // addvariante // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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(897, 621); + this.ClientSize = new System.Drawing.Size(673, 505); this.ControlBox = false; this.Controls.Add(this.pictureBox2); this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.textBox2); + this.Controls.Add(this.txtPrecioCompra); this.Controls.Add(this.label4); this.Controls.Add(this.button1); this.Controls.Add(this.lbImg); - this.Controls.Add(this.textBox1); + this.Controls.Add(this.txtCantidad); this.Controls.Add(this.label3); this.Controls.Add(this.txtPrecio); this.Controls.Add(this.label2); @@ -201,6 +198,7 @@ this.Controls.Add(this.label1); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "addvariante"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); @@ -216,11 +214,11 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtNombre; private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox txtCantidad; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label lbImg; - private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox txtPrecioCompra; private System.Windows.Forms.Label label4; private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; diff --git a/admin/addvariante.cs b/admin/addvariante.cs index eb402ba..99dd563 100644 --- a/admin/addvariante.cs +++ b/admin/addvariante.cs @@ -1,8 +1,10 @@ -using System; +using compabetov2.database.modelos; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,9 +14,77 @@ namespace compabetov2.admin { public partial class addvariante : Form { - public addvariante() + private string imagePath = ""; + private Producto producto; + Variantes ventanaPadre; + public addvariante(Producto producto, Variantes ventanaPadre) { InitializeComponent(); + this.ventanaPadre = ventanaPadre; + this.producto = producto; + } + + private void pictureBox1_Click(object sender, EventArgs e) + { + Close(); + } + + private void pictureBox2_Click(object sender, EventArgs e) + { + if (isInt(txtCantidad.Text) && isDecimal(txtPrecio.Text) && isDecimal(txtPrecioCompra.Text)) { + Variante NuevaVariante = new Variante( + -1, + txtNombre.Text, + Decimal.Parse(txtPrecio.Text), + int.Parse(txtCantidad.Text), + imagePath, + producto.idProducto, + Decimal.Parse(txtPrecioCompra.Text) + ); + } + } + + private static bool isInt(string cadena) + { + try + { + int.Parse(cadena); + return true; + } + catch + { + MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + private static bool isDecimal(string cadena) + { + try + { + Decimal.Parse(cadena); + return true; + } + catch + { + MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return false; + } + } + + private void button1_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog1 = new OpenFileDialog(); + + openFileDialog1.Filter = "Archivos de imagen (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg;*.jpeg;*.png;*.bmp"; + openFileDialog1.Title = "Seleccionar imagen"; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + imagePath = openFileDialog1.FileName; + lbImg.Text = $"Imagen: {Path.GetFileName(imagePath)}"; + } } } } diff --git a/admin/crud.cs b/admin/crud.cs index e08316b..bef003a 100644 --- a/admin/crud.cs +++ b/admin/crud.cs @@ -110,7 +110,7 @@ namespace compabetov2.admin btnVariante.Dock = DockStyle.Fill; btnVariante.Click += new EventHandler(delegate (object sender, EventArgs e) { - Variantes variantes = new Variantes(this); + Variantes variantes = new Variantes(this, producto); variantes.Owner = this; variantes.Show(); }); diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index bfb5c6d..9c94853 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 31fe02e..c2b59ed 100644 Binary files a/bin/Debug/compabetov2.pdb and b/bin/Debug/compabetov2.pdb differ diff --git a/database/DAO.cs b/database/DAO.cs index 091f585..27c1a03 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -1782,6 +1782,31 @@ namespace compabetov2.database } } + public static SQLiteDataReader conseguirVarianteDAO(int idProducto) + { + SQLiteDataReader reader = null; + var db_conexion = new Conexion(); + try + { + SQLiteConnection conexion = db_conexion.get_connection(); + + conexion.Open(); + + string sql = "SELECT * FROM variantes WHERE fk_producto = @fk_producto"; + SQLiteCommand command = new SQLiteCommand(sql, conexion); + command.Parameters.AddWithValue("@fk_producto", idProducto); + reader = command.ExecuteReader(); + + return reader; + + } + catch (SQLiteException ex) + { + MessageBox.Show(ex.Message); + return reader; + } + } + public static SQLiteDataReader conseguirImportesDAO() { SQLiteDataReader reader = null; diff --git a/database/service.cs b/database/service.cs index abd14e9..87c2212 100644 --- a/database/service.cs +++ b/database/service.cs @@ -574,6 +574,35 @@ namespace compabetov2.database return variantes; } + public static List conseguirVariante(int idProducto) + { + List variantes = new List(); + SQLiteDataReader reader = DAO.conseguirVarianteDAO(idProducto); + + while (reader.Read()) + { + int idVariante = (int)reader.GetInt64(0); + string nombre = reader.GetString(1); + decimal precio = reader.GetDecimal(2); + int cantidad = (int)reader.GetInt64(3); + string img = reader.GetString(4); + int fkProducto = (int)reader.GetInt64(5); + decimal precioCompra = reader.GetDecimal(6); + + variantes.Add(new Variante( + idVariante, + nombre, + precio, + cantidad, + img, + fkProducto, + precioCompra + )); + } + + return variantes; + } + public static List conseguirImportes() { List importes = new List(); diff --git a/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 1362474..4382aa9 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/obj/Debug/compabetov2.csproj.AssemblyReference.cache b/obj/Debug/compabetov2.csproj.AssemblyReference.cache index 6ae8e14..7695aa1 100644 Binary files a/obj/Debug/compabetov2.csproj.AssemblyReference.cache and b/obj/Debug/compabetov2.csproj.AssemblyReference.cache differ diff --git a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache index 99ad058..fe7ee61 100644 --- a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache +++ b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -9d955a773c1723ba869474290d793277f0a353ff7f35db8c554c5d0fbfe417e0 +e213d9beb5da3320ef36bb44a93fdae1bbcb3db7d3ede06b34b1df208bbd692a diff --git a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt index 2319af8..5f2f5ba 100644 --- a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt +++ b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt @@ -159,3 +159,4 @@ C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.a C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.admin.addvariante.resources C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.admin.agregarproducto.resources C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.admin.Variantes.resources +C:\Users\carsu\Source\Repos\compabetoOG\obj\Debug\compabet.5C4A9C0C.Up2Date diff --git a/obj/Debug/compabetov2.csproj.GenerateResource.cache b/obj/Debug/compabetov2.csproj.GenerateResource.cache index 6adebdd..632f690 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 bfb5c6d..9c94853 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 31fe02e..c2b59ed 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ