protected void Button1_Click(object sender, EventArgs e) { int idCustomer = 0; try { idCustomer = Convert.ToInt16(DropDownList1.SelectedValue.ToString()); } catch (Exception ex) { idCustomer = 0; } string idProducts = Page.Request["Productos"]; string Amounts = Page.Request["Cantidad"]; Double Total = Convert.ToDouble(Page.Request["Total"]); string[] aidProducts; string[] aAmounts; try { aidProducts = idProducts.Split(new char[] { ',' }); } catch(Exception ex) { aidProducts = new string[0]; } try { aAmounts = Amounts.Split(new char[] { ',' }); } catch(Exception ex) { aAmounts = new string[0]; } if (idCustomer == 0) { this.setNotification("error", "¡Ooooops!", "Selecciona un cliente..."); } else if (aidProducts.Length == 0) { this.setNotification("warning", "¡No hay productos seleccionados!", "Selecciona un producto como mínimo..."); } else if (aidProducts.Length != aAmounts.Length) { this.setNotification("error", "¡Ooooops!", "No hay el mismo número de productos seleccionados que cantidades..."); } else if (Total == 0) { this.setNotification("error", "¡Ooooops!", "Algo salió mal..."); } else { Products products = new Products(); products.saveSell(idCustomer, this.user.idUser, Total, aidProducts, aAmounts); this.setNotification("success", "¡Éxito!", "Los productos han sido asignados"); } }