public bool AddAward(Int64 subjectid, string label, string institution, string startdate, string enddate, XmlDocument PropertyListXML) { ActivityLog(PropertyListXML, subjectid, label, institution); bool error = false; try { StoreAwardReceiptRequest sarr = new StoreAwardReceiptRequest(); sarr.AwardOrHonorForID = new StoreAwardReceiptParam(); sarr.AwardOrHonorForID.Value = subjectid; sarr.AwardOrHonorForID.ParamOrdinal = 0; sarr.Label = new StoreAwardReceiptParam(); sarr.Label.Value = label; sarr.Label.ParamOrdinal = 1; sarr.AwardConferedBy = new StoreAwardReceiptParam(); sarr.AwardConferedBy.Value = institution; sarr.AwardConferedBy.ParamOrdinal = 2; sarr.StartDate = new StoreAwardReceiptParam(); sarr.StartDate.Value = startdate; sarr.StartDate.ParamOrdinal = 3; sarr.EndDate = new StoreAwardReceiptParam(); sarr.EndDate.Value = enddate; sarr.EndDate.ParamOrdinal = 4; error = this.StoreAwardReceipt(sarr); } catch (Exception e) { Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace); throw new Exception(e.Message); } return error; }
private bool StoreAwardReceipt(StoreAwardReceiptRequest sarr) { SessionManagement sm = new SessionManagement(); string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; SqlConnection dbconnection = new SqlConnection(connstr); SqlParameter[] param = new SqlParameter[sarr.Length]; bool error = false; try { dbconnection.Open(); if (sarr.ExistingAwardReceiptURI != null) param[sarr.ExistingAwardReceiptURI.ParamOrdinal] = new SqlParameter("@ExistingAwardReceiptURI", sarr.ExistingAwardReceiptURI.Value); if (sarr.AwardOrHonorForID != null) param[sarr.AwardOrHonorForID.ParamOrdinal] = new SqlParameter("@awardOrHonorForID", Convert.ToInt64(sarr.AwardOrHonorForID.Value)); if (sarr.Label != null) param[sarr.Label.ParamOrdinal] = new SqlParameter("@Label", sarr.Label.Value.ToString()); if (sarr.AwardConferedBy != null) param[sarr.AwardConferedBy.ParamOrdinal] = new SqlParameter("@awardConferredBy", sarr.AwardConferedBy.Value.ToString()); if (sarr.StartDate != null) param[sarr.StartDate.ParamOrdinal] = new SqlParameter("@startDate", sarr.StartDate.Value.ToString()); if (sarr.EndDate != null) param[sarr.EndDate.ParamOrdinal] = new SqlParameter("@endDate", sarr.EndDate.Value.ToString()); param[sarr.Length - 3] = new SqlParameter("@sessionID", sm.Session().SessionID); param[sarr.Length - 2] = new SqlParameter("@error", null); param[sarr.Length - 2].DbType = DbType.Boolean; param[sarr.Length - 2].Direction = ParameterDirection.Output; param[sarr.Length - 1] = new SqlParameter("@nodeid", null); param[sarr.Length - 1].DbType = DbType.Int64; param[sarr.Length - 1].Direction = ParameterDirection.Output; SqlCommand comm = GetDBCommand(ref dbconnection, "[Edit.Module].[CustomEditAwardOrHonor.StoreItem]", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param); //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value. ExecuteSQLDataCommand(comm); comm.Connection.Close(); if (dbconnection.State != ConnectionState.Closed) dbconnection.Close(); error = Convert.ToBoolean(param[sarr.Length - 2].Value); } catch (Exception e) { Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace); throw new Exception(e.Message); } return error; }
public bool UpdateAward(string subjecturi, string label, string institution, string startdate, string enddate) { bool error = false; try { StoreAwardReceiptRequest sarr = new StoreAwardReceiptRequest(); sarr.ExistingAwardReceiptURI = new StoreAwardReceiptParam(); sarr.ExistingAwardReceiptURI.Value = subjecturi; sarr.ExistingAwardReceiptURI.ParamOrdinal = 0; sarr.Label = new StoreAwardReceiptParam(); sarr.Label.Value = label; sarr.Label.ParamOrdinal = 1; sarr.AwardConferedBy = new StoreAwardReceiptParam(); sarr.AwardConferedBy.Value = institution; sarr.AwardConferedBy.ParamOrdinal = 2; sarr.StartDate = new StoreAwardReceiptParam(); sarr.StartDate.Value = startdate; sarr.StartDate.ParamOrdinal = 3; sarr.EndDate = new StoreAwardReceiptParam(); sarr.EndDate.Value = enddate; sarr.EndDate.ParamOrdinal = 4; sarr.AwardOrHonorForID = new StoreAwardReceiptParam(); sarr.AwardOrHonorForID.Value = this.GetStoreNode(subjecturi).ToString(); sarr.AwardOrHonorForID.ParamOrdinal = 5; error = this.StoreAwardReceipt(sarr); } catch (Exception e) { Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace); throw new Exception(e.Message); } return error; }