crud de variante en proceso
This commit is contained in:
+72
-2
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using compabetov2.database.modelos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,9 +14,77 @@ namespace compabetov2.admin
|
||||
{
|
||||
public partial class addvariante : Form
|
||||
{
|
||||
public addvariante()
|
||||
private string imagePath = "";
|
||||
private Producto producto;
|
||||
Variantes ventanaPadre;
|
||||
public addvariante(Producto producto, Variantes ventanaPadre)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.ventanaPadre = ventanaPadre;
|
||||
this.producto = producto;
|
||||
}
|
||||
|
||||
private void pictureBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void pictureBox2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (isInt(txtCantidad.Text) && isDecimal(txtPrecio.Text) && isDecimal(txtPrecioCompra.Text)) {
|
||||
Variante NuevaVariante = new Variante(
|
||||
-1,
|
||||
txtNombre.Text,
|
||||
Decimal.Parse(txtPrecio.Text),
|
||||
int.Parse(txtCantidad.Text),
|
||||
imagePath,
|
||||
producto.idProducto,
|
||||
Decimal.Parse(txtPrecioCompra.Text)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool isInt(string cadena)
|
||||
{
|
||||
try
|
||||
{
|
||||
int.Parse(cadena);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool isDecimal(string cadena)
|
||||
{
|
||||
try
|
||||
{
|
||||
Decimal.Parse(cadena);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Por favor introduzca un precio valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog1 = new OpenFileDialog();
|
||||
|
||||
openFileDialog1.Filter = "Archivos de imagen (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg;*.jpeg;*.png;*.bmp";
|
||||
openFileDialog1.Title = "Seleccionar imagen";
|
||||
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
imagePath = openFileDialog1.FileName;
|
||||
lbImg.Text = $"Imagen: {Path.GetFileName(imagePath)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user