private string GetOrderByClause()
        {
            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
            workTypeViewConditionGateway.LoadByWorkTypeConditionId(workType, int.Parse(ddlCondition1.SelectedValue), companyId);

            string conditionValue1 = workTypeViewConditionGateway.GetColumn_(workType, companyId, int.Parse(ddlCondition1.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "LFS_ASSET_SEWER_SECTION") tableName = "LASS";
            if (tableName == "LFS_WORK_POINT_REPAIRS") tableName = "LWPR";

            // Get order by clause
            string orderBy = "";

            if (columnName == "Date")
            {
                switch (conditionValue1)
                {
                    case "ProposedLiningDate":
                        orderBy = "LWPR.ProposedLiningDate DESC";
                        break;

                    case "DeadlineLiningDate":
                        orderBy = "LWPR.DeadlineLiningDate DESC";
                        break;

                    case "FinalVideoDate":
                        orderBy = "LWPR.FinalVideoDate DESC";
                        break;

                    default:
                        orderBy = "LWPR.WorkID ASC";
                        break;
                }
            }
            else
            {
                orderBy = tableName + "." + columnName;
            }

            return orderBy;
        }
        private string GetOrderByClause()
        {
            // Get tableName
            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "LFS_ASSET_SEWER_MH") tableName = "LASMH";
            if (tableName == "LFS_WORK_MANHOLE_REHABILITATION") tableName = "LWMR";
            if (tableName == "LFS_WORK_MANHOLE_REHABILITATION_BATCH") tableName = "LWMRB";
            if (tableName == "AM_ASSET_SEWER_MH") tableName = "AASMH";

            WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
            workTypeViewConditionGateway.LoadByWorkTypeConditionId(workType, int.Parse(ddlCondition1.SelectedValue), companyId);

            string conditionValue = workTypeViewConditionGateway.GetColumn_(workType, companyId, int.Parse(ddlCondition1.SelectedValue));

            // Get order by clause
            string orderBy = "";
            if (columnName == "Date")
            {
                switch (conditionValue)
                {
                    case "PreppedDate":
                        orderBy = "LWMR.PreppedDate DESC";
                        break;

                    case "SprayedDate":
                        orderBy = "LWMR.SprayedDate DESC";
                        break;

                    case "Date":
                        orderBy = "LWMRB.Date DESC";
                        break;

                    default:
                        orderBy = "AASMH.MHID ASC";
                        break;
                }
            }
            else
            {
                orderBy = tableName + "." + columnName;
            }

            return orderBy;
        }
        private string GetOrderByClause()
        {
            // For tableName
            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
            workTypeViewConditionGateway.LoadByWorkTypeConditionId(workType, int.Parse(ddlCondition1.SelectedValue), companyId);

            string conditionValue = workTypeViewConditionGateway.GetColumn_(workType, companyId, int.Parse(ddlCondition1.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "AM_ASSET_SEWER_LATERAL") tableName = "AASL";
            if (tableName == "LFS_ASSET_SEWER_SECTION") tableName = "LASS";
            if (tableName == "LFS_WORK_JUNCTIONLINING_SECTION") tableName = "LWJLS";
            if (tableName == "LFS_WORK_JUNCTIONLINING_LATERAL") tableName = "LWJLL";

            string orderBy = "";

            if (columnName == "Date")
            {
                switch (conditionValue)
                {
                    case "VideoInspection":
                        orderBy = "LWJLL.VideoInspection DESC";
                        break;

                    case "PipeLocated":
                        orderBy = "LWJLL.PipeLocated DESC";
                        break;

                    case "ServicesLocated":
                        orderBy = "LWJLL.ServicesLocated DESC";
                        break;

                    case "CoInstalled":
                        orderBy = "LWJLL.CoInstalled DESC";
                        break;

                    case "BackfilledConcrete":
                        orderBy = "LWJLL.BackfilledConcrete DESC";
                        break;

                    case "BackfilledSoil":
                        orderBy = "LWJLL.BackfilledSoil DESC";
                        break;

                    case "Grouted":
                        orderBy = "LWJLL.Grouted DESC";
                        break;

                    case "Cored":
                        orderBy = "LWJLL.Cored DESC";
                        break;

                    case "Prepped":
                        orderBy = "LWJLL.Prepped DESC";
                        break;

                    case "Measured":
                        orderBy = "LWJLL.Measured DESC";
                        break;

                    case "InProcess":
                        orderBy = "LWJLL.InProcess DESC";
                        break;

                    case "InStock":
                        orderBy = "LWJLL.InStock DESC";
                        break;

                    case "Delivered":
                        orderBy = "LWJLL.Delivered DESC";
                        break;

                    case "PreVideo":
                        orderBy = "LWJLL.PreVideo DESC";
                        break;

                    case "LinerInstalled":
                        orderBy = "LWJLL.LinerInstalled DESC";
                        break;

                    case "FinalVideo":
                        orderBy = "LWJLL.FinalVideo DESC";
                        break;

                    case "CoCutDown":
                        orderBy = "LWJLL.CoCutDown DESC";
                        break;

                    case "FinalRestoration":
                        orderBy = "LWJLL.FinalRestoration DESC";
                        break;

                    case "NoticeDelivered":
                        orderBy = "LWJLL.NoticeDelivered DESC";
                        break;

                    default:
                        orderBy = "AASS.FlowOrderID ASC";
                        break;
                }
            }
            else
            {
                orderBy = tableName + "." + columnName;
            }

            return orderBy;
        }
        private string GetOrderByClause()
        {
            // Get tableName
            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "LFS_WORK_REHABASSESSMENT") tableName = "LWR";
            if (tableName == "LFS_ASSET_SEWER_SECTION") tableName = "LASS";
            if (tableName == "LFS_WORK") tableName = "LW";

            // Get order by clause
            string orderBy = "";
            orderBy = tableName + "." + columnName;
            return orderBy;
        }
        private string GetOrderByClause()
        {
            // Get tableName
            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "LFS_WORK_FULLLENGTHLINING") tableName = "LWF";
            if (tableName == "LFS_ASSET_SEWER_SECTION") tableName = "LASS";

            WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway();
            workTypeViewConditionGateway.LoadByWorkTypeConditionId(workType, int.Parse(ddlCondition1.SelectedValue), companyId);

            string conditionValue = workTypeViewConditionGateway.GetColumn_(workType, companyId, int.Parse(ddlCondition1.SelectedValue));

            // Get order by clause
            string orderBy = "";
            if (columnName == "Date")
            {
                switch (conditionValue)
                {
                    case "ProposedLiningDate":
                        orderBy = "LWF.ProposedLiningDate DESC";
                        break;

                    case "DeadlineLiningDate":
                        orderBy = "LWF.DeadlineLiningDate DESC";
                        break;

                    case "P1Date":
                        orderBy = "LWF.P1Date DESC";
                        break;

                    case "M1Date":
                        orderBy = "LWF.M1Date DESC";
                        break;

                    case "M2Date":
                        orderBy = "LWF.M2Date DESC";
                        break;

                    case "InstallDate":
                        orderBy = "LWF.InstallDate DESC";
                        break;

                    case "FinalVideoDate":
                        orderBy = "LWF.FinalVideoDate DESC";
                        break;

                    case "PreFlushDate":
                        orderBy = "LWR.PreFlushDate DESC";
                        break;

                    case "PreVideoDate":
                        orderBy = "LWR.PreVideoDate DESC";
                        break;

                    default:
                        orderBy = "AASS.FlowOrderID ASC";
                        break;
                }
            }
            else
            {
                orderBy = tableName + "." + columnName;
            }

            return orderBy;
        }
        private string GetOrderByClause()
        {
            // For tableName
            string workType = "Junction Lining Section";
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway();
            workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            string tableName = workTypeViewSortGateway.GetTable_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));
            string columnName = workTypeViewSortGateway.GetColumn_(workType, companyId, int.Parse(ddlSortBy.SelectedValue));

            if (tableName == "AM_ASSET_SEWER_SECTION") tableName = "AASS";
            if (tableName == "LFS_WORK_JUNCTIONLINING_SECTION") tableName = "LWJLS";
            if (tableName == "LFS_ASSET_SEWER_SECTION") tableName = "LASS";

            string orderBy = tableName + "." + columnName;

            return orderBy;
        }
 /// <summary>
 /// LoadByWorkTypeSortId
 /// </summary>
 /// <param name="workType">workType</param>
 /// <param name="companyId">companyId</param>
 /// <param name="sortId">sortId</param>
 public void LoadByWorkTypeSortId(string workType, int companyId, int sortId)
 {
     WorkTypeViewSortGateway workTypeViewSortGateway = new WorkTypeViewSortGateway(Data);
     workTypeViewSortGateway.LoadByWorkTypeSortId(workType, companyId, sortId);
 }