public static bool LoadApplicationConfiguration() { DialogResult result; MerkConfiguration merkConfiguration = LoadMerkConfigurationFile(ref _errorMessage); if (merkConfiguration == null) { result = XtraMessageBox.Show(_errorMessage + "\r\n\r\n" + "The application will exit now", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); switch (result) { case DialogResult.OK: Process.GetCurrentProcess().Kill(); return(false); } } DBCommon.ServerName = merkConfiguration.DBServer; DBCommon.DBName = merkConfiguration.MerkDBName; Organization = (DB_Organization)Convert.ToInt32(merkConfiguration.OrganizationID); if (merkConfiguration.InventoryHousingID != null && !string.IsNullOrWhiteSpace(merkConfiguration.InventoryHousingID)) { ActiveInventoryHousingID = Convert.ToInt32(merkConfiguration.InventoryHousingID); } else { ActiveInventoryHousingID = -1; } if (merkConfiguration.CashBoxID != null && !string.IsNullOrWhiteSpace(merkConfiguration.CashBoxID)) { ActiveCashBoxID = Convert.ToInt32(merkConfiguration.CashBoxID); } else { ActiveCashBoxID = -1; } return(true); }
public static MerkConfiguration LoadMerkConfigurationFile(ref string errorMessage) { MerkConfiguration merkConfiguration = null; if (SaveMerkConfigurationFile()) { merkConfiguration = XMLActions.LoadXmlFile <MerkConfiguration>(MerkConfigurationFilePath); if (string.IsNullOrEmpty(merkConfiguration.DBServer) || string.IsNullOrWhiteSpace(merkConfiguration.DBServer)) { errorMessage = "Please Provide Database Server Name in the MerkConfiguration.xml"; return(null); } if (string.IsNullOrEmpty(merkConfiguration.MerkDBName) || string.IsNullOrWhiteSpace(merkConfiguration.MerkDBName)) { errorMessage = "Please Provide Database Name in the MerkConfiguration.xml"; return(null); } } return(merkConfiguration); }
public static bool SaveMerkConfigurationFile() { try { if (!MerkConfigurationFileExists()) { MerkConfiguration configurationFile = new MerkConfiguration(); configurationFile.DBServer = " "; configurationFile.MerkDBName = " "; configurationFile.OrganizationID = " "; configurationFile.InventoryHousingID = " "; configurationFile.CashBoxID = " "; XMLActions.SaveXmlFile(configurationFile, MerkConfigurationFilePath); } } catch (Exception ex) { MessageBox.Show("MerkConfiguration.xml file is missing." + "\r\n\r\n" + "The application will exit now !", "File Missing", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); Process.GetCurrentProcess().Kill(); } return(true); }
public static bool MerkConfigurationFileExists() { return(MerkConfiguration.Exists()); }