예제 #1
0
파일: DBManager.cs 프로젝트: tordf/iLabs
        public static USSInfo GetUSSInfo(string guid)
        {
            USSInfo ussInfo = null;

            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            // create sql command
            // command executes the "RetrieveUSSInfoByID" stored procedure
            DbCommand cmd = FactoryDB.CreateCommand("USSInfo_RetrieveByGUID", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@guid", guid, DbType.AnsiString, 50));

            //execute the command
            try
            {
                connection.Open();

                DbDataReader dataReader = null;
                dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    ussInfo = new USSInfo();
                    if (dataReader[0] != System.DBNull.Value)
                        ussInfo.ussInfoId = dataReader.GetInt32(0);
                    if (dataReader[1] != System.DBNull.Value)
                        ussInfo.ussGuid = dataReader.GetString(1);
                    if (dataReader[2] != System.DBNull.Value)
                        ussInfo.ussName = dataReader.GetString(2);
                    if (dataReader[3] != System.DBNull.Value)
                        ussInfo.ussUrl = dataReader.GetString(3);
                    if (dataReader[4] != System.DBNull.Value)
                        ussInfo.couponId = dataReader.GetInt64(4);
                    if (dataReader[5] != System.DBNull.Value)
                        ussInfo.domainGuid = dataReader.GetString(5);

                }
                dataReader.Close();

            }

            catch (Exception ex)
            {
                throw new Exception("Exception thrown in get ussInfos", ex);
            }
            finally
            {
                connection.Close();
            }
            return ussInfo;
        }
예제 #2
0
파일: DBManager.cs 프로젝트: tordf/iLabs
        /// <summary>
        /// Returns an array of the immutable USSInfo objects that correspond to the supplied USS information IDs. 
        /// </summary>
        /// <param name="ussInfoIDs"></param>
        /// <returns></returns>An array of immutable objects describing the specified USS information; if the nth ussInfoID does not correspond to a valid experiment scheduling property, the nth entry in the return array will be null
        public static USSInfo[] GetUSSInfos(int[] ussInfoIDs)
        {
            List<USSInfo> ussInfos = new List<USSInfo>();

            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            // create sql command
            // command executes the "RetrieveUSSInfoByID" stored procedure
            DbCommand cmd = FactoryDB.CreateCommand("USSInfo_RetrieveByID", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@ussInfoID", null, DbType.Int32));
            //execute the command
            try
            {
                connection.Open();
                for(int i=0;i<ussInfoIDs.Length;i++)
                {
                    // populate the parameters
                    cmd.Parameters["@ussInfoID"].Value = ussInfoIDs[i];
                    DbDataReader dataReader = null;
                    dataReader=cmd.ExecuteReader();
                    while(dataReader.Read())
                    {
                        USSInfo ussInfo = new USSInfo();
                        ussInfo.ussInfoId=ussInfoIDs[i];
                        if(dataReader[0] != System.DBNull.Value )
                            ussInfo.ussGuid=dataReader.GetString(0);
                        if(dataReader[1] != System.DBNull.Value )
                            ussInfo.ussName=dataReader.GetString(1);
                        if(dataReader[2] != System.DBNull.Value )
                            ussInfo.ussUrl=dataReader.GetString(2);
                        if (dataReader[3] != System.DBNull.Value)
                            ussInfo.couponId = dataReader.GetInt64(3);
                        if (dataReader[4] != System.DBNull.Value)
                            ussInfo.domainGuid = dataReader.GetString(4);
                        ussInfos.Add(ussInfo);
                    }
                    dataReader.Close();
                }
            }

            catch (Exception ex)
            {
                throw new Exception("Exception thrown in get ussInfos",ex);
            }
            finally
            {
                connection.Close();
            }
            return ussInfos.ToArray();
        }
예제 #3
0
 /// <summary>
 /// This method fires when the USS dropdown changes.
 /// If the index is greater than zero, the specified USS 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 ddlUSS_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (ddlUSS.SelectedIndex == 0)
     // prepare for a new record
     {
         ClearFormFields();
         SetReadOnly(false);
     }
     else
     //retrieve an existing record
     {
         USSInfo ui = new USSInfo();
         ui = ussInfos[ddlUSS.SelectedIndex - 1];
         txtUSSID.Text = ui.ussGuid;
         txtUSSName.Text = ui.ussName;
         txtUSSURL.Text = ui.ussUrl;
         // Make the USSID field ReadOnly
         SetReadOnly(true);
     }
 }