private void cboAuthenticationType_SelectionChangeCommitted(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (cboAuthenticationType.SelectedIndex == 0) { clsDMCommon.ObjCon.ConnectionString = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True"; clsConnection_DAL ObjDAL = new clsConnection_DAL(); ObjDAL.SetConnectionString(clsDMCommon.ObjCon.ConnectionString); if (ObjDAL.IsDatabaseExist(ClientDBName)) { if (!System.IO.Directory.Exists("AppConfig")) { System.IO.Directory.CreateDirectory("AppConfig"); File.WriteAllText("AppConfig\\ServerConfig.sc", ObjUtil.Encrypt(clsDMCommon.ObjCon.ConnectionString, true)); } clsUtility.ShowInfoMessage("Database is already exist.\n please select client", clsUtility.strProjectTitle); IsConnect = false; } else { grpDBRestore.Enabled = true; txtDabasePath.Focus(); } } else if (cboAuthenticationType.SelectedIndex == 1) { grpDBRestore.Enabled = false; ConnectToDB(clsDMCommon.strServerName, clsDMCommon.strUserID, clsDMCommon.strUserPassword, ClientDBName); String conn = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True"; String EncrConn = ObjUtil.Encrypt(conn, true); if (!System.IO.Directory.Exists("AppConfig")) { System.IO.Directory.CreateDirectory("AppConfig"); File.WriteAllText("AppConfig\\ServerConfig.sc", EncrConn); } ObjDAL = new clsConnection_DAL(true); //DataTable dt = ObjDAL.GetDataCol(ClientDBName + ".dbo.RegistrationDetails", "RegistrationID", "PcName = '"+ Environment.MachineName+"'", null); int a = ObjDAL.CountRecords(ClientDBName + ".dbo.RegistrationDetails", "PcName = '" + Environment.MachineName + "'"); //if (dt == null || dt.Rows.Count == 0) if (a == 0) { InsertClientRegistration(); } else { clsUtility.ShowInfoMessage("Client is already Registered.", clsUtility.strProjectTitle); Application.Exit(); } } this.Cursor = Cursors.Default; }