FEAT EDITAR VARIANTE

This commit is contained in:
Michael Robles
2024-06-23 20:40:07 -07:00
31 changed files with 1011 additions and 75 deletions
+6
View File
@@ -1,10 +1,16 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
<<<<<<< HEAD
"", "",
"\\admin", "\\admin",
"\\Empleados", "\\Empleados",
"\\Ventas" "\\Ventas"
], ],
"SelectedNode": "\\admin\\editar.cs", "SelectedNode": "\\admin\\editar.cs",
=======
""
],
"SelectedNode": "\\Solution.sln",
>>>>>>> 68bcb453d1be6aa4af940b43aa4a1848e71b2c46
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }
File diff suppressed because one or more lines are too long
+76
View File
@@ -0,0 +1,76 @@
namespace compabetov2.admin
{
partial class Variantes
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.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;
this.VariantePanel.Paint += new System.Windows.Forms.PaintEventHandler(this.VariantePanel_Paint);
//
// 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(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
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);
this.Name = "Variantes";
this.Text = "Variantes";
this.Load += new System.EventHandler(this.Variantes_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel VariantePanel;
private System.Windows.Forms.Button btnAgregar;
}
}
+154
View File
@@ -0,0 +1,154 @@
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;
using System.Windows.Forms;
namespace compabetov2.admin
{
public partial class Variantes : Form
{
private crud ventanaPadre;
private Producto producto;
private List<Variante> variantes = new List<Variante>();
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.eliminarVariante(variante.idVariante))
{
llenarLayout();
}
}
});
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();
}
private void VariantePanel_Paint(object sender, PaintEventArgs e)
{
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+47 -49
View File
@@ -32,11 +32,11 @@
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.txtNombre = new System.Windows.Forms.TextBox(); this.txtNombre = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label(); 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.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.lbImg = new System.Windows.Forms.Label(); 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.label4 = new System.Windows.Forms.Label();
this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
@@ -47,10 +47,9 @@
// txtPrecio // txtPrecio
// //
this.txtPrecio.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Location = new System.Drawing.Point(188, 205);
this.txtPrecio.Margin = new System.Windows.Forms.Padding(4);
this.txtPrecio.Name = "txtPrecio"; 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; this.txtPrecio.TabIndex = 37;
// //
// label2 // label2
@@ -59,20 +58,18 @@
this.label2.BackColor = System.Drawing.Color.Transparent; 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.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.ForeColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(245, 209); this.label2.Location = new System.Drawing.Point(184, 170);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2"; 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.TabIndex = 38;
this.label2.Text = "Precio:"; this.label2.Text = "Precio:";
// //
// txtNombre // txtNombre
// //
this.txtNombre.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Location = new System.Drawing.Point(188, 132);
this.txtNombre.Margin = new System.Windows.Forms.Padding(4);
this.txtNombre.Name = "txtNombre"; 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; this.txtNombre.TabIndex = 35;
// //
// label1 // label1
@@ -81,21 +78,19 @@
this.label1.BackColor = System.Drawing.Color.Transparent; 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.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.ForeColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(245, 121); this.label1.Location = new System.Drawing.Point(184, 98);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1"; 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.TabIndex = 36;
this.label1.Text = "Nombre:"; 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.txtCantidad.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.txtCantidad.Location = new System.Drawing.Point(188, 274);
this.textBox1.Margin = new System.Windows.Forms.Padding(4); this.txtCantidad.Name = "txtCantidad";
this.textBox1.Name = "textBox1"; this.txtCantidad.Size = new System.Drawing.Size(300, 26);
this.textBox1.Size = new System.Drawing.Size(399, 30); this.txtCantidad.TabIndex = 39;
this.textBox1.TabIndex = 39;
// //
// label3 // label3
// //
@@ -103,10 +98,9 @@
this.label3.BackColor = System.Drawing.Color.Transparent; 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.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.ForeColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(245, 294); this.label3.Location = new System.Drawing.Point(184, 239);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3"; 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.TabIndex = 40;
this.label3.Text = "Cantidad:"; 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.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.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.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.TabIndex = 42;
this.button1.Text = "Subir"; this.button1.Text = "Subir";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
// //
// lbImg // lbImg
// //
@@ -127,21 +123,19 @@
this.lbImg.BackColor = System.Drawing.Color.Transparent; 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.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.ForeColor = System.Drawing.Color.Transparent;
this.lbImg.Location = new System.Drawing.Point(360, 399); this.lbImg.Location = new System.Drawing.Point(270, 324);
this.lbImg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbImg.Name = "lbImg"; 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.TabIndex = 41;
this.lbImg.Text = "Imagen:"; 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.txtPrecioCompra.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.txtPrecioCompra.Location = new System.Drawing.Point(188, 396);
this.textBox2.Margin = new System.Windows.Forms.Padding(4); this.txtPrecioCompra.Name = "txtPrecioCompra";
this.textBox2.Name = "textBox2"; this.txtPrecioCompra.Size = new System.Drawing.Size(300, 26);
this.textBox2.Size = new System.Drawing.Size(399, 30); this.txtPrecioCompra.TabIndex = 43;
this.textBox2.TabIndex = 43;
// //
// label4 // label4
// //
@@ -149,10 +143,9 @@
this.label4.BackColor = System.Drawing.Color.Transparent; 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.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.ForeColor = System.Drawing.Color.Transparent;
this.label4.Location = new System.Drawing.Point(245, 455); this.label4.Location = new System.Drawing.Point(184, 370);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4"; 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.TabIndex = 44;
this.label4.Text = "Precio Compra:"; this.label4.Text = "Precio Compra:";
// //
@@ -161,39 +154,43 @@
this.pictureBox2.BackColor = System.Drawing.Color.Transparent; this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pictureBox2.Image = global::compabetov2.Properties.Resources.check1; 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.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.TabIndex = 46;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
// //
// pictureBox1 // pictureBox1
// //
this.pictureBox1.BackColor = System.Drawing.Color.Transparent; this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pictureBox1.Image = global::compabetov2.Properties.Resources.cancel1; 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.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.TabIndex = 45;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
// //
// addvariante // 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.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255))))); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255)))));
this.BackgroundImage = global::compabetov2.Properties.Resources.Form; this.BackgroundImage = global::compabetov2.Properties.Resources.Form;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 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.ControlBox = false;
this.Controls.Add(this.pictureBox2); this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.textBox2); this.Controls.Add(this.txtPrecioCompra);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.lbImg); this.Controls.Add(this.lbImg);
this.Controls.Add(this.textBox1); this.Controls.Add(this.txtCantidad);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.txtPrecio); this.Controls.Add(this.txtPrecio);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
@@ -201,6 +198,7 @@
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "addvariante"; this.Name = "addvariante";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
@@ -216,11 +214,11 @@
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtNombre; private System.Windows.Forms.TextBox txtNombre;
private System.Windows.Forms.Label label1; 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.Label label3;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label lbImg; 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.Label label4;
private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
+79 -2
View File
@@ -1,8 +1,11 @@
using System; using compabetov2.database;
using compabetov2.database.modelos;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -12,9 +15,83 @@ namespace compabetov2.admin
{ {
public partial class addvariante : Form public partial class addvariante : Form
{ {
public addvariante() private string imagePath = "";
private Producto producto;
Variantes ventanaPadre;
public addvariante(Producto producto, Variantes ventanaPadre)
{ {
InitializeComponent(); 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)
);
if (service.insertarVariante(NuevaVariante))
{
Close();
ventanaPadre.llenarLayout();
}
}
}
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)}";
}
} }
} }
} }
+15 -12
View File
@@ -28,7 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.button1 = new System.Windows.Forms.Button(); this.btnSubir = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lbImg = new System.Windows.Forms.Label(); this.lbImg = new System.Windows.Forms.Label();
@@ -40,16 +40,17 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // btnSubir
// //
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnSubir.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.btnSubir.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button1.Location = new System.Drawing.Point(243, 312); this.btnSubir.Location = new System.Drawing.Point(243, 312);
this.button1.Name = "button1"; this.btnSubir.Name = "btnSubir";
this.button1.Size = new System.Drawing.Size(103, 46); this.btnSubir.Size = new System.Drawing.Size(103, 46);
this.button1.TabIndex = 38; this.btnSubir.TabIndex = 38;
this.button1.Text = "Subir"; this.btnSubir.Text = "Subir";
this.button1.UseVisualStyleBackColor = true; this.btnSubir.UseVisualStyleBackColor = true;
this.btnSubir.Click += new System.EventHandler(this.button1_Click);
// //
// pictureBox2 // pictureBox2
// //
@@ -61,6 +62,7 @@
this.pictureBox2.Size = new System.Drawing.Size(100, 69); this.pictureBox2.Size = new System.Drawing.Size(100, 69);
this.pictureBox2.TabIndex = 37; this.pictureBox2.TabIndex = 37;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
// //
// pictureBox1 // pictureBox1
// //
@@ -72,6 +74,7 @@
this.pictureBox1.Size = new System.Drawing.Size(100, 69); this.pictureBox1.Size = new System.Drawing.Size(100, 69);
this.pictureBox1.TabIndex = 36; this.pictureBox1.TabIndex = 36;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
// //
// lbImg // lbImg
// //
@@ -139,7 +142,7 @@
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(897, 575); this.ClientSize = new System.Drawing.Size(897, 575);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.button1); this.Controls.Add(this.btnSubir);
this.Controls.Add(this.pictureBox2); this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.lbImg); this.Controls.Add(this.lbImg);
@@ -161,7 +164,7 @@
#endregion #endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button btnSubir;
private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label lbImg; private System.Windows.Forms.Label lbImg;
+57 -2
View File
@@ -1,8 +1,11 @@
using System; using compabetov2.database;
using compabetov2.database.modelos;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -12,9 +15,61 @@ namespace compabetov2.admin
{ {
public partial class agregarproducto : Form public partial class agregarproducto : Form
{ {
public agregarproducto() private crud ventanaPadre;
private string imagePath = "";
public agregarproducto(crud ventanaPadre)
{ {
this.ventanaPadre = ventanaPadre;
InitializeComponent(); InitializeComponent();
} }
private void pictureBox2_Click(object sender, EventArgs e)
{
try
{
string nombre = txtNombre.Text;
decimal precio = decimal.Parse(txtPrecio.Text);
//valida que se haya colocado alguna imagen
if (!imagePath.Equals("")) {
Producto producto = new Producto(-1, nombre, "", precio, imagePath, 0);
if (service.insertarProducto(producto))
{
string destinationFolder = Path.Combine(Application.StartupPath, "Resources");
string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagePath));
File.Copy(imagePath, destinationFile, true);
Close();
ventanaPadre.llenarLayout();
}
}
else
{
MessageBox.Show("Por favor seleccione alguna imagen", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch {
MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
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();
}
} }
} }
+1
View File
@@ -169,6 +169,7 @@
this.btnAgregar.TabIndex = 15; this.btnAgregar.TabIndex = 15;
this.btnAgregar.Text = "Agregar"; this.btnAgregar.Text = "Agregar";
this.btnAgregar.UseVisualStyleBackColor = true; this.btnAgregar.UseVisualStyleBackColor = true;
this.btnAgregar.Click += new System.EventHandler(this.btnAgregar_Click);
// //
// crud // crud
// //
+46 -4
View File
@@ -24,9 +24,12 @@ namespace compabetov2.admin
llenarLayout(); llenarLayout();
} }
private void llenarLayout() public void llenarLayout()
{ {
AdminPanel.Controls.Clear();
productos.Clear();
productos = service.conseguirProductos(); productos = service.conseguirProductos();
foreach (Producto producto in productos) foreach (Producto producto in productos)
{ {
@@ -107,6 +110,9 @@ namespace compabetov2.admin
btnVariante.Dock = DockStyle.Fill; btnVariante.Dock = DockStyle.Fill;
btnVariante.Click += new EventHandler(delegate (object sender, EventArgs e) btnVariante.Click += new EventHandler(delegate (object sender, EventArgs e)
{ {
Variantes variantes = new Variantes(this, producto);
variantes.Owner = this;
variantes.Show();
}); });
Button btnEliminar = new Button(); Button btnEliminar = new Button();
@@ -119,7 +125,37 @@ namespace compabetov2.admin
btnEliminar.Dock = DockStyle.Fill; btnEliminar.Dock = DockStyle.Fill;
btnEliminar.Click += new EventHandler(delegate (object sender, EventArgs e) 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();
}
}
}); });
@@ -131,13 +167,12 @@ namespace compabetov2.admin
agregarPanel.Controls.Add(btnVariante, 1, 0); agregarPanel.Controls.Add(btnVariante, 1, 0);
agregarPanel.Controls.Add(btnEliminar, 2, 0); agregarPanel.Controls.Add(btnEliminar, 2, 0);
filaLayout.Controls.Add(informacionProducto, 0, 0); filaLayout.Controls.Add(informacionProducto, 0, 0);
filaLayout.Controls.Add(agregarPanel, 1, 0); filaLayout.Controls.Add(agregarPanel, 1, 0);
AdminPanel.Controls.Add(filaLayout); AdminPanel.Controls.Add(filaLayout);
} }
} }
private void crud_Load(object sender, EventArgs e) private void crud_Load(object sender, EventArgs e)
{ {
@@ -169,5 +204,12 @@ namespace compabetov2.admin
menuprincipalForm.BringToFront(); menuprincipalForm.BringToFront();
} }
} }
private void btnAgregar_Click(object sender, EventArgs e)
{
agregarproducto agregarproducto = new agregarproducto(this);
agregarproducto.Owner = this;
agregarproducto.Show();
}
} }
} }
+53 -2
View File
@@ -1,4 +1,5 @@
using compabetov2.database.modelos; using compabetov2.database;
using compabetov2.database.modelos;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -59,7 +60,57 @@ namespace compabetov2.admin
{ {
try { try {
decimal precio = decimal.Parse(txtPrecio.Text); decimal precio = decimal.Parse(txtPrecio.Text);
}catch(Exception ex) string nombre = txtNombre.Text;
//en caso de que descida cambiar la imagen
if (!imagePath.Equals(""))
{
Producto productoNuevo = new Producto(producto.idProducto, nombre, "", precio, imagePath, 0);
if (service.editarProducto(productoNuevo))
{
//guardar imagen nueva
string destinationFolder = Path.Combine(Application.StartupPath, "Resources");
string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagePath));
File.Copy(imagePath, destinationFile, true);
ventanaPadre.llenarLayout();
//eliminar imagen antigua
string imagenEliminada = Path.Combine(destinationFolder, producto.img);
//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);
}
};
Close();
}
}
else
{
// si la imagen no es modificada
Producto productoNuevo = new Producto(producto.idProducto, nombre, "", precio, producto.img, 0);
if (service.editarProducto(productoNuevo))
{
ventanaPadre.llenarLayout();
Close();
}
}
}
catch(Exception ex)
{ {
MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
+39
View File
@@ -0,0 +1,39 @@
namespace compabetov2.admin
{
partial class editarvariante
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "editarvariante";
}
#endregion
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace compabetov2.admin
{
public partial class editarvariante : Form
{
public editarvariante()
{
InitializeComponent();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

+9
View File
@@ -130,6 +130,12 @@
<Compile Include="admin\editar.Designer.cs"> <Compile Include="admin\editar.Designer.cs">
<DependentUpon>editar.cs</DependentUpon> <DependentUpon>editar.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="admin\Variantes.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="admin\Variantes.Designer.cs">
<DependentUpon>Variantes.cs</DependentUpon>
</Compile>
<Compile Include="database\modelos\DetalleEnvioModel.cs" /> <Compile Include="database\modelos\DetalleEnvioModel.cs" />
<Compile Include="database\modelos\DetalleImporte.cs" /> <Compile Include="database\modelos\DetalleImporte.cs" />
<Compile Include="database\modelos\DetalleImporteCuenta.cs" /> <Compile Include="database\modelos\DetalleImporteCuenta.cs" />
@@ -310,6 +316,9 @@
<EmbeddedResource Include="admin\editar.resx"> <EmbeddedResource Include="admin\editar.resx">
<DependentUpon>editar.cs</DependentUpon> <DependentUpon>editar.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="admin\Variantes.resx">
<DependentUpon>Variantes.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Empleados\AgregarEmpleado1.resx"> <EmbeddedResource Include="Empleados\AgregarEmpleado1.resx">
<DependentUpon>AgregarEmpleado1.cs</DependentUpon> <DependentUpon>AgregarEmpleado1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
+113 -1
View File
@@ -10,6 +10,7 @@ using System.Security.Policy;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using compabetov2.admin;
using compabetov2.database; using compabetov2.database;
using compabetov2.database.modelos; using compabetov2.database.modelos;
@@ -478,7 +479,39 @@ namespace compabetov2.database
command.Parameters.AddWithValue("@precio", producto.precion); command.Parameters.AddWithValue("@precio", producto.precion);
command.Parameters.AddWithValue("@img", producto.img); command.Parameters.AddWithValue("@img", producto.img);
command.Parameters.AddWithValue("@stock", producto.stock); command.Parameters.AddWithValue("@stock", producto.stock);
command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria); command.Parameters.AddWithValue("@idcategoria", 1);
int filasAfectadas = command.ExecuteNonQuery();
if (filasAfectadas > 0) { return true; }
else { return false; }
}
}
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public static bool editarProductoDAO(Producto producto)
{
var db_conexion = new Conexion();
try
{
using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open();
string sql = "UPDATE Producto SET nombre = @nombre, precio = @precio, img = @img WHERE idproducto = @idproducto;";
using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{
command.Parameters.AddWithValue("@nombre", producto.nombre);
command.Parameters.AddWithValue("@precio", producto.precion);
command.Parameters.AddWithValue("@img", producto.img);
command.Parameters.AddWithValue("@idproducto", producto.idProducto);
int filasAfectadas = command.ExecuteNonQuery(); int filasAfectadas = command.ExecuteNonQuery();
if (filasAfectadas > 0) { return true; } if (filasAfectadas > 0) { return true; }
@@ -1750,6 +1783,85 @@ 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 bool insertarVarianteDAO(Variante variante)
{
var db_conexion = new Conexion();
try
{
SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open();
string sql = "INSERT INTO variantes (nombre, precio, cantidad, img, fk_producto, precioCompra) " +
"VALUES(@nombre, @precio, @cantidad, @img, @fk_producto, @precioCompra);";
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.ExecuteNonQuery();
return true;
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public static bool eliminarVarianteDAO(int idVariante)
{
var db_conexion = new Conexion();
try
{
SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open();
string sql = "DELETE FROM variantes WHERE idVariante = @idVariante;";
SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@idVariante", idVariante);
command.ExecuteNonQuery();
return true;
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public static SQLiteDataReader conseguirImportesDAO() public static SQLiteDataReader conseguirImportesDAO()
{ {
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
+50 -1
View File
@@ -66,7 +66,17 @@ namespace compabetov2.database
{ {
return DAO.insertarProductoDAO(producto); return DAO.insertarProductoDAO(producto);
} }
public static bool editarProducto(Producto producto)
{
return DAO.editarProductoDAO(producto);
}
public static bool eliminarProducto(Producto producto)
{
return DAO.eliminarProductoDAO(producto);
}
public static bool insertarCliente(Cliente cliente) public static bool insertarCliente(Cliente cliente)
{ {
return DAO.insertarClienteDAO(cliente); return DAO.insertarClienteDAO(cliente);
@@ -564,6 +574,45 @@ namespace compabetov2.database
return variantes; return variantes;
} }
public static List<Variante> conseguirVariante(int idProducto)
{
List<Variante> variantes = new List<Variante>();
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 bool insertarVariante(Variante variante)
{
return DAO.insertarVarianteDAO(variante);
}
public static bool eliminarVariante(int idVariante)
{
return DAO.eliminarVarianteDAO(idVariante);
}
public static List<ImporteModel> conseguirImportes() public static List<ImporteModel> conseguirImportes()
{ {
List<ImporteModel> importes = new List<ImporteModel>(); List<ImporteModel> importes = new List<ImporteModel>();
Binary file not shown.
@@ -1 +1 @@
30eeea1d3a18c3af78d41c1a75498495f055cb0c8c73112988833c654a1eeba7 e213d9beb5da3320ef36bb44a93fdae1bbcb3db7d3ede06b34b1df208bbd692a
@@ -156,3 +156,7 @@ C:\Users\carsu\source\repos\compabetoOG\obj\Debug\compabetov2.admin.editar.resou
======= =======
C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.editar.resources C:\Users\Googl\Source\Repos\aspermaster23yeh\compabetoOG\obj\Debug\compabetov2.admin.editar.resources
>>>>>>> ae6945f7e474edb1bde1c277c092d25b221e151b >>>>>>> ae6945f7e474edb1bde1c277c092d25b221e151b
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
Binary file not shown.
Binary file not shown.
Binary file not shown.