private void hmTabControlTools_SelectedPageChanging(object sender, TabPageChangingEventArgs e) { if (e.PrevPage == tpSyncManager) { if (CompanySyncProcess.GetSyncProcessEnum(CompanySyncProcess.NoCompany, EnumSyncType.System) != EnumSyncProcess.NotSyncing) { GuiCommon.ShowMessage("System Sync is broken, please run it again."); e.Cancel = true; return; } var syncStatus = CompanySyncProcess.GetSyncProcessEnum(Company.CurrentId, EnumSyncType.Lookup); if (syncStatus == EnumSyncProcess.LookupSyncing) { GuiCommon.ShowMessage("Lookup Sync is broken, please finish or cancel it."); e.Cancel = true; return; } syncStatus = CompanySyncProcess.GetSyncProcessEnum(Company.CurrentId, EnumSyncType.Core); if (syncStatus == EnumSyncProcess.CoreSending) { GuiCommon.ShowMessage("Core Sync is broken in sending data, please finish or cancel it."); e.Cancel = true; return; } else if (syncStatus == EnumSyncProcess.CoreReceiving) { GuiCommon.ShowMessage("Core Sync is broken in receiving data, please finish or cancel it."); e.Cancel = true; return; } } }
private void VerifiyUser() { if (CompanySyncProcess.GetSyncProcessEnum(CompanySyncProcess.NoCompany, EnumSyncType.System) != EnumSyncProcess.NotSyncing) { GuiCommon.ShowMessage("First time use or sync broken, need to Sync Users."); btnSync.Focus(); return; } if (teUsername.EditValue == null) { GuiCommon.ShowMessage("Please enter a user name."); return; } if (tePassword.EditValue == null) { GuiCommon.ShowMessage("Please enter a password."); return; } IntPtr userHandle = IntPtr.Zero; bool winValid = LogonUser(teUsername.EditValue.ToString(), System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName, tePassword.EditValue.ToString(), 2, 0, ref userHandle); if (!winValid) { GuiCommon.ShowMessage("Failed in windows authentication. Incorrect Username/Password."); return; } int?id = LoginUser.ValidUser(teUsername.EditValue.ToString()); if (id == null) { GuiCommon.ShowMessage("Cannot find this user."); return; } else { LoginUser.CurrUser = LoginUser.GetUser(id.Value); DataManage.UpdateCodeVersion(); if (LoginUser.MaxCodeVersion() != LoginUser.CurrUser.CodeVersion) { GuiCommon.ShowMessage("Code verion is not correct, please log out and restart."); return; } luCompany.Properties.DataSource = Company.List.Where(x => LoginUser.CurrUser.AccessList.Select(a => a.CompanyId).Contains(x.MatchId)).Select(x => new { CompanyID = x.MatchId, CompanyName = x.CompanyName }); if (LoginUser.CurrUser.AccessList.Count == 1) { luCompany.ItemIndex = 0;//autoload the only company } } }
private void ucMain_Load(object sender, EventArgs e) { hmNavigationBar1.SetMOBSecurity(LoginUser.CurrUser.AccessList.Single(x => x.CompanyId == Company.CurrentId).Department, Company.CurrentId, MobileCommon.MobileDB); if (CompanySyncProcess.GetSyncProcessEnum(Company.CurrentId, EnumSyncType.Lookup) != EnumSyncProcess.NotSyncing) { GuiCommon.ShowMessage("Last Lookup Sync was broken, please finish or cancel it."); hmTabControlTop.SelectedTabPage = hmTabPageTools; hmTabControlTools.SelectedTabPage = tpSyncManager; } if (new EnumSyncProcess[] { EnumSyncProcess.NotSyncing, EnumSyncProcess.CoreHalfWay }.Contains(CompanySyncProcess.GetSyncProcessEnum(Company.CurrentId, EnumSyncType.Core)) == false) { GuiCommon.ShowMessage("Last Core Sync was broken, please finish or cancel it."); hmTabControlTop.SelectedTabPage = hmTabPageTools; hmTabControlTools.SelectedTabPage = tpSyncManager; } }