public void TestSetup()
        {
            busReportParameter         = new BReportParameter();
            reportParameter_testObject = new ReportParameter();

            DatabaseGateway.TA_ReportDataTable reportTable = new DatabaseGateway.TA_ReportDataTable();
            reportTable = reportTA.GetRoot();
            if (reportTable.Rows.Count == 0)
            {
                reportTA.Insert("TestRoot", 0, "", null, false);
                reportTable = reportTA.GetRoot();
            }

            ADOReportRoot.ID       = Convert.ToInt32(reportTable.Rows[0]["report_ID"]);
            ADOReportRoot.ParentId = Utility.ToInteger(reportTable.Rows[0]["report_ParentID"]);
            ADOReportRoot.Name     = Convert.ToString(reportTable.Rows[0]["report_Name"]);

            reportTA.Insert("TestReport1", ADOReportRoot.ID, "", null, false);
            reportTA.Insert("TestReport2", ADOReportRoot.ID, "", null, false);

            reportTable         = reportTA.GetDataByName("TestReport1");
            ADOReport1.ID       = Convert.ToInt32(reportTable.Rows[0]["report_ID"]);
            ADOReport1.ParentId = Utility.ToInteger(reportTable.Rows[0]["report_ParentID"]);
            ADOReport1.Name     = Convert.ToString(reportTable.Rows[0]["report_Name"]);

            reportTable         = reportTA.GetDataByName("TestReport2");
            ADOReport2.ID       = Convert.ToInt32(reportTable.Rows[0]["report_ID"]);
            ADOReport2.ParentId = Utility.ToInteger(reportTable.Rows[0]["report_ParentID"]);
            ADOReport2.Name     = Convert.ToString(reportTable.Rows[0]["report_Name"]);

            reportFileTA.Insert("TestReportFile1", "XML");
            reportFileTA.GetDataByName("TestReportFile1");

            DatabaseGateway.TA_ReportFileDataTable reportFileDT = new DatabaseGateway.TA_ReportFileDataTable();
            reportFileDT        = reportFileTA.GetDataByName("TestReportFile1");
            ADOReportFile1.ID   = Convert.ToInt32(reportFileDT.Rows[0]["reportfile_ID"]);
            ADOReportFile1.Name = Convert.ToString(reportFileDT.Rows[0]["reportfile_Name"]);


            uiParamterTA.Insert("TestUIParam1", "TestPage.aspx", "FNNAME", "ENNAME", 1, "Action1", false);
            DatabaseGateway.TA_ReportUIParameterDataTable uiParamtable = uiParamterTA.GetDataByKey("TestPage.aspx");
            ADOReportUIParam1.ID = Convert.ToDecimal(uiParamtable.Rows[0][0]);

            reportParamTA.Insert(ADOReportUIParam1.ID, "TestParam1", ADOReportFile1.ID);
            reportParamTA.Insert(ADOReportUIParam1.ID, "TestParam2", ADOReportFile1.ID);

            DatabaseGateway.TA_ReportParameterDataTable paramTable = reportParamTA.GetDataByReportId(ADOReportFile1.ID);
            ADOReportParam1.ID   = Convert.ToDecimal(paramTable.Rows[0]["ReportParameter_ID"]);
            ADOReportParam1.Name = Convert.ToString(paramTable.Rows[0]["ReportParameter_Name"]);

            ADOReportParam2.ID   = Convert.ToDecimal(paramTable.Rows[1]["ReportParameter_ID"]);
            ADOReportParam2.Name = Convert.ToString(paramTable.Rows[1]["ReportParameter_Name"]);
        }
    public string[] UpdateReport_DesignedReportsPage(string state, string SelectedReportID, string ReportName, string ReportDescription, string DesignedTypeID, string ParentReportID, string DateParameterTypeID, string ParentPath)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            decimal ReportID         = 0;
            decimal selectedReportID = decimal.Parse(this.StringBuilder.CreateString(SelectedReportID), CultureInfo.InvariantCulture);

            string       reportName        = this.StringBuilder.CreateString(ReportName);
            string       reportDescription = this.StringBuilder.CreateString(ReportDescription);
            decimal      designedTypeID    = decimal.Parse(this.StringBuilder.CreateString(DesignedTypeID), CultureInfo.InvariantCulture);
            decimal      parentReportID    = decimal.Parse(this.StringBuilder.CreateString(ParentReportID), CultureInfo.InvariantCulture);
            string       parentPath        = this.StringBuilder.CreateString(ParentPath);
            UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());

            GTS.Clock.Model.Report.Report report = new GTS.Clock.Model.Report.Report();
            report.ID = selectedReportID;
            ReportParameterDesigned reportParameterDesignedObj = null;
            if (uam != UIActionType.DELETE)
            {
                GTS.Clock.Model.Report.DesignedReportType designedType = new BDesignedReportsColumn().GetAllDesignedReportsTypes().SingleOrDefault(d => d.ID == designedTypeID);
                report.Name             = reportName;
                report.Description      = reportDescription;
                report.DesignedType     = designedType;
                report.ParentId         = parentReportID;
                report.IsReport         = true;
                report.IsDesignedReport = true;
                report.ParentPath       = parentPath;
                decimal dateParamID = decimal.Parse(this.StringBuilder.CreateString(DateParameterTypeID), CultureInfo.InvariantCulture);
                if (designedType != null && designedType.CustomCode == DesignedReportTypeEnum.Person)
                {
                    reportParameterDesignedObj = ReportParameterBusiness.GetAllReportParameterDesigned().SingleOrDefault(p => p.CustomCode == "None");
                }
                else
                {
                    reportParameterDesignedObj = ReportParameterBusiness.GetAllReportParameterDesigned().SingleOrDefault(p => p.ID == dateParamID);
                }
                report.ReportParameterDesigned = reportParameterDesignedObj;
            }
            BReportParameter reportParameterBusiness = new BReportParameter();
            switch (uam)
            {
            case UIActionType.ADD:
                ReportID = this.ReportBusiness.InsertReport(report, uam);

                if (reportParameterDesignedObj != null)
                {
                    foreach (ReportParameterDesignedParam item in reportParameterDesignedObj.ReportParameterDesignedParam)
                    {
                        GTS.Clock.Model.Report.ReportParameter reportParameterObj = new GTS.Clock.Model.Report.ReportParameter();
                        reportParameterObj.ID     = 0;
                        reportParameterObj.Report = new GTS.Clock.Model.Report.Report()
                        {
                            ID = ReportID
                        };
                        reportParameterObj.Name = item.Parameter;
                        reportParameterObj.ReportUIParameter = reportParameterDesignedObj.ReportUIParameter;


                        decimal param1Id = reportParameterBusiness.InsertReportParameter(reportParameterObj);
                    }
                }
                break;

            case UIActionType.EDIT:
                if (selectedReportID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoReportSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }

                ReportID = this.ReportBusiness.UpdateReport(report, uam);
                ReportParameterBusiness.DeleteReportParameterByReportID(ReportID);

                foreach (ReportParameterDesignedParam item in reportParameterDesignedObj.ReportParameterDesignedParam)
                {
                    GTS.Clock.Model.Report.ReportParameter reportParameterObj = new GTS.Clock.Model.Report.ReportParameter();
                    reportParameterObj.ID     = 0;
                    reportParameterObj.Report = new GTS.Clock.Model.Report.Report()
                    {
                        ID = ReportID
                    };
                    reportParameterObj.Name = item.Parameter;
                    reportParameterObj.ReportUIParameter = reportParameterDesignedObj.ReportUIParameter;


                    decimal param1Id = reportParameterBusiness.InsertReportParameter(reportParameterObj);
                }
                break;

            case UIActionType.DELETE:
                if (selectedReportID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoReportSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }
                this.ReportBusiness.CheckDeleteAccess();
                ReportID = this.ReportBusiness.DeleteReport(selectedReportID);
                break;
            }


            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            string SuccessMessageBody = string.Empty;
            switch (uam)
            {
            case UIActionType.ADD:
                SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                break;

            case UIActionType.EDIT:
                SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                break;

            case UIActionType.DELETE:
                SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                break;

            default:
                break;
            }
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = ReportID.ToString();
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }