public string[] UpdateGridOrder_DesignedReportsSelectColumnPage(string Type, string OrderRow, string ReportID)
    {
        this.InitializeCulture();

        string[] retMessage = new string[6];

        try
        {
            decimal                      reportId            = int.Parse(this.StringBuilder.CreateString(ReportID), CultureInfo.InvariantCulture);
            int                          selectedColumnOrder = int.Parse(this.StringBuilder.CreateString(OrderRow), CultureInfo.InvariantCulture);
            ActionGridRowOrder           type       = (ActionGridRowOrder)Enum.Parse(typeof(ActionGridRowOrder), this.StringBuilder.CreateString(Type));
            IList <DesignedReportColumn> columnList = DesignedReportsColumnBusiness.GetDesignedReportsColumnsByReportID(reportId);
            GTS.Clock.Model.Report.DesignedReportColumn selectedColumn = columnList.Where(s => s.Order == selectedColumnOrder).FirstOrDefault();
            GTS.Clock.Model.Report.DesignedReportColumn targetColumn   = new GTS.Clock.Model.Report.DesignedReportColumn();
            int changeCountColumnOrder = 0;
            switch (type)
            {
            case ActionGridRowOrder.Up:
                targetColumn           = columnList.Where(t => t.Order < selectedColumnOrder).OrderByDescending(m => m.Order).FirstOrDefault();
                changeCountColumnOrder = selectedColumnOrder - targetColumn.Order;
                selectedColumn.Order   = (Int16)(selectedColumn.Order - changeCountColumnOrder);
                targetColumn.Order     = (Int16)(targetColumn.Order + changeCountColumnOrder);

                break;

            case ActionGridRowOrder.Down:
                targetColumn           = columnList.Where(t => t.Order > selectedColumnOrder).OrderBy(m => m.Order).FirstOrDefault();
                changeCountColumnOrder = targetColumn.Order - selectedColumnOrder;
                selectedColumn.Order   = (Int16)(selectedColumn.Order + changeCountColumnOrder);
                targetColumn.Order     = (Int16)(targetColumn.Order - changeCountColumnOrder);
                break;

            default:

                break;
            }
            if (targetColumn != null)
            {
                decimal targetId = DesignedReportsColumnBusiness.UpdateColumn(targetColumn);
            }
            decimal columnId = DesignedReportsColumnBusiness.UpdateColumn(selectedColumn);

            UIActionType uam = UIActionType.EDIT;



            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] = columnId.ToString();
            retMessage[4] = selectedColumn.Order.ToString();
            retMessage[5] = targetColumn.Order.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);
        }
    }
    public string[] UpdateColumn_DesignedReportsSelectColumnPage(string state, string SelectedColumnID, string Title, string Active, string ReportID, string ConceptID, string Order, string ColumnType, string TrafficColumnsCount, string KeyColumn)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            decimal      ColumnID            = 0;
            decimal      selectedColumnID    = decimal.Parse(this.StringBuilder.CreateString(SelectedColumnID), CultureInfo.InvariantCulture);
            string       title               = this.StringBuilder.CreateString(Title);
            bool         active              = Convert.ToBoolean(this.StringBuilder.CreateString(Active) == "" ? "false" : this.StringBuilder.CreateString(Active));
            decimal      reportID            = decimal.Parse(this.StringBuilder.CreateString(ReportID), CultureInfo.InvariantCulture);
            decimal      fieldId             = decimal.Parse(this.StringBuilder.CreateString(ConceptID), CultureInfo.InvariantCulture);
            Int16        order               = Int16.Parse(this.StringBuilder.CreateString(Order));
            int          trafficColumnsCount = int.Parse(this.StringBuilder.CreateString(TrafficColumnsCount), CultureInfo.InvariantCulture);
            bool         isConcept           = false;
            UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());
            DesignedReportTrafficKeyColumn keyColumn = DesignedReportTrafficKeyColumn.AllTraffic;
            GTS.Clock.Model.Report.DesignedReportColumn columnObj = new GTS.Clock.Model.Report.DesignedReportColumn();
            columnObj.ID = selectedColumnID;
            GTS.Clock.Model.Report.Report reportObj = new GTS.Clock.Model.Report.Report();
            reportObj.ID     = reportID;
            columnObj.Report = reportObj;
            if (uam != UIActionType.DELETE)
            {
                DesignedReportColumnType columnType = DesignedReportColumnType.None;
                if (ColumnType != string.Empty)
                {
                    columnType = (DesignedReportColumnType)Enum.Parse(typeof(DesignedReportColumnType), this.StringBuilder.CreateString(ColumnType));
                }
                if (columnType == DesignedReportColumnType.Traffic)
                {
                    keyColumn = (DesignedReportTrafficKeyColumn)Enum.Parse(typeof(DesignedReportTrafficKeyColumn), this.StringBuilder.CreateString(KeyColumn));
                }

                GTS.Clock.Model.Concepts.SecondaryConcept conceptObj    = null;
                DesignedReportPersonInfoColumn            personInfoObj = null;
                DesignedReportTrafficColumn trafficObj          = null;
                PersonParamField            personParamFieldObj = null;
                switch (columnType)
                {
                case DesignedReportColumnType.Concept:
                    conceptObj           = new SecondaryConcept();
                    conceptObj.ID        = fieldId;
                    columnObj.ColumnType = DesignedReportColumnType.Concept;
                    isConcept            = true;

                    break;

                case DesignedReportColumnType.Traffic:
                    trafficObj           = new DesignedReportTrafficColumn();
                    trafficObj.ID        = fieldId;
                    trafficObj.Key       = keyColumn;
                    columnObj.ColumnType = DesignedReportColumnType.Traffic;

                    break;

                case DesignedReportColumnType.PersonInfo:
                    personInfoObj        = new DesignedReportPersonInfoColumn();
                    personInfoObj.ID     = fieldId;
                    columnObj.ColumnType = DesignedReportColumnType.PersonInfo;
                    break;

                case DesignedReportColumnType.PersonParam:
                    personParamFieldObj    = new PersonParamField();
                    personParamFieldObj.ID = fieldId;
                    columnObj.ColumnType   = DesignedReportColumnType.PersonParam;
                    break;

                default:
                    break;
                }



                columnObj.Title              = title;
                columnObj.Active             = active;
                columnObj.Concept            = conceptObj;
                columnObj.PersonInfo         = personInfoObj;
                columnObj.Traffic            = trafficObj;
                columnObj.PersonParam        = personParamFieldObj;
                columnObj.Order              = order;
                columnObj.IsConcept          = isConcept;
                columnObj.TrafficColumnCount = trafficColumnsCount;
                if (uam != UIActionType.EDIT)
                {
                    IList <GTS.Clock.Model.Report.DesignedReportColumn> designedReportColumnList = DesignedReportsColumnBusiness.GetDesignedReportsColumnsByReportID(reportID);
                    Int16 lastOrder = 0;
                    if (designedReportColumnList.Count > 0)
                    {
                        lastOrder = designedReportColumnList.OrderByDescending(o => o.Order).FirstOrDefault().Order;
                    }

                    columnObj.Order = (Int16)(lastOrder + 1);
                }
            }

            switch (uam)
            {
            case UIActionType.ADD:

                ColumnID = this.DesignedReportsColumnBusiness.InsertColumn(columnObj);

                break;

            case UIActionType.EDIT:
                if (selectedColumnID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoColumnSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }
                ColumnID = this.DesignedReportsColumnBusiness.UpdateColumn(columnObj);
                break;

            case UIActionType.DELETE:
                if (selectedColumnID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoColumnSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }
                ColumnID = this.DesignedReportsColumnBusiness.DeleteColumn(columnObj);
                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] = ColumnID.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);
        }
    }