/// <summary> /// Returns an array of the immutable LSSInfo objects that correspond to the supplied lssInfo IDs. /// </summary> /// <param name="lssInfoIds"></param> /// <returns></returns> public static LSSInfo[] GetLSSInfos(int[] lssInfoIds) { LSSInfo[] lssInfos=new LSSInfo[lssInfoIds.Length]; for(int i=0; i<lssInfoIds.Length;i++) { lssInfos[i]=new LSSInfo(); } // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command // command executes the "RetrieveLSSInfoByID" stored procedure DbCommand cmd = FactoryDB.CreateCommand("RetrieveLSSInfoByID", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@lssInfoId", null, DbType.Int32)); //execute the command try { connection.Open(); for(int i=0;i<lssInfoIds.Length;i++) { // populate the parameters cmd.Parameters["@lssInfoId"].Value = lssInfoIds[i]; DbDataReader dataReader = null; dataReader=cmd.ExecuteReader(); while(dataReader.Read()) { lssInfos[i].lssInfoId=lssInfoIds[i]; if(dataReader[0] != System.DBNull.Value ) lssInfos[i].lssGuid=dataReader.GetString(0); if(dataReader[1] != System.DBNull.Value ) lssInfos[i].lssName=dataReader.GetString(1); if(dataReader[2] != System.DBNull.Value ) lssInfos[i].lssUrl=dataReader.GetString(2); } dataReader.Close(); } } catch (Exception ex) { throw new Exception("Exception thrown in get lssInfo",ex); } finally { connection.Close(); } return lssInfos; }
/// <summary> /// Returns a LSSInfo object that correspond to the supplied lssInfo Guid. /// </summary> /// <param name="connection">An open connection</param> /// <param name="lssguid"></param> /// <returns></returns> public LSSInfo GetLSSInfo( DbConnection connection, string lssGuid) { LSSInfo lssInfo = null; // create sql command DbCommand cmd = FactoryDB.CreateCommand("RetrieveLSSInfoByGUID", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(FactoryDB.CreateParameter("@lssGuid", lssGuid, DbType.AnsiString, 50)); //execute the command try { DbDataReader dataReader = null; dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { lssInfo = new LSSInfo(); lssInfo.lssInfoId = dataReader.GetInt32(0); if (!dataReader.IsDBNull(1)) lssInfo.lssGuid = dataReader.GetString(1); if (!dataReader.IsDBNull(2)) lssInfo.lssName = dataReader.GetString(2); if (!dataReader.IsDBNull(3)) lssInfo.lssUrl = dataReader.GetString(3); lssInfo.revokeCouponID = dataReader.GetInt64(4); if (!dataReader.IsDBNull(5)) lssInfo.domainGuid = dataReader.GetString(5); } dataReader.Close(); } catch (Exception ex) { throw new Exception("Exception thrown in get lssInfo", ex); } return lssInfo; }
/// <summary> /// Returns an array of the immutable LSSInfo objects that correspond to the supplied lssInfo IDs. /// </summary> /// <param name="lssInfoIds"></param> /// <returns></returns> public static LSSInfo GetLSSInfo(string lssGuid) { LSSInfo lssInfo = new LSSInfo(); // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command DbCommand cmd = FactoryDB.CreateCommand("RetrieveLSSInfoByGUID", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@lssGuid", lssGuid, DbType.AnsiString, 50)); //execute the command try { connection.Open(); DbDataReader dataReader = null; dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { lssInfo.lssInfoId = dataReader.GetInt32(0); if (dataReader[1] != System.DBNull.Value) lssInfo.lssGuid = dataReader.GetString(1); if (dataReader[2] != System.DBNull.Value) lssInfo.lssName = dataReader.GetString(2); if (dataReader[3] != System.DBNull.Value) lssInfo.lssUrl = dataReader.GetString(3); } dataReader.Close(); } catch (Exception ex) { throw new Exception("Exception thrown in get lssInfo", ex); } finally { connection.Close(); } return lssInfo; }
/// <summary> /// This method fires when the LSS dropdown changes. /// If the index is greater than zero, the specified LSS will be looked up /// and its values will be used to populate the text fields on the form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlLSS_SelectedIndexChanged(object sender, System.EventArgs e) { if (ddlLSS.SelectedIndex == 0) // prepare for a new record { ClearFormFields(); SetReadOnly(false); } else //retrieve an existing record { LSSInfo ui = new LSSInfo(); ui = lssInfos[ddlLSS.SelectedIndex - 1]; txtLSSID.Text = ui.lssGuid; txtLSSName.Text = ui.lssName; txtLSSURL.Text = ui.lssUrl; // Make the LSSID field ReadOnly SetReadOnly(true); } }