private void vista_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            ComboArgumento comboArgumento;

            switch (e.Parameters.Split('|')[0])
            {
            case "ObtenerSkusNoAsociadosAlCombo":
                if (int.Parse(e.Parameters.Split('|')[1]) == 0)
                {
                    comboArgumento = new ComboArgumento
                    {
                        Combo = new Combo
                        {
                            COMBO_ID = null
                        }
                    };
                }
                else
                {
                    comboArgumento = new ComboArgumento
                    {
                        Combo = new Combo
                        {
                            COMBO_ID = int.Parse(e.Parameters.Split('|')[1])
                        }
                    };
                }
                UsuarioSeleccionoCombo?.Invoke(sender, comboArgumento);
                UiListaSku.GridView.JSProperties.Add("cpTerminoDeObtenerSkuNoAsociados", "Enabled");
                break;

            case "AgregarSkusCombo":
                AgregarSkusCombo(sender);
                UiListaSku.GridView.JSProperties.Add("cpTerminoDeAgregarSku", "Enabled");
                break;

            case "AgregarSkusNuevoCombo":
                AgregarSkusNuevoCombo(sender);
                UiListaSku.GridView.JSProperties.Add("cpTerminoDeAgregarSkuComboNuevo", "Enabled");
                break;

            case "LimpiarListaSku":
                ProductosDeCombo            = null;
                ProductosNoAsociadosAlCombo = null;
                break;
            }
        }
        protected void UiVistaSkusCombo_OnCustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            ComboArgumento comboArgumento;

            switch (e.Parameters.Split('|')[0])
            {
            case "ObtenerSkusCombo":
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        COMBO_ID = int.Parse(e.Parameters.Split('|')[1])
                    }
                };
                UsuarioSeleccionoCombo?.Invoke(sender, comboArgumento);
                break;

            case "EliminarTodosSkusCombo":
                EliminarSkusDeCombo(sender);
                UiVistaSkusCombo.JSProperties.Add("cpTerminoDeEliminarTodosSkus", "Enabled");
                break;

            case "EliminarTodosSkusNuevoCombo":
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo()
                };

                ProductosDeCombo = null;

                UsuarioSeleccionoCombo?.Invoke(sender, comboArgumento);
                UiVistaSkusCombo.JSProperties.Add("cpTerminoBatchNuevoCombo", "Enabled");
                break;

            case "LimpiarVistaSku":
                ProductosDeCombo            = null;
                ProductosNoAsociadosAlCombo = null;
                break;
            }
        }
        public void AgregarSkusNuevoCombo(object sender)
        {
            var cantidad = Int32.Parse(UiTxtCantidadSku.Text);

            if (cantidad < 0)
            {
                EstablecerError("La cantidad debe de ser mayor a 0.", UiVistaCombos);
                return;
            }

            var listaSkusAAsociar = UiListaSku.GridView.GetSelectedFieldValues("CODE_SKU", "PACK_UNIT", "DESCRIPTION_SKU", "CODE_PACK_UNIT",
                                                                               "DESCRIPTION_PACK_UNIT", "FAMILY_SKU", "CODE_FAMILY_SKU", "DESCRIPTION_FAMILY_SKU", "ID");

            var listaSkuPorCombos = new List <SkuPorCombo>();

            if (ProductosDeCombo == null)
            {
                var comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        COMBO_ID = null
                    }
                };
                UsuarioSeleccionoCombo?.Invoke(sender, comboArgumento);
            }
            else
            {
                listaSkuPorCombos = ProductosDeCombo.ToList();
            }

            if (listaSkusAAsociar.Count > 0)
            {
                foreach (var sku in listaSkusAAsociar)
                {
                    int?   famSku  = null;
                    string famCode = null;
                    string descFam = null;

                    if (((object[])sku)[5] != null)
                    {
                        famSku  = int.Parse(((object[])sku)[5].ToString());
                        famCode = ((object[])sku)[6].ToString();
                        descFam = ((object[])sku)[7].ToString();
                    }

                    var skuPorCombo = new SkuPorCombo
                    {
                        COMBO_ID = 0
                        ,
                        CODE_SKU = ((object[])sku)[0].ToString()
                        ,
                        PACK_UNIT = int.Parse(((object[])sku)[1].ToString())
                        ,
                        QTY = cantidad
                        ,
                        DESCRIPTION_SKU = ((object[])sku)[2].ToString()
                        ,
                        CODE_PACK_UNIT = ((object[])sku)[3].ToString()
                        ,
                        DESCRIPTION_PACK_UNIT = ((object[])sku)[4].ToString()
                        ,
                        FAMILY_SKU = famSku
                        ,
                        CODE_FAMILY_SKU = famCode
                        ,
                        DESCRIPTION_FAMILY_SKU = descFam
                        ,
                        ID = int.Parse(((object[])sku)[8].ToString())
                    };

                    listaSkuPorCombos.Add(skuPorCombo);
                    skuPorCombo = null;
                }
            }

            ProductosDeCombo = listaSkuPorCombos;



            var res =
                ProductosNoAsociadosAlCombo.Where(
                    s => ProductosDeCombo.All(s2 => s2.ID != s.ID)).ToList();

            ProductosNoAsociadosAlCombo = res;
        }
        protected void UiVistaCombos_OnCustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            ComboArgumento comboArgumento;

            switch (e.Parameters.Split('|')[0])
            {
            case "ObtenerCombos":
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        COMBO_ID = null
                    }
                };
                UsuararioDeseaObtenerCombo?.Invoke(sender, comboArgumento);
                break;

            case "ActualizarCombo":
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        COMBO_ID = int.Parse(e.Parameters.Split('|')[1])
                        ,
                        DESCRIPTION_COMBO = UiTxtDescripcion.Text
                        ,
                        NAME_COMBO = UiTxtNombre.Text
                    }
                };
                UsuarioDeseaActualizarCombo?.Invoke(sender, comboArgumento);
                UiVistaCombos.JSProperties.Add("cpTerminoDeActualizarCombo", "Enabled");
                break;

            case "CrearCombo":
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        DESCRIPTION_COMBO = UiTxtDescripcion.Text
                        ,
                        NAME_COMBO = UiTxtNombre.Text
                        ,
                        SkusPorCombo = ProductosDeCombo
                    }
                };
                UsuarioDeseaAgregarCombo?.Invoke(sender, comboArgumento);
                UiVistaCombos.JSProperties.Add("cpTerminoDeCrearCombo", "Enabled");
                break;

            case "EliminarCombo":
                if (ProductosDeCombo.Count > 0)
                {
                    EstablecerError("No se puede eliminar el combo debido a que este posee productos asociados.", sender);
                    return;
                }
                comboArgumento = new ComboArgumento
                {
                    Combo = new Combo
                    {
                        COMBO_ID = int.Parse(e.Parameters.Split('|')[1])
                        ,
                        DESCRIPTION_COMBO = UiTxtDescripcion.Text
                        ,
                        NAME_COMBO = UiTxtNombre.Text
                    }
                };
                UsuarioDeseaEliminarCombo?.Invoke(sender, comboArgumento);
                UiVistaCombos.JSProperties.Add("cpTerminoDeEliminarCombo", "Enabled");
                break;
            }
        }
Example #5
0
 private void _vista_UsuarioDeseaObtenerSkusPertenecientesAComboDePromocionPorCombo(object sender, ComboArgumento e)
 {
     try
     {
         _vista.SkusPertenecientesAComboDeBonoPorCombo = ComboServicio.ObtenerProductosDeCombo(e.Combo);
     }
     catch (Exception ex)
     {
         _vista.EstablecerError(ex.Message, sender);
     }
 }