コード例 #1
0
        /// <summary>
        /// UpdateInsert the Document Upload record
        /// </summary>
        /// <param name="DocumentUploadBO"></param>
        /// <returns>int</returns>
        public void UpdateInsert(DocumentUploadBO duBO)
        {
            // Define Constants
            const string sp = "dbo.Update_Insert_Document_Upload";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            try
            {
                _DB.AddInParameter(dbCommand, "Project_Id", DbType.Int32, duBO.Project_Id);
                _DB.AddInParameter(dbCommand, "Project_Name", DbType.String, duBO.Project_Name);
                _DB.AddInParameter(dbCommand, "Upload_Criteria_Id", DbType.Int32, duBO.Upload_Criteria_Id);
                _DB.AddInParameter(dbCommand, "Effective_Date", DbType.DateTime, duBO.Effective_Date);
                _DB.AddInParameter(dbCommand, "Ack_Due_Date", DbType.DateTime, duBO.Ack_Due_Date);
                _DB.AddInParameter(dbCommand, "Primary_Barcode", DbType.String, duBO.Primary_Barcode);
                _DB.AddInParameter(dbCommand, "Secondary_Barcode", DbType.String, duBO.Secondary_Barcode);
                _DB.AddInParameter(dbCommand, "Email_Notification", DbType.String, duBO.Email_Notification);
                _DB.AddInParameter(dbCommand, "Email_Reminder", DbType.String, duBO.Email_Reminder);
                _DB.AddInParameter(dbCommand, "Zip_File_Name", DbType.String, duBO.Zip_File_Name);
                _DB.AddInParameter(dbCommand, "Control_File_Name", DbType.String, duBO.Control_File_Name);
                _DB.AddInParameter(dbCommand, "PDF_File_Name", DbType.String, duBO.PDF_File_Name);
                _DB.AddInParameter(dbCommand, "Criteria_Name", DbType.String, duBO.Criteria_Name);
                _DB.AddInParameter(dbCommand, "Project_Created_By", DbType.String, duBO.Project_Created_By);
                _DB.AddInParameter(dbCommand, "Modified_By", DbType.String, duBO.Modified_By);

                _DB.AddOutParameter(dbCommand, "Id", DbType.Int32, 0);
                _DB.ExecuteNonQuery(dbCommand);

                if (duBO.Project_Id == 0)
                {
                    HttpContext.Current.Session["ProjectId"] = Convert.ToInt32(_DB.GetParameterValue(dbCommand, "@Id"));
                }
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Database Error
                ErrMsg = string.Format("{0} - UpdateInsert Document Upload Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }
        }
コード例 #2
0
        /// <summary>
        /// Retrieves the Document Upload record for an Project Id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns>documentUploadBO</returns>
        public DocumentUploadBO GetByProjectId(Int32 projectId)
        {
            // Define Constants
            const string sp = "dbo.Get_DocUpload_By_Project_Id";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            // Define Variables
            DocumentUploadBO duBO = new DocumentUploadBO();

            try
            {
                // Set Input Parameters
                _DB.AddInParameter(dbCommand, "Project_Id", DbType.Int32, projectId);

                using (IDataReader dr = _DB.ExecuteReader(dbCommand))
                {
                    // Process all the records
                    while (dr.Read())
                    {
                        // Save the DocUpload record
                        duBO.Save(dr);
                    }
                }
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Database Error
                ErrMsg = string.Format("{0} - Get DocUpload By Project Id Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }

            return(duBO);
        }