private bool ValidateFields() { try { if (txtBrowser.Text == "") { cmnService.J_UserMessage("Please choose the database"); BtnBrowser.Select(); return(false); } if (cmnService.J_IsFileExist(txtBrowser.Text) == false) { cmnService.J_UserMessage("Database doesn't exist in selected path"); BtnBrowser.Select(); return(false); } if (cmnService.J_GetFileName(txtBrowser.Text).ToUpper() != J_Var.J_pMsAccessDatabaseName.ToUpper()) { cmnService.J_UserMessage("Invalid Database."); BtnBrowser.Select(); return(false); } if (dmlService.J_ValidateConnection(txtBrowser.Text, J_Var.J_pMsAccessDatabasePassword) == false) { cmnService.J_UserMessage("Connection Failed...."); BtnBrowser.Focus(); return(false); } return(true); } catch { cmnService.J_UserMessage("Verify the Config Information and Try again.... !!"); BtnBrowser.Focus(); return(false); } }
private void BtnSubmit_Click(object sender, EventArgs e) { try { // all validations if (ValidateFields() == false) { return; } string strDatabasePath = cmnService.J_GetDirectoryName(txtBrowser.Text); // create the connection xml file Hashtable nameValue = new Hashtable(); nameValue.Add("SERVERNAME", ""); nameValue.Add("DATABASENAME", strDatabasePath); nameValue.Add("USERNAME", J_Var.J_pMsAccessDatabaseName); nameValue.Add("PASSWORD", J_Var.J_pMsAccessDatabasePassword); XMLService objxml = new XMLService(); objxml.J_CreateXMLFile(nameValue, Application.StartupPath + "/" + J_Var.J_pXmlConnectionFileName); if (dmlService.J_IsDatabaseObjectExist("MST_FAYEAR") == true) { // Close & Dispose the MstLogin Class this.Close(); this.Dispose(); // Close & Dispose the main Class if (J_Var.J_pLoginStatus == 1) { J_Var.frmMain.Close(); J_Var.frmMain.Dispose(); } if (dmlService.J_IsRecordExist("MST_FAYEAR") == true) { dmlService.Dispose(); if (J_Var.J_pLoginScreen == J_LoginScreen.YES) { CmnLogin frm = new CmnLogin(); frm.ShowDialog(); frm.Dispose(); } else if (J_Var.J_pLoginScreen == J_LoginScreen.NO) { J_Var.frmMain = new mdiBillingSystem(); J_Var.frmMain.ShowDialog(); } } else { dmlService.Dispose(); CmnCreate1stFAYear frm = new CmnCreate1stFAYear(); frm.ShowDialog(); frm.Dispose(); } return; } else { dmlService.Dispose(); cmnService.J_UserMessage("Invalid database structure.\nPlease check the database"); BtnBrowser.Focus(); return; } } catch (Exception err_handler) { dmlService.Dispose(); cmnService.J_UserMessage(err_handler.Message); } }