示例#1
0
        private void GenerateScript()
        {
            ArrayList ProjectIds = new ArrayList();

            switch (ProjectListType)
            {
            case "All":
                using (IDataReader reader = Project.GetListProjects())
                {
                    while (reader.Read())
                    {
                        ProjectIds.Add(int.Parse(reader["ProjectId"].ToString()));
                    }
                }
                break;

            case "Portfolio":
                DataTable dt = Project.GetListProjectGroupedByPortfolio(int.Parse(ProjectListData), 0, 0);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        int prid = int.Parse(dr["ProjectId"].ToString());
                        if (prid > 0)
                        {
                            ProjectIds.Add(prid);
                        }
                    }
                }
                break;

            case "Custom":
                if (ProjectListData != null && ProjectListData.Length > 0)
                {
                    string[] Ids = ProjectListData.Split(';');
                    if (Ids != null && Ids.Length > 0)
                    {
                        for (int i = 0; i < Ids.Length; i++)
                        {
                            ProjectIds.Add(int.Parse(Ids[i]));
                        }
                    }
                }
                break;

            default:
                break;
            }
            SpreadSheetDocumentType type = SpreadSheetDocumentType.Total;

            switch (FinanceType)
            {
            case "1":
                type = SpreadSheetDocumentType.WeekYear;
                break;

            case "2":
                type = SpreadSheetDocumentType.MonthQuarterYear;
                break;

            case "3":
                type = SpreadSheetDocumentType.QuarterYear;
                break;

            case "4":
                type = SpreadSheetDocumentType.Year;
                break;

            case "5":
                type = SpreadSheetDocumentType.Total;
                break;
            }

            SpreadSheetView view = null;

            if (!Reverse)
            {
                view = ProjectSpreadSheet.CompareProjects(ProjectIds, type, BasePlan1, FromYear, ToYear);
            }
            else
            {
                view = ProjectSpreadSheet.CompareProjectsReverse(ProjectIds, type, BasePlan1, FromYear, ToYear);
            }
            SpreadSheetView view2;

            if (BasePlan2 != -2)
            {
                if (!Reverse)
                {
                    view2 = ProjectSpreadSheet.CompareProjects(ProjectIds, type, BasePlan2, FromYear, ToYear);
                }
                else
                {
                    view2 = ProjectSpreadSheet.CompareProjectsReverse(ProjectIds, type, BasePlan2, FromYear, ToYear);
                }
            }


            int colCount = view.Columns.Length;
            //int maxWidth = 950;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<script type='text/javascript'>");
            sb.AppendLine("//<![CDATA[");
            sb.AppendLine("if (mygrid2 == null)");
            sb.AppendLine("	mygrid2 = new dhtmlXGridObject('gridbox');");
            //sb.Append("");


            #region Bind: Header Caption

            if (view.Document.DocumentType != SpreadSheetDocumentType.Total && view.Document.DocumentType != SpreadSheetDocumentType.Year)
            {
                sb.AppendFormat("mygrid2.setHeader(\"{0}", LocRM.GetString("tProjects"));
                int YearCounter = ToYear - FromYear + 1;
                int ColSpanRate = -1;

                #region Year
                if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
                {
                    ColSpanRate = 5;
                }
                else if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                {
                    ColSpanRate = 17;
                }
                else if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
                {
                    ColSpanRate = 53;
                }

                int RowSpanRate = (view.Columns.Length - YearCounter) / (YearCounter * 4);
                //int RowSpanRate = 45;
                int yearCount = 0;

                for (int i = 0; i < view.Columns.Length - 1; i++)
                {
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        if (i % (ColSpanRate) == 0)
                        {
                            sb.AppendFormat(",{0}", FromYear + yearCount);
                        }
                        else if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                        {
                            sb.AppendFormat(",{0}", LocRM.GetString("tYear"));
                        }
                        else
                        {
                            sb.Append(",#cspan");
                        }
                    }
                    else
                    {
                        if (i % (ColSpanRate) == 0)
                        {
                            sb.AppendFormat(",{0}", FromYear + yearCount);
                        }
                        else if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                        {
                            sb.AppendFormat(",{0}", LocRM.GetString("tYear"));
                        }
                        else
                        {
                            sb.Append(",#cspan");
                        }
                    }
                    if (i % (ColSpanRate) == 0)
                    {
                        yearCount++;
                    }
                }
                //}
                sb.AppendFormat(",{0}\");", LocRM.GetString("tTotalSum"));
                #endregion

                #region Quartals
                if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                {
                    sb.Append("mygrid2.attachHeader([\"#rspan\"");
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        int counter = i % ColSpanRate;

                        if (counter % (RowSpanRate) == 0 && counter != 16)
                        {
                            sb.AppendFormat(",\"{0} {1}\"", LocRM.GetString("tQuarterYear"), /*(((i + 1) / RowSpanRate) % 4) + 1*/ (counter / 4) + 1);
                        }
                        else
                        if ((counter + 1) % RowSpanRate == 0)
                        {
                            sb.AppendFormat(", \"{0}\"", LocRM.GetString("tQuarterTotal"));
                        }
                        else
                        if (counter == 16)
                        {
                            sb.Append(",\"#rspan\"");
                        }

                        else
                        {
                            sb.Append(",\"#cspan\"");
                        }
                    }
                    sb.Append(",\"#rspan\"]);");
                }
                #endregion

                #region BindServerData
                sb.AppendFormat("mygrid2.attachHeader([\"#rspan\", \"{0}\"", ((Column)view.Columns[0]).Name);
                int _counter = 0;
                for (int i = 1; i < view.Columns.Length - 1; i++)
                {
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        if (i % ColSpanRate == 0)
                        {
                            _counter++;
                        }
                        if ((i + 1 - _counter) % RowSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        if ((i + 1) % ColSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        {
                            sb.AppendFormat(",\" {0}\"", ((Column)view.Columns[i]).Name);
                        }
                    }
                    else
                    {
                        if ((i + 1) % ColSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        {
                            sb.AppendFormat(",\" {0}\"", ((Column)view.Columns[i]).Name);
                        }
                    }
                }
                sb.Append(",\"#rspan\"]);");
                #endregion
            }
            else
            {
                //for scales: Year, Project Total
                sb.AppendFormat("mygrid2.setHeader(\"{0}", LocRM.GetString("tProjects"));

                for (int i = 0; i < view.Columns.Length; i++)
                {
                    sb.AppendFormat(",{0}", ((Column)view.Columns[i]).Name);
                }
                sb.Append("\");");
            }
            #endregion

            #region Bind: Header Width
            sb.AppendFormat("mygrid2.setImagePath('{0}');", ResolveUrl("~/Layouts/Images/dhtmlGrid/imgs"));

            sb.Append("mygrid2.setInitWidths(\"100");
            for (int i = 0; i < view.Columns.Length; i++)
            {
                sb.AppendFormat(",{0}", 60 /*(int)(maxWidth / view.Columns.Length)*/);
            }
            sb.Append("\");");
            #endregion

            #region Bind: Header Align
            sb.Append("mygrid2.setColAlign(\"left");
            for (int i = 0; i < view.Columns.Length; i++)
            {
                sb.Append(",right");
            }
            sb.Append("\");");
            #endregion

            #region Bind: Cols CanEdit
            sb.Append("mygrid2.setColTypes(\"tree");

            for (int i = 0; i < colCount; i++)
            {
                sb.Append(",ro");
            }
            sb.Append("\");");
            #endregion

            #region Bind: Cols Color
            sb.Append("mygrid2.setColumnColor(\"#E1ECFC");
            for (int i = 1; i < colCount; i++)
            {
                sb.Append(",white");
            }
            sb.Append("\");");
            #endregion


            sb.AppendLine("mygrid2.enableKeyboardSupport(false);mygrid2.setOnLoadingEnd('EnableApplyButton');mygrid2.enableEditEvents(false,false,false);mygrid2.init();");

            if (ddBasePlan2.SelectedValue != "-2")
            {
                sb.AppendLine("qstring2='&compare=1';");
                sb.AppendFormat("var xmlurl='{0}?ProjectFinanceCompare=1'+qstring2;", ResolveUrl("~/Modules/XmlForTreeView.aspx"));
                sb.AppendLine("mygrid2.loadXML(xmlurl);");
                sb.AppendLine("compareMode=1;");
            }
            else
            {
                sb.AppendFormat("var xmlurl='{0}?ProjectFinanceCompare=1';", ResolveUrl("~/Modules/XmlForTreeView.aspx"));
                sb.AppendLine("mygrid2.loadXML(xmlurl);");

                sb.AppendLine("compareMode=0;");
            }

            sb.AppendLine("//]]>");
            sb.AppendLine("</script>");
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), sb.ToString());
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            XmlDocument doc = new XmlDocument();
            UserLightPropertyCollection pc = Security.CurrentUser.Properties;

            ArrayList PrIds = LoadProjectList();

            SpreadSheetDocumentType type = SpreadSheetDocumentType.WeekYear;

            switch (FinanceType)
            {
            case "1":
                type = SpreadSheetDocumentType.WeekYear;
                break;

            case "2":
                type = SpreadSheetDocumentType.MonthQuarterYear;
                break;

            case "3":
                type = SpreadSheetDocumentType.QuarterYear;
                break;

            case "4":
                type = SpreadSheetDocumentType.Year;
                break;

            case "5":
                type = SpreadSheetDocumentType.Total;
                break;
            }

            SpreadSheetView view = null;

            if (!Reverse)
            {
                view = ProjectSpreadSheet.CompareProjects(PrIds, type, BasePlan1,
                                                          FromYear, ToYear);
            }
            else
            {
                view = ProjectSpreadSheet.CompareProjectsReverse(PrIds, type, BasePlan1,
                                                                 FromYear, ToYear);
            }
            Response.ContentType = "text/xml";

            if (BasePlan2 == -2)
            {
                doc = ProjectSpreadSheet.CreateViewDocForAnalysis(view);
            }
            else
            {
                SpreadSheetView view2 = null;
                if (!Reverse)
                {
                    view2 = ProjectSpreadSheet.CompareProjects(PrIds, type,
                                                               BasePlan2, FromYear, ToYear);
                }
                else
                {
                    view2 = ProjectSpreadSheet.CompareProjectsReverse(PrIds, type,
                                                                      BasePlan2, FromYear, ToYear);
                }

                doc = ProjectSpreadSheet.CreateViewCompareDocForAnalysis(view, view2);
            }
            if (doc != null)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Charset = "utf-8";
                HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream");
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=BusinessScores.xls");
                string Header = "<html><head><meta http-equiv=\"Content-Type\" content=\"application/octet-stream; charset=utf-8\"></head><body><table>";
                string Footer = "</table></body></html>";

                #region BindTableBody
                string  body       = string.Empty;
                string  sbody      = string.Empty;
                string  childrows  = string.Empty;;
                XmlNode ParentNode = doc.DocumentElement;
                foreach (XmlNode node in ParentNode.ChildNodes)
                {
                    sbody     = "<tr>";
                    childrows = "<tr>";
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        foreach (XmlNode cnode in node2.ChildNodes)
                        {
                            if (node2.Name == "row")
                            {
                                if (BasePlan2 != -2)
                                {
                                    childrows += "<td style='mso-number-format:\\@'>";
                                }
                                else
                                {
                                    childrows += "<td>";
                                }
                                childrows += cnode.InnerText;
                                childrows += "</td>";
                            }
                            else
                            {
                                if (node2.Name == "cell")
                                {
                                    if (BasePlan2 != -2)
                                    {
                                        sbody += "<td style='border-top:1px solid black; mso-number-format:\\@'><b>";
                                    }
                                    else
                                    {
                                        sbody += "<td style='border-top:1px solid black'><b>";
                                    }
                                    sbody += node2.InnerText;
                                    sbody += "<b></td>";
                                }
                            }
                        }
                        childrows += "</tr>";
                    }
                    sbody += "</tr>";
                    sbody += childrows;
                    body  += sbody;
                }
                #endregion

                #region BindTableHeader
                string header1 = string.Empty;
                string header2 = string.Empty;
                string header3 = string.Empty;

                if (view.Document.DocumentType != SpreadSheetDocumentType.Total && view.Document.DocumentType != SpreadSheetDocumentType.Year)
                {
                    int YearCounter = ToYear - FromYear + 1;
                    int ColSpanRate = -1;

                    #region Year
                    if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
                    {
                        ColSpanRate = 5;
                        header1    += "<tr><td rowspan='2' style='border:1px solid black' align='center' >" + LocRM.GetString("tProjects") + "</td>";
                        header2    += "<tr>";
                    }
                    else
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        ColSpanRate = 17;
                        header1    += "<tr><td rowspan='3' style='border:1px solid black' align='center' >" + LocRM.GetString("tProjects") + "</td>";
                        header2    += "<tr>";
                        header3    += "<tr>";
                    }
                    else
                    if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
                    {
                        ColSpanRate = 53;
                        header1    += "<tr><td rowspan='2' style='border:1px solid black' align='center' >" + LocRM.GetString("tProjects") + "</td>";
                        header2    += "<tr>";
                    }

                    int RowSpanRate = (view.Columns.Length - YearCounter) / (YearCounter * 4);
                    //int RowSpanRate = 45;
                    int yearCount = 0;
                    int tmp       = 0;
                    int tmp2      = 0;
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                        {
                            if (i % (ColSpanRate) == 0)
                            {
                                tmp      = FromYear + yearCount;
                                tmp2     = ColSpanRate - 1;
                                header1 += "<td colspan='" + tmp2.ToString() + "' style='border:1px solid black' align='center' >" + tmp.ToString() + "</td>";
                            }
                            else
                            if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                            {
                                header1 += "<td rowspan='3' style='border:1px solid black' align='center' >" + LocRM.GetString("tYear") + "</td>";
                            }
                        }
                        else                        //Week/Year or Quarter/Year
                        {
                            if (i % (ColSpanRate) == 0)
                            {
                                tmp      = FromYear + yearCount;
                                tmp2     = ColSpanRate - 1;
                                header1 += "<td colspan='" + tmp2.ToString() + "' style='border:1px solid black' align='center' >" + tmp.ToString() + "</td>";
                            }
                            else
                            if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                            {
                                header1 += "<td rowspan='2' style='border:1px solid black' align='center' >" + LocRM.GetString("tYear") + "</td>";
                            }
                        }
                        if (i % (ColSpanRate) == 0)
                        {
                            yearCount++;
                        }
                    }
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        header1 += "<td rowspan='3' style='border:1px solid black' align='center' >" + LocRM.GetString("tTotalSum") + "</td></tr>";
                    }
                    else
                    {
                        header1 += "<td rowspan='2' style='border:1px solid black' align='center' >" + LocRM.GetString("tTotalSum") + "</td></tr>";
                    }
                    #endregion

                    #region Quartals
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        for (int i = 0; i < view.Columns.Length - 1; i++)
                        {
                            int counter = i % ColSpanRate;

                            if (counter % (RowSpanRate) == 0 && counter != 16)
                            {
                                tmp      = (counter / 4) + 1;
                                header2 += "<td colspan='3' style='border:1px solid black' align='center' >" + LocRM.GetString("tQuarterYear") + " " + tmp.ToString() + "</td>";
                            }
                            else
                            if ((counter + 1) % RowSpanRate == 0)
                            {
                                header2 += "<td rowspan='2' style='border:1px solid black' align='center' >" + LocRM.GetString("tQuarterTotal") + "</td>";
                            }
                            else
                            if (counter == 16)
                            {
                                //header2+="<td></td>";
                            }
                        }
                        header2 += "</tr>";
                    }
                    #endregion

                    #region BindServerData

                    //sb.AppendFormat("mygrid2.attachHeader([\"#rspan\", \"{0}\"",((Column)view.Columns[0]).Name);
                    int _counter = 0;
                    //header3+="<td>"+((Column)view.Columns[0]).Name+"</td>";
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                        {
                            if (i % ColSpanRate == 0 && i > 0)
                            {
                                _counter++;
                            }
                            if ((i + 1 - _counter) % RowSpanRate == 0 && i > 0)
                            {
                            }
                            else

                            if ((i + 1) % ColSpanRate == 0 && i > 0)
                            {
                            }
                            else
                            {
                                header3 += "<td style='border:1px solid black' align='center' >" + ((Column)view.Columns[i]).Name + "</td>";
                            }
                        }

                        else
                        {
                            if ((i + 1) % ColSpanRate == 0)
                            {
                            }
                            else
                            {
                                header3 += "<td style='border:1px solid black' align='center' >" + ((Column)view.Columns[i]).Name + "</td>";
                            }
                        }
                    }
                    header3 += "</tr>";
                    #endregion
                    body = body.Insert(0, header1 + header2 + header3);
                }
                else
                {
                    header1  = "<tr>";
                    header1 += "<td style='border:1px solid black' align='center' >" + LocRM.GetString("tProjects") + "</td>";
                    for (int i = 0; i < view.Columns.Length; i++)
                    {
                        header1 += "<td style='border:1px solid black' align='center' >" + ((Column)view.Columns[i]).Name + "</td>";
                    }
                    header1 += "</tr>";
                    body     = body.Insert(0, header1);
                }
                #endregion
                HttpContext.Current.Response.Write(String.Concat(Header, body, Footer));
                HttpContext.Current.Response.End();
            }
        }
示例#3
0
        void GenerateScript()
        {
            SpreadSheetView view = ProjectSpreadSheet.LoadView(int.Parse(this.Request["ProjectId"]), 0, int.Parse(tbFrom.Text), int.Parse(tbTo.Text));

            projType = (int)view.Document.DocumentType;

            int           colCount = view.Columns.Length;
            int           YearFrom = int.Parse(tbFrom.Text);
            int           YearTo   = int.Parse(tbTo.Text);
            StringBuilder sb       = new StringBuilder();

            sb.Append("<script type='text/javascript'>");
            sb.Append("if (mygrid == null) mygrid = new dhtmlXGridObject('gridbox');");

            #region Bind: Header Caption
            if (view.Document.DocumentType != SpreadSheetDocumentType.Total && view.Document.DocumentType != SpreadSheetDocumentType.Year)
            {
                // Generate procedure for scale grid
                GenerateScaleUpDownScript(view);

                #region Generate Html for scaling
                StringBuilder scaleHtml = new StringBuilder();
                scaleHtml.Append("<div style='margin: 2px; padding: 2px;'>");
                scaleHtml.Append("<table class='text' cellspacing='2' cellpadding='0'><tr>");
                scaleHtml.AppendFormat("<td valign='top'><img alt='' src='{0}' border='0'/>&nbsp;</td>", ResolveUrl("~/Layouts/Images/zoomin.gif"));
                string disableKeyboard = ((bool)(ddPrimarySheet.SelectedValue != "0")).ToString().ToLower();
                if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                {
                    scaleHtml.AppendFormat("<td id='span-link-month' class='dhtmlLink_Active' onclick='gridScale=-1; GridScaleUpDown2(110); DisableSelection = {1}; this.className=\"dhtmlLink_Active\";'>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tMonthQuarterYear"), disableKeyboard);
                    scaleHtml.AppendFormat("<td id='span-link-quartal' class='dhtmlLink_Passive' onclick='gridScale=2; GridScaleUpDown(110); gridScale=0; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\";'>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tQuarterYear"));
                    scaleHtml.AppendFormat("<td id='span-link-year' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown(110); gridScale=1; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tYear"));
                    scaleHtml.AppendFormat("<td id='span-link-project' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td>", LocRM.GetString("tTotal"));
                }
                else
                if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
                {
                    scaleHtml.AppendFormat("<td id='span-link-week' class='dhtmlLink_Active' onclick='gridScale=-1; GridScaleUpDown2(110); DisableSelection = {1}; this.className=\"dhtmlLink_Active\";'>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tWeekYear"), disableKeyboard);
                    scaleHtml.AppendFormat("<td id='span-link-year' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown(110); gridScale=0; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tYear"));
                    scaleHtml.AppendFormat("<td id='span-link-project' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td>", LocRM.GetString("tTotal"));
                }
                else
                if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
                {
                    scaleHtml.AppendFormat("<td id='span-link-quartal' class='dhtmlLink_Active' onclick='gridScale=-1; GridScaleUpDown2(110); DisableSelection = {1}; this.className=\"dhtmlLink_Active\";'>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tQuarterYear"), disableKeyboard);
                    scaleHtml.AppendFormat("<td id='span-link-year' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown(110); gridScale=0; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td><td class='ibn-separator'>|</td>", LocRM.GetString("tYear"));
                    scaleHtml.AppendFormat("<td id='span-link-project' class='dhtmlLink_Passive' onclick='gridScale=-1; GridScaleUpDown2(0); DisableSelection = true; this.className=\"dhtmlLink_Active\"; '>&nbsp;{0}&nbsp;</td>", LocRM.GetString("tTotal"));
                }
                scaleHtml.Append("</tr></table>");
                scaleHtml.Append("</div>");
                #endregion

                //Absolute panel for scale up/down finance grid
                panelScale.InnerHtml = scaleHtml.ToString();

                sb.AppendFormat("mygrid.setHeader(\"{0},&nbsp;", LocRM.GetString("tGridHeader1"));
                int YearCounter = YearTo - YearFrom + 1;
                int ColSpanRate = -1;

                #region Year
                if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
                {
                    ColSpanRate = 5;
                }
                else if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                {
                    ColSpanRate = 17;
                }
                else if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
                {
                    ColSpanRate = 53;
                }

                int RowSpanRate = (view.Columns.Length - YearCounter) / (YearCounter * 4);
                //int RowSpanRate = 45;
                int yearCount = 0;

                for (int i = 0; i < view.Columns.Length - 1; i++)
                {
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        if (i % (ColSpanRate) == 0)
                        {
                            sb.AppendFormat(",{0}", YearFrom + yearCount);
                        }
                        else if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                        {
                            sb.AppendFormat(",{0} {1}", LocRM.GetString("tYearTotal"), YearFrom + yearCount - 1);
                        }
                        else
                        {
                            sb.Append(",#cspan");
                        }
                    }
                    else
                    {
                        if (i % (ColSpanRate) == 0)
                        {
                            sb.AppendFormat(",{0}", YearFrom + yearCount);
                        }
                        else if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                        {
                            sb.AppendFormat(",{0} {1}", LocRM.GetString("tYearTotal"), YearFrom + yearCount - 1);
                        }
                        else
                        {
                            sb.Append(",#cspan");
                        }
                    }
                    if (i % (ColSpanRate) == 0)
                    {
                        yearCount++;
                    }
                }
                //}
                sb.AppendFormat(",{0}\");", LocRM.GetString("tProjectTotal"));
                #endregion

                #region Quartals
                if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                {
                    sb.Append("mygrid.attachHeader([\"#rspan\", \"#rspan\"");
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        int counter = i % ColSpanRate;

                        if (counter % (RowSpanRate) == 0 && counter != 16)
                        {
                            sb.AppendFormat(",\"{0} {1}\"", LocRM.GetString("tQuarterYear"), /*(((i + 1) / RowSpanRate) % 4) + 1*/ (counter / 4) + 1);
                        }
                        else
                        if ((counter + 1) % RowSpanRate == 0)
                        {
                            sb.AppendFormat(", \"{0}{1}\"", LocRM.GetString("tQuartalTotal"), (counter / 4) + 1);
                        }
                        else
                        if (counter == 16)
                        {
                            sb.Append(",\"#rspan\"");
                        }

                        else
                        {
                            sb.Append(",\"#cspan\"");
                        }
                    }
                    sb.Append(",\"#rspan\"]);");
                }
                #endregion

                #region BindServerData
                sb.AppendFormat("mygrid.attachHeader([\"#rspan\",\"#rspan\", \"{0}\"", ((Column)view.Columns[0]).Name);
                int _counter = 0;
                for (int i = 1; i < view.Columns.Length - 1; i++)
                {
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        if (i % ColSpanRate == 0)
                        {
                            _counter++;
                        }
                        // Total for quartal
                        if ((i + 1 - _counter) % RowSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        //Total for year
                        if ((i + 1) % ColSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        {
                            sb.AppendFormat(",\" {0}\"", ((Column)view.Columns[i]).Name);
                        }
                    }
                    else
                    {
                        if ((i + 1) % ColSpanRate == 0)
                        {
                            sb.Append(",\"#rspan\"");
                        }
                        else
                        {
                            sb.AppendFormat(",\" {0}\"", ((Column)view.Columns[i]).Name);
                        }
                    }
                }
                sb.Append(",\"#rspan\"]);");
                #endregion
            }
            else
            {
                //for scales: Year, Project Total
                sb.AppendFormat("mygrid.setHeader(\"{1},&nbsp;, {0}", ((Column)view.Columns[0]).Name, LocRM.GetString("tGridHeader1"));

                for (int i = 1; i < view.Columns.Length; i++)
                {
                    sb.AppendFormat(", {0}", ((Column)view.Columns[i]).Name);
                }
                sb.Append("\");");
            }
            #endregion

            #region Bind: Header Width
            sb.AppendFormat("mygrid.setImagePath('{0}');", ResolveUrl("~/Layouts/Images/dhtmlGrid/imgs"));

            sb.AppendFormat("mygrid.setInitWidths(\"120,25,{0}", 110 /*(int)(maxWidth / view.Columns.Length)*/);
            for (int i = 1; i < view.Columns.Length; i++)
            {
                sb.AppendFormat(",{0}", 110 /*(int)(maxWidth / view.Columns.Length)*/);
            }
            sb.Append("\");");
            #endregion

            #region Bind: Header Align
            sb.Append("mygrid.setColAlign(\"left,left,right");
            for (int i = 1; i < view.Columns.Length; i++)
            {
                sb.Append(",right");
            }
            sb.Append("\");");
            #endregion

            #region Bind: Cols CanEdit

            if (ddPrimarySheet.SelectedValue != "0")
            {
                sb.Append("mygrid.setColTypes(\"tree,ro,ro");
            }
            else
            {
                sb.Append("mygrid.setColTypes(\"tree,ro,ed");
            }
            for (int i = 1; i < colCount; i++)
            {
                if (ddPrimarySheet.SelectedValue != "0")
                {
                    sb.Append(",ro");
                }
                else
                {
                    sb.Append(",ed");
                }
            }
            sb.Append("\");");
            #endregion

            #region Bind: Cols Color
            sb.Append("mygrid.setColumnColor(\"#E1ECFC,#E1ECFC");
            for (int i = 1; i < colCount; i++)
            {
                sb.Append(",white");
            }
            sb.Append("\");");
            #endregion

            sb.Append("gridScale = 0;");
            sb.Append(" mygrid.enableKeyboardSupport(false); mygrid.enableDragAndDrop(true); mygrid.setDragBehavior('sibling'); mygrid.init(); ");
            sb.Append("mygrid.setDragHandler(drag_f); mygrid.setDropHandler(drop_f);");


            if (ddSecondarySheet.SelectedValue != "-2")
            {
                sb.AppendFormat("qstring2='&BasePlanSlotId1={0}&BasePlanSlotId2={1}&FromYear={2}&ToYear={3}&compare=1';", ddPrimarySheet.SelectedValue, ddSecondarySheet.SelectedValue, tbFrom.Text, tbTo.Text);
                sb.AppendFormat("var xmlurl = '{0}?ProjectId={1}&ProjectFinance=1'+qstring2;", ResolveUrl("~/Modules/XmlForTreeView.aspx"), ProjectId);
                sb.AppendFormat("mygrid.loadXML(xmlurl);", ResolveUrl("~/Modules/XmlForTreeView.aspx"), ProjectId);
                //sb.Append("function({HighlightCell(null, -1, mygrid.getRowId(0), 2);});");
                sb.Append("compareMode = 1;");
            }
            else
            {
                sb.AppendFormat("qstring2='&BasePlanSlotId1={0}&BasePlanSlotId2={1}&FromYear={2}&ToYear={3}';", ddPrimarySheet.SelectedValue, ddSecondarySheet.SelectedValue, tbFrom.Text, tbTo.Text);
                sb.AppendFormat("var xmlurl = '{0}?ProjectId={1}&ProjectFinance=1'+qstring2;", ResolveUrl("~/Modules/XmlForTreeView.aspx"), ProjectId);
                sb.AppendFormat("mygrid.loadXML(xmlurl);", ResolveUrl("~/Modules/XmlForTreeView.aspx"), ProjectId);
                //sb.Append("function({HighlightCell(null, -1, mygrid.getRowId(0), 2);});");
                sb.Append("compareMode = 0;");
            }
            //sb.Append("mygrid.attachHeader([\"#rspan\", \"#rspan\", \"TEST MF\", \"#cspan\", \"T2\", \"_\", \"_\", \"T3\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\"]);");
            //sb.Append("mygrid.setSizes();");

            if (ddPrimarySheet.SelectedValue == "0")
            {
                sb.Append("DisableSelection = false;");
                sb.Append(" setTimeout(\"HighlightCell(null,-1,mygrid.getRowId(0), 2)\", 500); ");
            }
            else
            {
                sb.Append("DisableSelection = true;");
            }
            sb.Append("mygrid.setOnEditCellHandler(GridCellEdit); ");

            //DV: Fix bug with new doctype
            sb.Append("window.setTimeout(function () ");
            sb.Append("{ if (document.getElementById('gridbox')) { ");
            sb.Append("	document.getElementById('gridbox').style.height = '399px'; ");
            sb.Append("	window.setTimeout(function() { document.getElementById('gridbox').style.height = '400px'; }, 1000);");
            sb.Append("	}");
            sb.Append("}, 100);");

            sb.Append("</script>");

            //Page.RegisterClientScriptBlock();
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), sb.ToString());
        }
示例#4
0
        private void GenerateScaleUpDownScript(SpreadSheetView view)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=JavaScript>");
            sb.Append("function GridScaleUpDown2(newlength2) {  popup_show(); ");
            //Clear TD selection
            sb.Append("var obj = document.getElementById('span-link-month'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-quartal'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-year'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-week'); if (obj != null) obj.className='dhtmlLink_Passive'; ");
            sb.Append("obj = document.getElementById('span-link-project'); if (obj != null) obj.className='dhtmlLink_Passive'; ");

            sb.Append("newColumnLength = newlength2; setTimeout(\"GridScaleUpDown(newColumnLength);\", 100); }");
            sb.Append("function GridScaleUpDown(newlength) { ");

            sb.Append("if (gridScale != null && gridScale != 'undefined') { ");

            #region ShowHideToalForProject
            sb.Append("if (gridScale == -1) {");
            for (int i = 2; i <= view.Columns.Length; i++)
            {
                sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
            }
            sb.Append("popup_hide(); return;");
            sb.Append("}");
            #endregion

            #region MonthQuarterYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
            {
                //Month <-> Quartal
                sb.Append("if((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) { ");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 17;
                    if ((counter + 1) % 4 == 0 || counter > 14)
                    {
                        continue;
                    }
                    sb.AppendFormat("mygrid.setColWidth({0},newlength);", i);
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; } popup_hide(); return;}");                 // gridScale == 0

                //Quartal <-> Year
                sb.Append("if ((gridScale == 1 && newlength == 0) || (gridScale == 2 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 17;
                    if ((counter + 1) % 4 == 0 || counter < 15)
                    {
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                    }
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale=0; } popup_hide(); return;}");                 //gridScale == 1
            }
            #endregion

            #region WeekYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
            {
                sb.Append("if ((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 53;
                    if (counter < 52)
                    {
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                    }
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; }  popup_hide(); return;}");
            }
            #endregion

            #region QuarterYear
            if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
            {
                sb.Append("if ((gridScale == 0 && newlength == 0) || (gridScale == 1 && newlength > 0)) {");
                for (int i = 2; i < view.Columns.Length; i++)
                {
                    int counter = (i - 2) % 5;
                    if (counter < 4)
                    {
                        sb.AppendFormat("mygrid.setColWidth({0},newlength); ", i);
                    }
                }
                sb.Append("if (newlength == 0) {gridScale++; } else {gridScale--; } popup_hide(); return;}");
            }
            #endregion



            sb.Append("popup_hide();} "); // gridScale != null

            sb.Append("}");               // function
            sb.Append("</script>");

            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), sb.ToString());
        }
示例#5
0
        /// <summary>
        /// Generates the project task business score report.
        /// </summary>
        /// <param name="projectIdList">The project id list.</param>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="completion">The completion.</param>
        /// <param name="completionFrom">The completion from.</param>
        /// <param name="completionTo">The completion to.</param>
        /// <returns></returns>
        public static ReportResult GenerateProjectTaskBusinessScoreReport(List <int> projectIdList,
                                                                          DateTime from, DateTime to, int completion, DateTime completionFromDate, DateTime completionToDate)
        {
            if (projectIdList == null)
            {
                throw new ArgumentNullException("projectIdList");
            }
            // test only;
            //projectIdList = new List<int>(new int[] { 624, 544, 665, 680, 686, 687, 688, 689, 681, 691, 781, 633, 809, 803, 801, 838, 407, 852, 849, 853, 841, 856, 819, 848 });

            TimeZone tz = Security.CurrentUser.CurrentTimeZone;

            completionFromDate = tz.ToUniversalTime(completionFromDate);
            completionToDate   = tz.ToUniversalTime(completionToDate);

            ReportResult result = new ReportResult();

            foreach (int projectId in projectIdList)
            {
                // Get Project Title
                string projectTitleName = Project.GetProjectTitle(projectId);

                ReportResultItem projectItem = new ReportResultItem(ObjectTypes.Project, projectId, projectTitleName);

                #region Load Task List
                // Get Task(Id,Name) List by projectId and fill projectItem.Items
                using (IDataReader reader = DbReport.GetTasks(projectId, completion, completionFromDate, completionToDate))
                {
                    while (reader.Read())
                    {
                        int    taskId    = (int)reader["TaskId"];
                        string taskTitle = (string)reader["Title"];

                        ReportResultItem taskItem = new ReportResultItem(ObjectTypes.Task, taskId, taskTitle);

                        // Add taskItem to projectItem
                        projectItem.ChildItems.Add(taskItem);
                    }
                }
                #endregion

                #region Create SpreadSheetDocument and SpreadSheetView
                // Create a new Spread Sheet Document
                SpreadSheetDocument ssDocument = new SpreadSheetDocument(SpreadSheetDocumentType.Total);

                // Load Template
                ssDocument.Template.Load(Path.Combine(ProjectSpreadSheet.TemplateDirectory, "ProfitAndLossStatementSimple_RU.xml"));

                ProjectSpreadSheetRow[] projectSpreadSheets = ProjectSpreadSheetRow.List(projectId);
                ProjectSpreadSheetRow   projectSpreadSheet  = projectSpreadSheets[0];

                // Add user rows
                if (projectSpreadSheet.UserRows != string.Empty)
                {
                    try
                    {
                        ssDocument.Template.LoadXml(projectSpreadSheet.UserRows);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex);
                    }
                }

                SpreadSheetView ssView = new SpreadSheetView(ssDocument);
                #endregion

                // Load Business Score
                //BusinessScore[] businessScoreList = BusinessScore.List();
                List <ReportResultItem> taskWithoutFinancesRemoveIt = new List <ReportResultItem>();

                #region Calcualte Business Score
                // Calcualte Business Score
                foreach (ReportResultItem taskItem in projectItem.ChildItems)
                {
                    // Cleare Spread Sheet Document
                    ssView.Document.DeleteAllCells();

                    // Get Actual Finances for current task + task/todo
                    ActualFinances[] finances = ActualFinances.List(taskItem.ObjectId, taskItem.ObjectType, from, to);

                    if (finances.Length > 0)
                    {
                        // Append Actual Finances to SpreadSheetDocument
                        foreach (ActualFinances finance in finances)
                        {
                            string columnId = SpreadSheetView.GetColumnByDate(ssView.Document.DocumentType, finance.Date);
                            string rowId    = finance.RowId;

                            Cell cell = ssView.Document.GetCell(columnId, rowId);
                            if (cell == null)
                            {
                                cell = ssView.Document.AddCell(columnId, rowId, CellType.Common, 0);
                            }

                            cell.Value += finance.Value;
                        }

                        // Add Business Scope ReportResultItem and Calculate Business Scope total.
                        // TODO: Localize ReportResultItem.Name
                        taskItem.ChildItems.Add(new ReportResultItem(ObjectTypes.UNDEFINED, -1, "Доходы" /*"Revenues"*/));
                        taskItem.ChildItems.Add(new ReportResultItem(ObjectTypes.UNDEFINED, -1, "Расходы" /*Expenses"*/));
                        taskItem.ChildItems.Add(new ReportResultItem(ObjectTypes.UNDEFINED, -1, "Чистый доход" /*"NetIncome"*/));

                        taskItem.ChildItems[0].Total = ssView["TT", "Revenues"];
                        taskItem.ChildItems[1].Total = ssView["TT", "Expenses"];
                        taskItem.ChildItems[2].Total = ssView["TT", "NetIncome"];

                        // Copy NetIncome to total
                        taskItem.Total = taskItem.ChildItems[2].Total;
                    }
                    else
                    {
                        taskWithoutFinancesRemoveIt.Add(taskItem);
                    }
                }

                // Remove Empty Tasks
                foreach (ReportResultItem item in taskWithoutFinancesRemoveIt)
                {
                    projectItem.ChildItems.Remove(item);
                }
                #endregion

                projectItem.Total = CalculateTotal(projectItem.ChildItems);

                // Add projectItem to result
                result.Items.Add(projectItem);
            }

            // Calculate Report Total
            result.Total = CalculateTotal(result.Items);

            // Final return result
            return(result);
        }
        private void BindFinanceTable()
        {
            XmlDocument doc   = new XmlDocument();
            ArrayList   PrIds = LoadProjectList();

            SpreadSheetDocumentType type = SpreadSheetDocumentType.WeekYear;

            switch (FinanceType)
            {
            case "1":
                type = SpreadSheetDocumentType.WeekYear;
                break;

            case "2":
                type = SpreadSheetDocumentType.MonthQuarterYear;
                break;

            case "3":
                type = SpreadSheetDocumentType.QuarterYear;
                break;

            case "4":
                type = SpreadSheetDocumentType.Year;
                break;

            case "5":
                type = SpreadSheetDocumentType.Total;
                break;
            }

            SpreadSheetView view = null;

            if (!Reverse)
            {
                view = ProjectSpreadSheet.CompareProjects(PrIds, type, BasePlan1,
                                                          FromYear, ToYear);
            }
            else
            {
                view = ProjectSpreadSheet.CompareProjectsReverse(PrIds, type, BasePlan1,
                                                                 FromYear, ToYear);
            }

            if (BasePlan2 == -2)
            {
                doc = ProjectSpreadSheet.CreateViewDocForAnalysis(view);
            }
            else
            {
                SpreadSheetView view2 = null;
                if (!Reverse)
                {
                    view2 = ProjectSpreadSheet.CompareProjects(PrIds, type,
                                                               BasePlan2, FromYear, ToYear);
                }
                else
                {
                    view2 = ProjectSpreadSheet.CompareProjectsReverse(PrIds, type,
                                                                      BasePlan2, FromYear, ToYear);
                }

                doc = ProjectSpreadSheet.CreateViewCompareDocForAnalysis(view, view2);
            }

            if (doc != null)
            {
                #region BindTableHeader
                HtmlTableRow rheader1 = new HtmlTableRow();
                HtmlTableRow rheader2 = new HtmlTableRow();
                HtmlTableRow rheader3 = new HtmlTableRow();
                if (view.Document.DocumentType != SpreadSheetDocumentType.Total && view.Document.DocumentType != SpreadSheetDocumentType.Year)
                {
                    int YearCounter = ToYear - FromYear + 1;
                    int ColSpanRate = -1;

                    #region Year
                    if (view.Document.DocumentType == SpreadSheetDocumentType.QuarterYear)
                    {
                        ColSpanRate = 5;
                        HtmlTableCell c1 = new HtmlTableCell();
                        c1.RowSpan   = 2;
                        c1.InnerText = LocRM.GetString("tProjects");
                        rheader1.Cells.Add(c1);
                    }
                    else
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        ColSpanRate = 17;
                        HtmlTableCell c1 = new HtmlTableCell();
                        c1.RowSpan   = 3;
                        c1.InnerText = LocRM.GetString("tProjects");
                        rheader1.Cells.Add(c1);
                    }
                    else
                    if (view.Document.DocumentType == SpreadSheetDocumentType.WeekYear)
                    {
                        ColSpanRate = 53;
                        HtmlTableCell c1 = new HtmlTableCell();
                        c1.RowSpan   = 2;
                        c1.InnerText = LocRM.GetString("tProjects");
                        rheader1.Cells.Add(c1);
                    }

                    int RowSpanRate = (view.Columns.Length - YearCounter) / (YearCounter * 4);
                    int yearCount   = 0;
                    int tmp         = 0;
                    int tmp2        = 0;
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                        {
                            if (i % (ColSpanRate) == 0)
                            {
                                tmp  = FromYear + yearCount;
                                tmp2 = ColSpanRate - 1;
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.Align     = "center";
                                c1.ColSpan   = tmp2;
                                c1.InnerHtml = tmp.ToString();
                                rheader1.Cells.Add(c1);
                            }
                            else
                            if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.RowSpan   = 3;
                                c1.Align     = "center";
                                c1.InnerHtml = LocRM.GetString("tYear");
                                rheader1.Cells.Add(c1);
                            }
                        }
                        else                        //Week/Year or Quarter/Year
                        {
                            if (i % (ColSpanRate) == 0)
                            {
                                tmp  = FromYear + yearCount;
                                tmp2 = ColSpanRate - 1;
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.ColSpan   = tmp2;
                                c1.Align     = "center";
                                c1.InnerHtml = tmp.ToString();
                                rheader1.Cells.Add(c1);
                            }
                            else
                            if (((i - yearCount + 1) % (ColSpanRate - 1) == 0) && (i - yearCount + 1 != 0))
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.RowSpan   = 2;
                                c1.InnerHtml = LocRM.GetString("tYear");
                                c1.Align     = "center";
                                rheader1.Cells.Add(c1);
                            }
                        }
                        if (i % (ColSpanRate) == 0)
                        {
                            yearCount++;
                        }
                    }
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        HtmlTableCell c1 = new HtmlTableCell();
                        c1.RowSpan   = 3;
                        c1.InnerHtml = LocRM.GetString("tTotalSum");
                        c1.Align     = "center";
                        rheader1.Cells.Add(c1);
                    }
                    else
                    {
                        HtmlTableCell c1 = new HtmlTableCell();
                        c1.RowSpan   = 2;
                        c1.InnerHtml = LocRM.GetString("tTotalSum");
                        c1.Align     = "center";
                        rheader1.Cells.Add(c1);
                    }
                    #endregion

                    #region Quartals
                    if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                    {
                        for (int i = 0; i < view.Columns.Length - 1; i++)
                        {
                            int counter = i % ColSpanRate;

                            if (counter % (RowSpanRate) == 0 && counter != 16)
                            {
                                tmp = (counter / 4) + 1;
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.ColSpan   = 3;
                                c1.Align     = "center";
                                c1.InnerHtml = LocRM.GetString("tQuarterYear") + " " + tmp.ToString();
                                rheader2.Cells.Add(c1);
                            }
                            else
                            if ((counter + 1) % RowSpanRate == 0)
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.RowSpan   = 2;
                                c1.InnerHtml = LocRM.GetString("tQuarterTotal");
                                c1.Align     = "center";
                                rheader2.Cells.Add(c1);
                            }
                            else
                            if (counter == 16)
                            {
                            }
                        }
                    }
                    #endregion

                    #region BindServerData
                    int _counter = 0;
                    for (int i = 0; i < view.Columns.Length - 1; i++)
                    {
                        if (view.Document.DocumentType == SpreadSheetDocumentType.MonthQuarterYear)
                        {
                            if (i % ColSpanRate == 0 && i > 0)
                            {
                                _counter++;
                            }
                            if ((i + 1 - _counter) % RowSpanRate == 0 && i > 0)
                            {
                            }
                            else

                            if ((i + 1) % ColSpanRate == 0 && i > 0)
                            {
                            }
                            else
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.InnerHtml = ((Column)view.Columns[i]).Name;
                                c1.Align     = "center";
                                rheader3.Cells.Add(c1);
                            }
                        }

                        else
                        {
                            if ((i + 1) % ColSpanRate == 0)
                            {
                            }
                            else
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.InnerHtml = ((Column)view.Columns[i]).Name;
                                c1.Align     = "center";
                                rheader3.Cells.Add(c1);
                            }
                        }
                    }
                    #endregion
                    rheader1.Attributes.Add("class", "gridheader");
                    tGrid.Rows.Add(rheader1);
                    rheader2.Attributes.Add("class", "gridheader");
                    if (rheader2.Cells.Count > 0)
                    {
                        tGrid.Rows.Add(rheader2);
                    }
                    rheader3.Attributes.Add("class", "gridheader");
                    if (rheader3.Cells.Count > 0)
                    {
                        tGrid.Rows.Add(rheader3);
                    }
                }
                else
                {
                    rheader1 = new HtmlTableRow();
                    HtmlTableCell c1 = new HtmlTableCell();
                    c1.InnerHtml = LocRM.GetString("tProjects");
                    rheader1.Cells.Add(c1);
                    for (int i = 0; i < view.Columns.Length; i++)
                    {
                        c1           = new HtmlTableCell();
                        c1.InnerHtml = ((Column)view.Columns[i]).Name;
                        c1.Align     = "center";
                        rheader1.Cells.Add(c1);
                    }
                    rheader1.Attributes.Add("class", "gridheader");
                    tGrid.Rows.Add(rheader1);
                }

                #endregion

                #region BindTableBody
                XmlNode ParentNode = doc.DocumentElement;

                foreach (XmlNode node in ParentNode.ChildNodes)
                {
                    HtmlTableRow rbody = new HtmlTableRow();
                    ArrayList    alcr  = new ArrayList();
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        HtmlTableRow crbody = new HtmlTableRow();
                        foreach (XmlNode cnode in node2.ChildNodes)
                        {
                            if (node2.Name == "row")
                            {
                                HtmlTableCell c1 = new HtmlTableCell();
                                c1.Align     = "right";
                                c1.InnerHtml = cnode.InnerText;
                                crbody.Cells.Add(c1);
                            }
                            else
                            {
                                if (node2.Name == "cell")
                                {
                                    HtmlTableCell c2 = new HtmlTableCell();
                                    c2.InnerHtml = "<b>" + node2.InnerText + "</b>";
                                    rbody.Cells.Add(c2);
                                }
                            }
                        }
                        alcr.Add(crbody);
                        crbody = new HtmlTableRow();
                    }
                    if (rbody.Cells.Count > 0)
                    {
                        tGrid.Rows.Add(rbody);
                    }
                    for (int i = 0; i < alcr.Count; i++)
                    {
                        if (((HtmlTableRow)alcr[i]).Cells.Count > 0)
                        {
                            tGrid.Rows.Add((HtmlTableRow)alcr[i]);
                        }
                    }
                    for (int i = 0; i < tGrid.Rows.Count; i++)
                    {
                        if (tGrid.Rows[i].Cells.Count > 0)
                        {
                            tGrid.Rows[i].Cells[0].Attributes.Add("class", "gridheader");
                        }
                    }
                }
                #endregion
            }
        }