protected void grid_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e)
    {
        if (!e.IsTotalSummary)
        {
            return;
        }

        ASPxGridView g = sender as ASPxGridView;

        if ((e.SummaryProcess == CustomSummaryProcess.Finalize))
        {
            decimal totalValue = 0;
            CollectGorups();
            foreach (int groupRowIndex in groupRowIndexes)
            {
                decimal uisCount = (decimal)g.GetGroupSummaryValue(groupRowIndex, grid.GroupSummary["UnitsInStock"]);
                decimal uioCount = (decimal)g.GetGroupSummaryValue(groupRowIndex, grid.GroupSummary["UnitsOnOrder"]);
                totalValue += uisCount - uioCount;
            }
            e.TotalValue = totalValue;
        }
    }