/// <summary>
 /// Generates the matrix for A new user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void GenerateMatrixForANewUser(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         usrPhyStore.AddNew();
         usrPhyStore.UserID = userID;
         usrPhyStore.PhysicalStoreID = phyStore.ID;
         usrPhyStore.CanAccess = false;
         usrPhyStore.IsDefault = false;
         usrPhyStore.Save();
         phyStore.MoveNext();
     }
 }
 public static bool DoesItNeedToBeRefreshed(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         usrPhyStore.LoadAllByUserAndStoreID(userID, phyStore.ID);
         if (usrPhyStore.RowCount == 0)
         {
             return(true);
         }
         phyStore.MoveNext();
     }
     return(false);
 }
 public static bool DoesItNeedToBeRefreshed(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         usrPhyStore.LoadAllByUserAndStoreID(userID, phyStore.ID);
         if (usrPhyStore.RowCount == 0)
         {
             return true;
         }
         phyStore.MoveNext();
     }
     return false;
 }
 /// <summary>
 /// Generates the matrix for A new user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void GenerateMatrixForANewUser(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         usrPhyStore.AddNew();
         usrPhyStore.UserID          = userID;
         usrPhyStore.PhysicalStoreID = phyStore.ID;
         usrPhyStore.CanAccess       = false;
         usrPhyStore.IsDefault       = false;
         usrPhyStore.Save();
         phyStore.MoveNext();
     }
 }
 /// <summary>
 /// Renews the matrix for A user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void RenewMatrixForAUser(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         this.LoadByUserAndStoreID(userID, phyStore.ID);
         if (this.RowCount == 0)
         {
             usrPhyStore.AddNew();
             usrPhyStore.UserID          = userID;
             usrPhyStore.PhysicalStoreID = phyStore.ID;
             usrPhyStore.CanAccess       = false;
             usrPhyStore.IsDefault       = false;
             usrPhyStore.Save();
         }
         phyStore.MoveNext();
     }
 }
 /// <summary>
 /// Renews the matrix for A user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void RenewMatrixForAUser(int userID)
 {
     BLL.PhysicalStore phyStore = new PhysicalStore();
     phyStore.LoadAll();
     while (!phyStore.EOF)
     {
         BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
         this.LoadByUserAndStoreID(userID, phyStore.ID);
         if (this.RowCount == 0)
         {
             usrPhyStore.AddNew();
             usrPhyStore.UserID = userID;
             usrPhyStore.PhysicalStoreID = phyStore.ID;
             usrPhyStore.CanAccess = false;
             usrPhyStore.IsDefault = false;
             usrPhyStore.Save();
         }
         phyStore.MoveNext();
     }
 }
 private void repoItemChkPhysicalStoreDefault_CheckedChanged(object sender, EventArgs e)
 {
     DataRow dr = gridViewUserPhysicalStoreMatrix.GetFocusedDataRow();
     int ID = int.Parse(dr["ID"].ToString());
     BLL.UserPhysicalStore userPhyStore = new UserPhysicalStore();
     userPhyStore.LoadByPrimaryKey(ID);
     userPhyStore.MakeDefault();
     RefreshUserPhysicalStoreGrid(userPhyStore.UserID);
 }
        private void RefreshUserPhysicalStoreGrid(int userID)
        {
            BLL.PhysicalStore phyStores = new PhysicalStore();
            phyStores.LoadAll();
            BLL.UserPhysicalStore userPhyStore = new UserPhysicalStore();
            userPhyStore.LoadAllEntriesByUserID(userID);

            if (BLL.UserPhysicalStore.DoesItNeedToBeRefreshed(userID))
            {
                BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
                usrPhyStore.RenewMatrixForAUser(userID);

            }

            if (userPhyStore.RowCount == 0)
            {
                BLL.UserPhysicalStore usrPhyStore = new UserPhysicalStore();
                usrPhyStore.GenerateMatrixForANewUser(userID);
                RefreshUserPhysicalStoreGrid(userID);
            }
            else if (userPhyStore.RowCount >= phyStores.RowCount)
            {
                grdUserPhysicalStoreMatrix.DataSource = userPhyStore.DefaultView;
                lcUserPhysicalStoreMatrix.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }
            else
            {
                BLL.UserPhysicalStore usrStore = new UserPhysicalStore();
                usrStore.RenewMatrixForAUser(userID);
                RefreshUserPhysicalStoreGrid(userID);
            }
        }