envios a medio terminar

This commit is contained in:
carlos
2024-01-23 04:47:28 -06:00
parent 881295d920
commit da855a6c85
24 changed files with 496 additions and 407 deletions
+58
View File
@@ -662,6 +662,64 @@ namespace compabetov2
{
}
private List<DetalleEnvioModel> listaProductosEnvio()
{
List<DetalleEnvioModel> detallesEnvio = new List<DetalleEnvioModel>();
int contador_saltar_2_vueltas = 1;
foreach (var item in flowLayoutPanel2.Controls)
{
if (contador_saltar_2_vueltas <= 3)
{
contador_saltar_2_vueltas++;
continue;
}
TableLayoutPanel panelProducto = item as TableLayoutPanel;
TableLayoutPanel panelInfo = panelProducto.Controls[1] as TableLayoutPanel;
PictureBox pic = panelProducto.Controls[0] as PictureBox;
Label idLabel = null;
foreach (Control control in pic.Controls)
{
if (control is Label)
{
idLabel = (Label)control;
break;
}
}
int idProducto = int.Parse(idLabel.Text);
Producto producto = new Producto(idProducto);
Label Lbcantidad = panelInfo.Controls[2] as Label;
string textcantidad = Lbcantidad.Text;
string[] cantidadCadenas = textcantidad.Split(' ');
int cantidad = int.Parse(cantidadCadenas[1]);
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(-1, producto, cantidad);
detallesEnvio.Add(detalleEnvio);
}
return detallesEnvio;
}
private void btnEnviar_Click(object sender, EventArgs e)
{
List<DetalleEnvioModel> detallesEnvio = listaProductosEnvio();
string responsable = responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text;
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable);
if(detallesEnvio.Count > 0){
if (service.crearEnvio(envio, detallesEnvio))
{
MessageBox.Show("Envio hecho");
}
else
{
MessageBox.Show("No hay ningun producto agregado");
}
}
}
}
}