/// <summary>
        /// SaveForEdit
        /// </summary>
        public void SaveForEdit()
        {
            foreach (WorkViewTDS.WorkViewSortTempRow rowViewSort in (WorkViewTDS.WorkViewSortTempDataTable)Data.Tables["WorkViewSortTemp"])
            {
                WorkViewSort workViewSort = new WorkViewSort(null);

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

                if (!rowViewSort.Deleted && rowViewSort.InDatabase && rowViewSort.Selected)
                {
                    WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway();
                    workViewSortGateway.LoadAllByViewIdWorkTypeSortId(rowViewSort.ViewID, rowViewSort.WorkType, rowViewSort.COMPANY_ID, rowViewSort.SortID);

                    int originalViewId = rowViewSort.ViewID;
                    string originalWorkType = rowViewSort.WorkType;
                    int originalCompanyId = rowViewSort.COMPANY_ID;
                    int originalSortId = rowViewSort.SortID;
                    int originalOrder = workViewSortGateway.GetOrder(rowViewSort.ViewID, rowViewSort.WorkType, rowViewSort.COMPANY_ID, rowViewSort.SortID);
                    bool originalDeleted = workViewSortGateway.GetDeleted(rowViewSort.ViewID, rowViewSort.WorkType, rowViewSort.COMPANY_ID, rowViewSort.SortID);

                    workViewSort.UpdateDirect(originalViewId, originalWorkType, originalCompanyId, originalSortId, originalOrder, originalDeleted, rowViewSort.ViewID, rowViewSort.WorkType, rowViewSort.COMPANY_ID, rowViewSort.SortID, rowViewSort.Order_, rowViewSort.Deleted);
                }

                if (rowViewSort.Deleted && rowViewSort.InDatabase && !rowViewSort.Selected)
                {
                    workViewSort.DeleteDirectForEditView(rowViewSort.ViewID, rowViewSort.WorkType, rowViewSort.COMPANY_ID, rowViewSort.SortID);
                }
            }
        }
 /// <summary>
 /// InsertDirect
 /// </summary>
 /// <param name="viewId">viewId</param>
 /// <param name="workType">workType</param>
 /// <param name="companyId">companyId</param>
 /// <param name="sortId">sortId</param>
 /// <param name="order">order</param>
 /// <param name="deleted">deleted</param>
 public void InsertDirect(int viewId, string workType, int companyId, int sortId, int order, bool deleted)
 {
     WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(null);
     workViewSortGateway.Insert(viewId, workType, companyId, sortId, order, deleted);
 }
        /// <summary>
        /// ProcessForEdit
        /// </summary>
        /// <param name="viewId">viewId</param>
        /// <param name="workType">workType</param>
        /// <param name="companyId">companyId</param>
        public void ProcessForEdit(int viewId, string workType, int companyId)
        {
            foreach (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTRow rowViewSort in (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable)Data.Tables["LFS_WORK_TYPE_VIEW_SORT"])
            {
                WorkViewSort workViewSort = new WorkViewSort();
                workViewSort.LoadAllByViewIdWorkTypeSortId(viewId, workType, companyId, rowViewSort.SortID);
                WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(workViewSort.Data);

                if (workViewSort.ExistsByViewIDWorkTypeCompanyIdSortId(viewId, workType, companyId, rowViewSort.SortID))
                {
                    if (rowViewSort.Selected)
                    {
                        Insert(viewId, workType, companyId, rowViewSort.SortID, rowViewSort.Order_, true, true, false);
                    }
                    else
                    {
                        // delete
                        Insert(viewId, workType, companyId, rowViewSort.SortID, 0, false, true, true);
                    }
                }
                else
                {
                    if (rowViewSort.Selected)
                    {
                        Insert(viewId, workType, companyId, rowViewSort.SortID, rowViewSort.Order_, true, false, false);
                    }
                }
            }
        }
 /// <summary>
 /// DeleteDirectForEditView
 /// </summary>
 /// <param name="viewId">viewId</param>
 /// <param name="workType">workType</param>
 /// <param name="companyId">companyId</param>
 /// <param name="sortId">sortId</param>
 public void DeleteDirectForEditView(int viewId, string workType, int companyId, int sortId)
 {
     WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(null);
     workViewSortGateway.DeleteForEditView(viewId, workType, companyId, sortId);
 }
 /// <summary>
 /// DeleteDirect
 /// </summary>
 /// <param name="viewId">viewId</param>
 /// <param name="companyId">companyId</param>
 public void DeleteDirect(int viewId, int companyId)
 {
     WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(null);
     workViewSortGateway.Delete(viewId, companyId);
 }
 /// <summary>
 /// UpdateDirect
 /// </summary>
 /// <param name="originalViewId">originalViewId</param>
 /// <param name="originalWorkType">originalWorkType</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="originalSortId">originalSortId</param>
 /// <param name="originalOrder">originalOrder</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="newViewId">newViewId</param>
 /// <param name="newWorkType">newWorkType</param>
 /// <param name="newCompanyId">newCompanyId</param>
 /// <param name="newSortId">newSortId</param>
 /// <param name="newOrder">newOrder</param>
 /// <param name="newDeleted">newDeleted</param>
 public void UpdateDirect(int originalViewId, string originalWorkType, int originalCompanyId, int originalSortId, int originalOrder, bool originalDeleted, int newViewId, string newWorkType, int newCompanyId, int newSortId, int newOrder, bool newDeleted)
 {
     WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(null);
     workViewSortGateway.Update(originalViewId, originalWorkType, originalCompanyId, originalSortId, originalOrder, originalDeleted, newViewId, newWorkType, newCompanyId, newSortId, newOrder, newDeleted);
 }
 /// <summary>
 /// LoadByViewIdWorkTypeSortId
 /// </summary>
 /// <param name="viewId">viewId</param>
 /// <param name="workType">workType</param>
 /// <param name="companyId">companyId</param>
 /// <param name="sortId">sortId</param>
 public void LoadByViewIdWorkTypeSortId(int viewId,string workType, int companyId, int sortId)
 {
     WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(Data);
     workViewSortGateway.LoadByViewIdWorkTypeSortId(viewId, workType, companyId, sortId);
 }
        /// <summary>
        /// UpdateForEdit
        /// </summary>
        /// <param name="viewId">viewId</param>
        /// <param name="workType">workType</param>
        /// <param name="companyId">companyId</param>
        public void UpdateForEdit(int viewId, string workType, int companyId)
        {
            foreach (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTRow row in (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable)Table)
            {
                if ((row.WorkType == workType) && (row.COMPANY_ID == companyId))
                {
                    WorkViewSort workViewSort = new WorkViewSort();
                    workViewSort.LoadByViewIdWorkTypeSortId(viewId, workType, companyId, row.SortID);
                    WorkViewSortGateway workViewSortGateway = new WorkViewSortGateway(workViewSort.Data);

                    if (workViewSort.ExistsByViewIDWorkTypeCompanyIdSortId(viewId, workType, companyId, row.SortID))
                    {
                        row.Selected = true;
                        row.Order_ = workViewSortGateway.GetOrder(viewId, workType, companyId, row.SortID);
                    }
                    else
                    {
                        row.Selected = false;
                        row.SetOrder_Null();
                    }
                }
            }
        }