/// <summary>
        /// SaveForEdit
        /// </summary>
        public void SaveForEdit()
        {
            foreach (FmViewTDS.FmViewSortTempRow rowViewSort in (FmViewTDS.FmViewSortTempDataTable)Data.Tables["FmViewSortTemp"])
            {
                FmViewSort fmViewSort = new FmViewSort(null);

                if (!rowViewSort.Deleted && !rowViewSort.InDatabase && rowViewSort.Selected)
                {
                    fmViewSort.InsertDirect(rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID, rowViewSort.Order_, rowViewSort.Deleted);
                }

                if (!rowViewSort.Deleted && rowViewSort.InDatabase && rowViewSort.Selected)
                {
                    FmViewSortGateway fmViewSortGateway = new FmViewSortGateway();
                    fmViewSortGateway.LoadAllByViewIdFmTypeSortId(rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID);

                    int originalViewId = rowViewSort.ViewID;
                    string originalFmType = rowViewSort.FmType;
                    int originalCompanyId = rowViewSort.COMPANY_ID;
                    int originalSortId = rowViewSort.SortID;
                    int originalOrder = fmViewSortGateway.GetOrder(rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID);
                    bool originalDeleted = fmViewSortGateway.GetDeleted(rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID);

                    fmViewSort.UpdateDirect(originalViewId, originalFmType, originalCompanyId, originalSortId, originalOrder, originalDeleted, rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID, rowViewSort.Order_, rowViewSort.Deleted);
                }

                if (rowViewSort.Deleted && rowViewSort.InDatabase && !rowViewSort.Selected)
                {
                    fmViewSort.DeleteDirectForEditView(rowViewSort.ViewID, rowViewSort.FmType, rowViewSort.COMPANY_ID, rowViewSort.SortID);
                }
            }
        }
 /// <summary>
 /// Save
 /// </summary>
 /// <param name="viewId">viewId</param>
 /// <param name="fmType">fmType</param>
 /// <param name="companyId">companyId</param>
 public void Save(int viewId, string fmType, int companyId)
 {
     foreach (FmViewTDS.FmViewSortTempRow rowViewSort in (FmViewTDS.FmViewSortTempDataTable)Data.Tables["FmViewSortTemp"])
     {
         FmViewSort fmViewSort = new FmViewSort(null);
         fmViewSort.InsertDirect(viewId, fmType, companyId, rowViewSort.SortID, rowViewSort.Order_, rowViewSort.Deleted);
     }
 }