public static void AddModelToGrid <T>(
     this MVCxGridViewColumnCollection devExpCollection)
 {
     // you just need the T parameter, not a list
     typeof(T).GetProperties().ToList().ForEach((prop) =>
     {
         DisplayAttribute displayName = null;
         var attributes = prop.GetCustomAttributes(true);
         foreach (var attribute in attributes)
         {
             if (attribute is DisplayAttribute)
             {
                 displayName = (DisplayAttribute)attribute;
             }
         }
         string name = null;
         if (displayName != null)
         {
             name = displayName.Name;
         }
         else
         {
             name = prop.Name;
         }
         devExpCollection.Add(prop.Name, name);
     });
 }
Ejemplo n.º 2
0
        static MVCxGridViewColumnCollection CreateExportedColumns()
        {
            var columns = new MVCxGridViewColumnCollection();

            columns.Add("ProductCode");
            columns.Add("Name");
            columns.Add(
                c =>
            {
                c.FieldName = "Price";
                c.EditorProperties().SpinEdit(p => {
                    p.DisplayFormatString     = "c";
                    p.DisplayFormatInEditMode = true;
                });
            });
            columns.Add(c => {
                c.FieldName = "UnitID";
                c.Caption   = "Unit";
                c.EditorProperties().ComboBox(p => {
                    p.TextField  = "Name";
                    p.ValueField = "UnitID";
                    p.ValueType  = typeof(int);
                    p.BindList(_unitService.GetAll());
                });
            });
            columns.Add("Tax");
            columns.Add("Description");
            return(columns);
        }
Ejemplo n.º 3
0
 // create in grid(control) the child - column of current band
 private static void AddToGrid(AvrViewColumn obj, MVCxGridViewColumnCollection Columns, PdfExportHelper pdfHelper)
 {
     Columns.Add(column =>
     {
         LayoutViewHelper.SetNewColumn(column, obj, pdfHelper);
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// A traves del tipo de un viewModel se obtienen las propiedades y se las agregada a Columns
        /// solo aquellas que no tengan el decorador Invisible y a las agregadas se les cambiara el nombre
        /// si existe otro decorador que lo indique
        /// </summary>
        /// <param name="Columns"></param>
        /// <param name="type"></param>
        public static void AddColumnsSetting(MVCxGridViewColumnCollection Columns, Type type)
        {
            Type modelType = null;

            if (IsEntity(type))
            {
                modelType = type;
            }
            else
            {
                modelType = type.GetGenericArguments().Where(t => t.BaseType.IsEquivalentTo(typeof(Business.Entities.BaseEntities.BaseEntity)) || (t.BaseType.BaseType != null && t.BaseType.BaseType.IsEquivalentTo(typeof(Business.Entities.BaseEntities.BaseEntity)))).FirstOrDefault();
            }

            if (modelType == null)
            {
                return;
            }

            foreach (var property in modelType.GetProperties())
            {
                if (modelType.Name == "Novedad" && property.Name == "NombreTipoNovedad")
                {
                    continue;
                }
                // Si se configuro el modelo para descartar propiedades a agregar al gridview
                var attr = property.GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name.Equals("InvisibleAttribute"));
                if (property.Name == "Id" || attr != null)
                {
                    continue;
                }

                //attr = property.GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name.Equals("ColumnNameGridViewAttribute"));
                if (!IsPropertyForRendered(property.Name))
                {
                    continue;
                }



                Columns.Add(property.Name);
                var style = new DevExpress.Web.GridViewHeaderStyle();
                // style.BackColor = System.Drawing.Color.LightGray;
                Columns[property.Name].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                Columns[property.Name].HeaderStyle.Font.Bold = true;
                ((MVCxGridViewColumn)Columns[property.Name]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;

                // Si se configuro el modelo para cambiar el nombre de la columna agregada
                attr = property.GetCustomAttributesData().FirstOrDefault(a => a.AttributeType.Name.Equals("ColumnNameGridViewAttribute"));
                if (attr != null)
                {
                    var nameColumn = attr.NamedArguments.FirstOrDefault(a => a.MemberName.Equals("Name")).TypedValue.Value.ToString();
                    Columns[property.Name].Caption = nameColumn;
                }
            }
        }
Ejemplo n.º 5
0
        // create in grid(control) the children of current view
        public static void AddToGrid(BaseBand obj, MVCxGridViewColumnCollection Columns)
        {
            PdfExportHelper pdfHelper = new PdfExportHelper(
                obj, BaseSettings.GetSystemFont(true));

            // at first put bands that were reordered by user
            // after that put bands that were not reordered by user in pivot order
            obj.Bands.FindAll(x => !x.IsToDelete).OrderBy(x => x.Order_ForUse).ToList().ForEach(b => AddToGrid(b, Columns, pdfHelper));
            // at first put columns that were reordered by user
            // after that put columns that were not reordered by user in pivot order
            obj.Columns.FindAll(x => !x.IsToDelete).OrderBy(x => x.Order_ForUse).ToList().ForEach(c => AddToGrid(c, Columns, pdfHelper));
        }
Ejemplo n.º 6
0
        public static void AddColumnsSettingViewDataContacto(MVCxGridViewColumnCollection Columns,
                                                             IEnumerable <CRM.Business.Views.BaseViews.BaseView.DynObject> model, HtmlHelper Html)
        {
            if (model.Count() == 0)
            {
                return;
            }

            foreach (var property in model.First().GetDynamicMemberNames())
            {
                if (property.ToUpper().Trim() == "ID" || property.ToUpper().Trim() == "CODIGOCLIENTE" || property.ToUpper().Trim() == "ESTADO")
                {
                    continue;
                }

                if (property.ToUpper().Trim() == "CODCLIENTE")
                {
                    Columns.Add(column => {
                        column.Caption = property;
                        column.SetDataItemTemplateContent(container =>
                        {
                            Html.DevExpress().HyperLink(hyperlink =>
                            {
                                var visibleIndex = container.VisibleIndex;
                                var keyValue     = container.KeyValue;
                                var lastName     = DataBinder.Eval(container.DataItem, "CodCliente");
                                var codCliente   = DataBinder.Eval(container.DataItem, "CodigoCliente");

                                hyperlink.Name            = "hl" + keyValue.ToString();
                                hyperlink.Properties.Text = lastName.ToString();
                                hyperlink.NavigateUrl     = DevExpressHelper.GetUrl(new { Controller = "Cliente", Action = "View", id = codCliente });
                            }).Render();
                        });
                    });
                    //var style = new DevExpress.Web.GridViewHeaderStyle();
                    // style.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.Font.Bold = true;
                    ((MVCxGridViewColumn)Columns[property]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                }
                else
                {
                    Columns.Add(property);
                    //var style = new DevExpress.Web.GridViewHeaderStyle();
                    // style.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.Font.Bold = true;
                    ((MVCxGridViewColumn)Columns[property]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                }

                //Columns.Add(property);
            }
        }
Ejemplo n.º 7
0
 // create in grid(control) the children of current band
 // only here we set properties of grid(control) band
 private static void AddToGrid(AvrViewBand obj, MVCxGridViewColumnCollection Columns, PdfExportHelper pdfHelper)
 {
     Columns.AddBand(newband =>
     {
         newband.Name       = obj.UniquePath;
         newband.Caption    = obj.DisplayText;
         newband.Visible    = obj.IsVisible;
         newband.FixedStyle = obj.IsFreezed ? GridViewColumnFixedStyle.Left : GridViewColumnFixedStyle.None;
         newband.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
         obj.Bands.FindAll(x => !x.IsToDelete).OrderBy(x => x.Order_ForUse).ToList().ForEach(b => AddToGrid(b, newband.Columns, pdfHelper));
         obj.Columns.FindAll(x => !x.IsToDelete).OrderBy(x => x.Order_ForUse).ToList().ForEach(c => AddToGrid(c, newband.Columns, pdfHelper));
     });
 }
Ejemplo n.º 8
0
        public static void AddColumnsSettingViewDataPDF(MVCxGridViewColumnCollection Columns, IEnumerable <CRM.Business.Views.BaseViews.BaseViewString.DynObject> model, bool Export)
        {
            if (model.Count() > 0)
            {
                foreach (var property in model.First().GetDynamicMemberNames())
                {
                    if (property.ToUpper().Trim() == "ID")
                    {
                        continue;
                    }

                    if (Export)
                    {
                        if (!(property.Trim() == "Observaciones" || property.Trim() == "Cg_Cli" ||
                              property.Trim() == "Des_Cli"))
                        {
                            Columns.Add(property);
                            var style = new DevExpress.Web.GridViewHeaderStyle();
                            // style.BackColor = System.Drawing.Color.LightGray;
                            Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                            Columns[property].HeaderStyle.Font.Bold = true;
                            if (property.Trim() == "CantidadPedida")
                            {
                                Columns[property].Caption = "Cant.\n Pedida";
                            }

                            if (property.Trim() == "CantidadRecibida")
                            {
                                Columns[property].Caption = "Cant.\n Recibida";
                            }

                            if (property.Trim() == "UnidadFac")
                            {
                                Columns[property].Caption = "Unidad\nFac";
                            }

                            ((MVCxGridViewColumn)Columns[property]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public static void AddColumnsSettingViewData(MVCxGridViewColumnCollection Columns, IEnumerable <CRM.Business.Views.BaseViews.BaseViewString.DynObject> model)
        {
            if (model.Count() > 0)
            {
                foreach (var property in model.First().GetDynamicMemberNames())
                {
                    if (property.ToUpper().Trim() == "ID" || property.ToUpper().Trim() == "ESTADO")
                    {
                        continue;
                    }


                    if (property.ToUpper().Trim().Contains("FECHA"))
                    {
                        Columns.Add(column =>
                        {
                            column.FieldName  = property;
                            column.Caption    = property;
                            column.ColumnType = MVCxGridViewColumnType.DateEdit;
                        });
                    }
                    else
                    {
                        Columns.Add(property);
                    }

                    if (property.ToUpper().Trim() == "DESCRIPCION")
                    {
                        Columns[property].Width = 350;
                    }

                    var style = new DevExpress.Web.GridViewHeaderStyle();
                    // style.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                    Columns[property].HeaderStyle.Font.Bold = true;
                    ((MVCxGridViewColumn)Columns[property]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                }
            }
        }
Ejemplo n.º 10
0
        public static void AddColumnsSettingViewData(MVCxGridViewColumnCollection Columns,
                                                     IEnumerable <CRM.Business.Views.BaseViews.BaseView.DynObject> model)
        {
            if (model.Count() == 0)
            {
                return;
            }

            foreach (var property in  model.First().GetDynamicMemberNames())
            {
                if (property.ToUpper().Trim() == "ID" || property.ToUpper().Trim() == "ESTADO")
                {
                    continue;
                }

                Columns.Add(property);
                var style = new DevExpress.Web.GridViewHeaderStyle();
                // style.BackColor = System.Drawing.Color.LightGray;
                Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                Columns[property].HeaderStyle.Font.Bold = true;
                ((MVCxGridViewColumn)Columns[property]).Settings.AutoFilterCondition = AutoFilterCondition.Contains;
            }
        }
Ejemplo n.º 11
0
        public static void AddCustomColumnsSettingViewData(MVCxGridViewColumnCollection Columns, IEnumerable <CRM.Business.Views.BaseViews.BaseViewString.DynObject> model,
                                                           HtmlHelper Html, bool IsAdminOperador)
        {
            if (model.Count() == 0)
            {
                return;
            }
            foreach (var property in model.First().GetDynamicMemberNames())
            {
                if (property.ToUpper().Trim() == "ID" || property.ToUpper().Trim() == "DEVOL" ||
                    property.ToUpper().Trim() == "ESTADO" || property.ToUpper().Trim() == "HEXACOLOR" ||
                    property.ToUpper().Trim() == "DESCESTADO")
                {
                    continue;
                }

                if (property.ToUpper().Trim() == "FECHASOLICITADARECEPCION" || property.ToUpper().Trim() == "FECHARECEPCION" ||
                    property.ToUpper().Trim() == "CONF_FECHA" || property.ToUpper().Trim() == "FE_RETIRO" || property.ToUpper().Trim() == "FECHAFINPRODUCCION")
                {
                    Columns.Add(property).PropertiesEdit.DisplayFormatString = "dd/MM/yyyy";


                    /*    Columns(property).FieldName = "AdmissionDate";
                     *  Columns.Caption = "Admission Date";
                     *  Columns.EditFormSettings.Visible = DefaultBoolean.True;
                     *  column.ColumnType = MVCxGridViewColumnType.DateEdit;
                     *  var dateProperties = column.PropertiesEdit as DateEditProperties;
                     *  dateProperties.AllowMouseWheel = true;
                     *  dateProperties.AllowUserInput = true;
                     *  dateProperties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip; */
                }
                else
                {
                    if (property.ToUpper().Trim() == "FECHAAUTORIZADARECEPCION")
                    {
                        if (IsAdminOperador)
                        {
                            Columns.Add(column =>
                            {
                                column.FieldName  = property;
                                column.Caption    = "Fecha Autorizada Recepcion";
                                column.ColumnType = MVCxGridViewColumnType.DateEdit;
                                int count         = 0;
                                column.SetDataItemTemplateContent(container =>
                                {
                                    Html.DevExpress().DateEdit(settings =>
                                    {
                                        var visibleIndex = container.VisibleIndex;
                                        //var keyValue = container.KeyValue;
                                        var keyValue   = DataBinder.Eval(container.DataItem, "ID");
                                        var fecha      = DataBinder.Eval(container.DataItem, "FechaAutorizadaRecepcion");
                                        settings.Width = System.Web.UI.WebControls.Unit.Pixel(90);
                                        settings.Name  = "date" + keyValue.ToString() + count;
                                        if (fecha.ToString() != string.Empty)
                                        {
                                            settings.Date = Convert.ToDateTime(fecha);
                                        }

                                        settings.Properties.DisplayFormatString = "d";
                                        settings.Properties.NullText            = "dd/MM/yyyy";
                                        settings.Properties.EditFormat          = EditFormat.Custom;
                                        settings.Properties.EditFormatString    = "dd/MM/yyyy";
                                        settings.Properties.DisplayFormatString = "dd/MM/yyyy";

                                        settings.Properties.ClientSideEvents.DateChanged = String.Format("function (s, e) {{ UpdatePedido(s, {0}); }}",
                                                                                                         Convert.ToInt32(keyValue));
                                        count++;
                                    }).Render();
                                });
                            });
                            var style = new DevExpress.Web.GridViewHeaderStyle();
                            Columns[property].HeaderStyle.BackColor = System.Drawing.Color.LightGray;
                            Columns[property].HeaderStyle.Font.Bold = true;
                        }
                        else
                        {
                            Columns.Add(property);
                        }
                    }
                    else
                    {
                        if (property.ToUpper().Trim() == "CANTIDADENTREGADA" || property.ToUpper().Trim() == "CANTIDADRECIBIDA")
                        {
                            Columns.Add(property).PropertiesEdit.DisplayFormatString = "N0";
                        }
                        else
                        {
                            Columns.Add(property);
                        }
                    }
                }

                Columns[property].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                Columns[property].HeaderStyle.BackColor     = System.Drawing.Color.LightGray;
                Columns[property].HeaderStyle.Font.Bold     = true;
            }
        }