diff --git a/admin/Variantes.cs b/admin/Variantes.cs index 596b08c..deee1dc 100644 --- a/admin/Variantes.cs +++ b/admin/Variantes.cs @@ -95,7 +95,9 @@ namespace compabetov2.admin btnEditar.Dock = DockStyle.Fill; btnEditar.Click += new EventHandler(delegate (object sender, EventArgs e) { - + editarvariante editarvariante = new editarvariante(variante, this); + editarvariante.Owner = this; + editarvariante.Show(); }); diff --git a/admin/addvariante.Designer.cs b/admin/addvariante.Designer.cs index 1638cb1..cf8268e 100644 --- a/admin/addvariante.Designer.cs +++ b/admin/addvariante.Designer.cs @@ -48,10 +48,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(251, 252); - this.txtPrecio.Margin = new System.Windows.Forms.Padding(4, 4, 4, 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 @@ -60,20 +59,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(251, 162); - this.txtNombre.Margin = new System.Windows.Forms.Padding(4, 4, 4, 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 @@ -82,20 +79,18 @@ 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:"; // // txtCantidad // 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(251, 337); - this.txtCantidad.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtCantidad.Location = new System.Drawing.Point(188, 274); this.txtCantidad.Name = "txtCantidad"; - this.txtCantidad.Size = new System.Drawing.Size(399, 30); + this.txtCantidad.Size = new System.Drawing.Size(300, 26); this.txtCantidad.TabIndex = 39; // // label3 @@ -104,21 +99,20 @@ 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(92, 24); this.label3.TabIndex = 40; - this.label3.Text = "Cantidad:"; + this.label3.Text = "Volumen:"; // // button1 // 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(251, 393); - this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + 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; @@ -130,20 +124,18 @@ 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:"; // // txtPrecioCompra // 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(251, 487); - this.txtPrecioCompra.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtPrecioCompra.Location = new System.Drawing.Point(188, 396); this.txtPrecioCompra.Name = "txtPrecioCompra"; - this.txtPrecioCompra.Size = new System.Drawing.Size(399, 30); + this.txtPrecioCompra.Size = new System.Drawing.Size(300, 26); this.txtPrecioCompra.TabIndex = 43; // // label4 @@ -152,10 +144,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:"; // @@ -164,10 +155,10 @@ 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + 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); @@ -177,10 +168,10 @@ 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + 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); @@ -191,21 +182,20 @@ this.label5.BackColor = System.Drawing.Color.Transparent; this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.ForeColor = System.Drawing.Color.Transparent; - this.label5.Location = new System.Drawing.Point(13, 9); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Location = new System.Drawing.Point(10, 7); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(193, 29); + this.label5.Size = new System.Drawing.Size(152, 24); this.label5.TabIndex = 47; this.label5.Text = "Agregar Variante"; // // 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, 622); + this.ClientSize = new System.Drawing.Size(673, 505); this.ControlBox = false; this.Controls.Add(this.label5); this.Controls.Add(this.pictureBox2); @@ -222,7 +212,7 @@ this.Controls.Add(this.label1); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + 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(); diff --git a/admin/addvariante.cs b/admin/addvariante.cs index f6e1154..0945530 100644 --- a/admin/addvariante.cs +++ b/admin/addvariante.cs @@ -45,6 +45,9 @@ namespace compabetov2.admin if (service.insertarVariante(NuevaVariante)) { + string destinationFolder = Path.Combine(Application.StartupPath, "Resources"); + string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagePath)); + File.Copy(imagePath, destinationFile, true); Close(); ventanaPadre.llenarLayout(); } diff --git a/admin/agregarproducto.Designer.cs b/admin/agregarproducto.Designer.cs index e395189..248911c 100644 --- a/admin/agregarproducto.Designer.cs +++ b/admin/agregarproducto.Designer.cs @@ -32,8 +32,6 @@ this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.lbImg = new System.Windows.Forms.Label(); - this.txtPrecio = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); this.txtNombre = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); @@ -45,9 +43,10 @@ // this.btnSubir.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnSubir.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.btnSubir.Location = new System.Drawing.Point(243, 312); + this.btnSubir.Location = new System.Drawing.Point(182, 254); + this.btnSubir.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnSubir.Name = "btnSubir"; - this.btnSubir.Size = new System.Drawing.Size(103, 46); + this.btnSubir.Size = new System.Drawing.Size(77, 37); this.btnSubir.TabIndex = 38; this.btnSubir.Text = "Subir"; this.btnSubir.UseVisualStyleBackColor = true; @@ -58,9 +57,10 @@ 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(348, 424); + this.pictureBox2.Location = new System.Drawing.Point(261, 344); + 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 = 37; this.pictureBox2.TabStop = false; this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click); @@ -70,9 +70,10 @@ 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(454, 424); + this.pictureBox1.Location = new System.Drawing.Point(340, 344); + 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 = 36; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); @@ -83,42 +84,18 @@ 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(353, 318); - this.lbImg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbImg.Location = new System.Drawing.Point(265, 258); 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 = 35; this.lbImg.Text = "Imagen:"; // - // 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(243, 258); - this.txtPrecio.Margin = new System.Windows.Forms.Padding(4); - this.txtPrecio.Name = "txtPrecio"; - this.txtPrecio.Size = new System.Drawing.Size(399, 30); - this.txtPrecio.TabIndex = 33; - // - // label2 - // - this.label2.AutoSize = true; - 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(238, 215); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(89, 29); - this.label2.TabIndex = 34; - 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(243, 169); - this.txtNombre.Margin = new System.Windows.Forms.Padding(4); + this.txtNombre.Location = new System.Drawing.Point(182, 192); 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 = 31; // // label1 @@ -127,10 +104,9 @@ 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(238, 127); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(178, 158); 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 = 32; this.label1.Text = "Nombre:"; // @@ -140,34 +116,32 @@ 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(13, 9); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(10, 7); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(202, 29); + this.label3.Size = new System.Drawing.Size(159, 24); this.label3.TabIndex = 39; this.label3.Text = "Agregar Producto"; // // agregarproducto // - 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, 575); + this.ClientSize = new System.Drawing.Size(673, 467); this.ControlBox = false; this.Controls.Add(this.label3); this.Controls.Add(this.btnSubir); this.Controls.Add(this.pictureBox2); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.lbImg); - this.Controls.Add(this.txtPrecio); - this.Controls.Add(this.label2); this.Controls.Add(this.txtNombre); this.Controls.Add(this.label1); this.DoubleBuffered = true; this.ForeColor = System.Drawing.SystemColors.ControlLightLight; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "agregarproducto"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); @@ -183,8 +157,6 @@ private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Label lbImg; - private System.Windows.Forms.TextBox txtPrecio; - private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtNombre; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label3; diff --git a/admin/agregarproducto.cs b/admin/agregarproducto.cs index 1e32297..d68a848 100644 --- a/admin/agregarproducto.cs +++ b/admin/agregarproducto.cs @@ -28,7 +28,7 @@ namespace compabetov2.admin try { string nombre = txtNombre.Text; - decimal precio = decimal.Parse(txtPrecio.Text); + decimal precio = 0; //valida que se haya colocado alguna imagen if (!imagePath.Equals("")) { Producto producto = new Producto(-1, nombre, "", precio, imagePath, 0); diff --git a/admin/crud.cs b/admin/crud.cs index bef003a..c162974 100644 --- a/admin/crud.cs +++ b/admin/crud.cs @@ -29,7 +29,7 @@ namespace compabetov2.admin AdminPanel.Controls.Clear(); productos.Clear(); productos = service.conseguirProductos(); - + foreach (Producto producto in productos) { @@ -41,7 +41,7 @@ namespace compabetov2.admin 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; @@ -133,27 +133,10 @@ namespace compabetov2.admin { //eliminar imagen antigua string destinationFolder = Path.Combine(Application.StartupPath, "Resources"); - string imagenEliminada = Path.Combine(destinationFolder, producto.img); + string imagenEliminar = 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(); - } } }); @@ -172,7 +155,7 @@ namespace compabetov2.admin AdminPanel.Controls.Add(filaLayout); } } - + private void crud_Load(object sender, EventArgs e) { @@ -211,5 +194,9 @@ namespace compabetov2.admin agregarproducto.Owner = this; agregarproducto.Show(); } + + } + + } diff --git a/admin/editar.Designer.cs b/admin/editar.Designer.cs index c4bb429..e58c530 100644 --- a/admin/editar.Designer.cs +++ b/admin/editar.Designer.cs @@ -30,8 +30,6 @@ { this.txtNombre = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); - this.txtPrecio = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); this.lbImg = new System.Windows.Forms.Label(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); @@ -43,10 +41,9 @@ // 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(240, 210); - this.txtNombre.Margin = new System.Windows.Forms.Padding(4); + this.txtNombre.Location = new System.Drawing.Point(180, 212); 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 = 5; // // label1 @@ -55,45 +52,21 @@ 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(235, 168); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(176, 177); 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 = 6; this.label1.Text = "Nombre:"; // - // 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(240, 299); - this.txtPrecio.Margin = new System.Windows.Forms.Padding(4); - this.txtPrecio.Name = "txtPrecio"; - this.txtPrecio.Size = new System.Drawing.Size(399, 30); - this.txtPrecio.TabIndex = 7; - // - // label2 - // - this.label2.AutoSize = true; - 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(235, 256); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(89, 29); - this.label2.TabIndex = 8; - this.label2.Text = "Precio:"; - // // lbImg // this.lbImg.AutoSize = true; 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(350, 359); - this.lbImg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbImg.Location = new System.Drawing.Point(262, 292); 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 = 10; this.lbImg.Text = "Imagen:"; // @@ -102,9 +75,10 @@ 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(345, 465); + this.pictureBox2.Location = new System.Drawing.Point(259, 378); + 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 = 29; this.pictureBox2.TabStop = false; this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click); @@ -114,9 +88,10 @@ 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(451, 465); + this.pictureBox1.Location = new System.Drawing.Point(338, 378); + 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 = 28; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); @@ -124,9 +99,10 @@ // button1 // this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(240, 353); + this.button1.Location = new System.Drawing.Point(180, 287); + 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 = 30; this.button1.Text = "Subir"; this.button1.UseVisualStyleBackColor = true; @@ -134,23 +110,22 @@ // // editar // - 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, 575); + this.ClientSize = new System.Drawing.Size(673, 467); this.ControlBox = false; this.Controls.Add(this.button1); this.Controls.Add(this.pictureBox2); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.lbImg); - this.Controls.Add(this.txtPrecio); - this.Controls.Add(this.label2); this.Controls.Add(this.txtNombre); 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 = "editar"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Load += new System.EventHandler(this.editar_Load); @@ -165,8 +140,6 @@ private System.Windows.Forms.TextBox txtNombre; private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtPrecio; - private System.Windows.Forms.Label label2; private System.Windows.Forms.Label lbImg; private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; diff --git a/admin/editar.cs b/admin/editar.cs index 77728b6..b548368 100644 --- a/admin/editar.cs +++ b/admin/editar.cs @@ -47,7 +47,6 @@ namespace compabetov2.admin private void cargarInto() { txtNombre.Text = producto.nombre; - txtPrecio.Text = producto.precion.ToString(); lbImg.Text = $"Imagen: {Path.GetFileName(imagePath)}"; ; } @@ -58,8 +57,8 @@ namespace compabetov2.admin private void pictureBox2_Click(object sender, EventArgs e) { - try { - decimal precio = decimal.Parse(txtPrecio.Text); + try { + decimal precio = 0; string nombre = txtNombre.Text; //en caso de que descida cambiar la imagen if (!imagePath.Equals("")) diff --git a/admin/editarvariante.Designer.cs b/admin/editarvariante.Designer.cs index 83140fb..7b98dd3 100644 --- a/admin/editarvariante.Designer.cs +++ b/admin/editarvariante.Designer.cs @@ -36,11 +36,11 @@ this.lbImg = new System.Windows.Forms.Label(); this.txtCantidad = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); - this.txtPrecio = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); this.txtNombre = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtPrecio = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -50,32 +50,33 @@ 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(357, 541); - this.pictureBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.pictureBox2.Location = new System.Drawing.Point(268, 440); + this.pictureBox2.Margin = new System.Windows.Forms.Padding(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 = 58; 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(463, 541); - this.pictureBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.pictureBox1.Location = new System.Drawing.Point(347, 440); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(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 = 57; this.pictureBox1.TabStop = false; + this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); // // txtPrecioCompra // 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(255, 488); - this.txtPrecioCompra.Margin = new System.Windows.Forms.Padding(4); + this.txtPrecioCompra.Location = new System.Drawing.Point(191, 396); this.txtPrecioCompra.Name = "txtPrecioCompra"; - this.txtPrecioCompra.Size = new System.Drawing.Size(399, 30); + this.txtPrecioCompra.Size = new System.Drawing.Size(300, 26); this.txtPrecioCompra.TabIndex = 55; // // label4 @@ -84,10 +85,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(249, 456); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(187, 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 = 56; this.label4.Text = "Precio Compra:"; // @@ -95,13 +95,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(255, 394); - this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button1.Location = new System.Drawing.Point(191, 320); + this.button1.Margin = new System.Windows.Forms.Padding(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 = 54; this.button1.Text = "Subir"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // lbImg // @@ -109,20 +110,18 @@ 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(364, 400); - this.lbImg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbImg.Location = new System.Drawing.Point(273, 325); 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 = 53; this.lbImg.Text = "Imagen:"; // // txtCantidad // 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(255, 338); - this.txtCantidad.Margin = new System.Windows.Forms.Padding(4); + this.txtCantidad.Location = new System.Drawing.Point(191, 275); this.txtCantidad.Name = "txtCantidad"; - this.txtCantidad.Size = new System.Drawing.Size(399, 30); + this.txtCantidad.Size = new System.Drawing.Size(300, 26); this.txtCantidad.TabIndex = 51; // // label3 @@ -131,42 +130,19 @@ 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(249, 295); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(187, 240); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(115, 29); + this.label3.Size = new System.Drawing.Size(92, 24); this.label3.TabIndex = 52; - this.label3.Text = "Cantidad:"; - // - // 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(255, 253); - this.txtPrecio.Margin = new System.Windows.Forms.Padding(4); - this.txtPrecio.Name = "txtPrecio"; - this.txtPrecio.Size = new System.Drawing.Size(399, 30); - this.txtPrecio.TabIndex = 49; - // - // label2 - // - this.label2.AutoSize = true; - 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(249, 210); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(89, 29); - this.label2.TabIndex = 50; - this.label2.Text = "Precio:"; + this.label3.Text = "Volumen:"; + this.label3.Click += new System.EventHandler(this.label3_Click); // // 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(255, 163); - this.txtNombre.Margin = new System.Windows.Forms.Padding(4); + this.txtNombre.Location = new System.Drawing.Point(191, 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 = 47; // // label1 @@ -175,10 +151,9 @@ 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(249, 122); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(187, 99); 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 = 48; this.label1.Text = "Nombre:"; // @@ -188,21 +163,40 @@ this.label5.BackColor = System.Drawing.Color.Transparent; this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.ForeColor = System.Drawing.Color.Transparent; - this.label5.Location = new System.Drawing.Point(13, 9); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Location = new System.Drawing.Point(10, 7); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(170, 29); + this.label5.Size = new System.Drawing.Size(132, 24); this.label5.TabIndex = 59; this.label5.Text = "Editar Variante"; // + // label2 + // + this.label2.AutoSize = true; + 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(187, 171); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(69, 24); + this.label2.TabIndex = 50; + this.label2.Text = "Precio:"; + // + // 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(191, 206); + this.txtPrecio.Name = "txtPrecio"; + this.txtPrecio.Size = new System.Drawing.Size(300, 26); + this.txtPrecio.TabIndex = 49; + // // editarvariante // - 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, 622); + this.ClientSize = new System.Drawing.Size(673, 505); this.ControlBox = false; this.Controls.Add(this.label5); this.Controls.Add(this.pictureBox2); @@ -219,6 +213,7 @@ this.Controls.Add(this.label1); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "editarvariante"; this.Load += new System.EventHandler(this.editarvariante_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); @@ -238,10 +233,10 @@ private System.Windows.Forms.Label lbImg; private System.Windows.Forms.TextBox txtCantidad; private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox txtPrecio; - private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtNombre; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtPrecio; } } \ No newline at end of file diff --git a/admin/editarvariante.cs b/admin/editarvariante.cs index 970b6e1..7137bba 100644 --- a/admin/editarvariante.cs +++ b/admin/editarvariante.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; @@ -12,14 +15,114 @@ namespace compabetov2.admin { public partial class editarvariante : Form { - public editarvariante() + private Variante variante; + private Variantes ventanaPadre; + private string imagePath; + public editarvariante(Variante variante, Variantes ventanaPadre) { InitializeComponent(); + this.variante = variante; + this.ventanaPadre = ventanaPadre; + llenarCampos(); + } + + private void llenarCampos() + { + txtNombre.Text = variante.nombre; + txtCantidad.Text = variante.cantidad.ToString(); + txtPrecio.Text = variante.precio.ToString(); + txtPrecioCompra.Text = variante.precioCompra.ToString(); + lbImg.Text = "Imagen: " + variante.img.ToString(); + imagePath = variante.img; } private void editarvariante_Load(object sender, EventArgs e) { } + + 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)}"; + } + } + + private void pictureBox1_Click(object sender, EventArgs e) + { + Close(); + } + + 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 pictureBox2_Click(object sender, EventArgs e) + { + if (isInt(txtCantidad.Text) && isDecimal(txtPrecio.Text) && isDecimal(txtPrecioCompra.Text)) + { + Variante NuevaVariante = new Variante( + variante.idVariante, + txtNombre.Text, + Decimal.Parse(txtPrecio.Text), + int.Parse(txtCantidad.Text), + imagePath, + variante.fkProducto, + Decimal.Parse(txtPrecioCompra.Text) + ); + + if (service.editarVariante(NuevaVariante)) + { + if (!NuevaVariante.img.Equals(variante.img)) + { + string destinationFolder = Path.Combine(Application.StartupPath, "Resources"); + string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagePath)); + File.Copy(imagePath, destinationFile, true); + } + Close(); + ventanaPadre.llenarLayout(); + //borrar imagen + // + + } + } + } + + private void label3_Click(object sender, EventArgs e) + { + + } } } diff --git a/bin/Debug/Resources/retrato.jpeg b/bin/Debug/Resources/retrato.jpeg new file mode 100644 index 0000000..8952ec7 Binary files /dev/null and b/bin/Debug/Resources/retrato.jpeg differ diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index aa150c0..a386c42 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 50ddfd5..411459f 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 13f9ed8..f91eca4 100644 Binary files a/bin/Debug/data.db and b/bin/Debug/data.db differ diff --git a/bin/Debug/produtos_img/retrato.jpeg b/bin/Debug/produtos_img/retrato.jpeg new file mode 100644 index 0000000..8952ec7 Binary files /dev/null and b/bin/Debug/produtos_img/retrato.jpeg differ diff --git a/database/DAO.cs b/database/DAO.cs index 09ce953..faa6e3e 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -1862,6 +1862,37 @@ namespace compabetov2.database } } + public static bool editarVarianteDAO(Variante variante) + { + var db_conexion = new Conexion(); + try + { + SQLiteConnection conexion = db_conexion.get_connection(); + conexion.Open(); + + string sql = "UPDATE variantes SET nombre = @nombre, precio = @precio, cantidad = @cantidad, img = @img, " + + "fk_producto = @fk_producto, precioCompra = @precioCompra WHERE idVariante = @idVariante; "; + + + SQLiteCommand command = new SQLiteCommand(sql, conexion); + command.Parameters.AddWithValue("@nombre", variante.nombre); + command.Parameters.AddWithValue("@precio", variante.precio); + command.Parameters.AddWithValue("@cantidad", variante.cantidad); + command.Parameters.AddWithValue("@img", variante.img); + command.Parameters.AddWithValue("@fk_producto", variante.fkProducto); + command.Parameters.AddWithValue("@precioCompra", variante.precioCompra); + command.Parameters.AddWithValue("@idVariante", variante.idVariante); + command.ExecuteNonQuery(); + + return true; + } + catch (SQLiteException ex) + { + MessageBox.Show(ex.Message); + return false; + } + } + public static SQLiteDataReader conseguirImportesDAO() { SQLiteDataReader reader = null; diff --git a/database/service.cs b/database/service.cs index 2b38dd0..b1eb888 100644 --- a/database/service.cs +++ b/database/service.cs @@ -613,6 +613,11 @@ namespace compabetov2.database return DAO.eliminarVarianteDAO(idVariante); } + public static bool editarVariante(Variante variante) + { + return DAO.editarVarianteDAO(variante); + } + public static List conseguirImportes() { List importes = new List(); diff --git a/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 1c35a3c..363616f 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 176b530..b5abab5 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 214cb75..6814a2c 100644 --- a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache +++ b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -a9bc43144c688823697090e74a55f122470d105d2557473669418d9f299656f6 +71f328ca57677b5d4698632bb6522f64a4fe76d47ddec8e1718dc439db6af453 diff --git a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt index b326809..4474bb6 100644 --- a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt +++ b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt @@ -164,3 +164,4 @@ C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.a C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.agregarproducto.resources 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 diff --git a/obj/Debug/compabetov2.csproj.GenerateResource.cache b/obj/Debug/compabetov2.csproj.GenerateResource.cache index 2421cd8..491d4e3 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 aa150c0..a386c42 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 50ddfd5..411459f 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ