69 lines
3.1 KiB
C#
69 lines
3.1 KiB
C#
|
using Ease.Core.DataAccess;
|
|||
|
using HRM.BO;
|
|||
|
using Microsoft.Data.SqlClient;
|
|||
|
using Payroll.BO;
|
|||
|
using System;
|
|||
|
using System.Configuration;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
internal class QuestionAnswerAttachmentDA
|
|||
|
{
|
|||
|
public static void Insert(QuestionAnswerAttachment item, string connectionString)
|
|||
|
{
|
|||
|
using (SqlConnection connection = new SqlConnection(connectionString))
|
|||
|
{
|
|||
|
connection.Open();
|
|||
|
SqlCommand cmd = new SqlCommand();
|
|||
|
cmd.Connection = connection;
|
|||
|
string commandText = @"INSERT INTO QUESTIONANSWERATTACHMENT(QuestionID,ANSWERID, FILEDATA, ORIGINALFILENAME,ATTACHMENTTYPE) Values (@QuestionID,@AnswerID,@FileData,@OriginalFileName,@ATTACHMENTTYPE)";
|
|||
|
cmd.CommandText = commandText;
|
|||
|
cmd.CommandType = CommandType.Text;
|
|||
|
cmd.Parameters.Add("@QuestionID", SqlDbType.Int);
|
|||
|
cmd.Parameters["@QuestionID"].Value = item.QuestionID;
|
|||
|
|
|||
|
cmd.Parameters.Add("@ANSWERID", SqlDbType.Int);
|
|||
|
cmd.Parameters["@ANSWERID"].Value = item.AnswerID;
|
|||
|
|
|||
|
cmd.Parameters.Add("@OriginalFileName", SqlDbType.VarChar);
|
|||
|
cmd.Parameters["@OriginalFileName"].Value = item.OriginalFileName;
|
|||
|
|
|||
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary);
|
|||
|
cmd.Parameters["@FileData"].Value = item.FileAsByteArray;
|
|||
|
|
|||
|
cmd.Parameters.Add("@ATTACHMENTTYPE", SqlDbType.Int);
|
|||
|
cmd.Parameters["@ATTACHMENTTYPE"].Value =(int)item.AttachmentType;
|
|||
|
|
|||
|
cmd.ExecuteNonQuery();
|
|||
|
cmd.Dispose();
|
|||
|
|
|||
|
connection.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetAnswerAttachment(TransactionContext tc, int questionId,int asnwerId)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM QUESTIONANSWERATTACHMENT where questionId= %n and answerId=%n and ATTACHMENTTYPE=2", questionId, asnwerId);
|
|||
|
}
|
|||
|
|
|||
|
//internal static IDataReader GetByReferenceId(TransactionContext tc, int refId,EnumFileType fileType)
|
|||
|
//{
|
|||
|
// return tc.ExecuteReader("SELECT * FROM QUESTIONANSWERATTACHMENT where referenceId= %n and fileType=%n ", refId,(int)fileType);
|
|||
|
//}
|
|||
|
//internal static IDataReader GetByRefChildId(TransactionContext tc, int refId, EnumFileType fileType,int refChildId)
|
|||
|
//{
|
|||
|
// return tc.ExecuteReader("SELECT * FROM FileAttachment where referenceId= %n and fileType=%n and RefChildId=%n", refId, (int)fileType, refChildId);
|
|||
|
//}
|
|||
|
//internal static IDataReader GetByReferenceandFileId(TransactionContext tc, int refId, EnumFileType fileType, int id)
|
|||
|
//{
|
|||
|
// return tc.ExecuteReader("SELECT * FROM FileAttachment where referenceId= %n and fileType=%n and FILEATTACHMENTID=%n", refId, (int)fileType,id);
|
|||
|
//}
|
|||
|
|
|||
|
//internal static void Delete(TransactionContext tc, int refID, EnumFileType type)
|
|||
|
//{
|
|||
|
// string sql = SQLParser.MakeSQL(@"DELETE FROM FILEATTACHMENT WHERE REFERENCEID = %n AND FILETYPE = %n", refID, type);
|
|||
|
// tc.ExecuteNonQuery(sql);
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|