Exemplo n.º 1
0
        protected void RadGridOrders_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
        {
            switch (e.Column.UniqueName)
            {
            case "AvgPrice":
                try
                {
                    GridItem[] arrGroupFooter = RadGridSalesReport.MasterTableView.GetItems(GridItemType.GroupFooter);
                    GridItem[] arrFooter      = RadGridSalesReport.MasterTableView.GetItems(GridItemType.Footer);

                    if (arrFooter.Any())
                    {
                        GridFooterItem footeritem = arrFooter.Last() as GridFooterItem;
                        int            qty        = int.Parse(footeritem.Cells[4].Text.Replace(",", ""));
                        decimal        value      = decimal.Parse(footeritem.Cells[6].Text.Replace("$", "").Replace(",", ""));

                        e.Result = "$" + String.Format("{0:n}", value / qty);
                        return;
                    }

                    if (arrGroupFooter.Any())
                    {
                        GridGroupFooterItem footeritem = arrGroupFooter.Last() as GridGroupFooterItem;
                        int     qty   = int.Parse(footeritem.Cells[4].Text.Replace(",", ""));
                        decimal value = decimal.Parse(footeritem.Cells[6].Text.Replace("$", "").Replace(",", ""));

                        e.Result = "$" + String.Format("{0:n}", value / qty);
                    }
                }
                catch (Exception ex)
                {
                    IndicoLogging.log.Error("Error occurred while calculating average prices", ex);
                }

                break;

            case "Name":
            {
                if (e.Item is GridGroupFooterItem)
                {
                    GridItem[] arrGroupHeader = RadGridSalesReport.MasterTableView.GetItems(GridItemType.GroupHeader);
                    if (arrGroupHeader.Any())
                    {
                        var headerItem = arrGroupHeader.Last() as GridGroupHeaderItem;
                        e.Result = "Total For " + headerItem.DataCell.Text;
                    }
                }
                else if (e.Item is GridFooterItem)
                {
                    e.Result = "Grand Total ";
                }
            }
            break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
 protected void RadGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
 {
     {
         if (e.Item is GridGroupFooterItem)
         {
             GridGroupFooterItem headerItem = e.Item as GridGroupFooterItem;
             GridItem[]          groups     = RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader);
             foreach (GridGroupHeaderItem group in groups)
             {
                 string id = headerItem["qty_required"].Text;
             }
         }
     }
 }
Exemplo n.º 3
0
        protected void rgGestionRentabilidad_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
        {
            if (((Telerik.Web.UI.GridBoundColumn)e.Column).UniqueName == "UtilidadBrutaPorc")
            {
                // TODO: Filter duplicate check numbers
                Double Venta         = 0;
                Double UtilidadBruta = 0;
                foreach (GridDataItem item in rgGestionRentabilidad.MasterTableView.Items)
                {
                    Venta         += Convert.ToDouble(item["VentaImporte"].Text);
                    UtilidadBruta += Convert.ToDouble(item["UtilidadBrutaImporte"].Text);
                }


                e.Result = (UtilidadBruta / Venta) * 100;
            }
            if (((Telerik.Web.UI.GridBoundColumn)e.Column).UniqueName == "MetaUtilidadBrutaPorc")
            {
                // TODO: Filter duplicate check numbers
                Double Venta = 0;
                Double Meta  = 0;
                foreach (GridDataItem item in rgGestionRentabilidad.MasterTableView.Items)
                {
                    Venta += Convert.ToDouble(item["VentaImporte"].Text);
                    Meta  += Convert.ToDouble(item["MetaUtilidadBrutaImporte"].Text);
                }


                e.Result = (Meta / Venta) * 100;
            }

            if (((Telerik.Web.UI.GridBoundColumn)e.Column).UniqueName == "UtilidadBrutaProyectadaPorc")
            {
                // TODO: Filter duplicate check numbers
                Double Venta      = 0;
                Double Proyectada = 0;
                foreach (GridDataItem item in rgGestionRentabilidad.MasterTableView.Items)
                {
                    Venta      += Convert.ToDouble(item["VentaImporte"].Text);
                    Proyectada += Convert.ToDouble(item["UtilidadBrutaProyectadaImporte"].Text);
                }


                e.Result = (Proyectada / Venta) * 100;
            }
        }