96 lines
4.9 KiB
C#
96 lines
4.9 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();
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
public static void Insert(QuestionAnswerAttachment item, TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
// string ConnString = ConfigurationSettings.AppSettings["default"];
|
|||
|
|
// var ConnString = System.Configuration.ConfigurationManager.GetSection("dbSettings");
|
|||
|
|
// string ConnString=ConfigurationManager.ConnectionStrings[connectionString].ConnectionString;
|
|||
|
|
|
|||
|
|
string strQuery = @"INSERT INTO QUESTIONANSWERATTACHMENT(QuestionID,ANSWERID, FILEDATA, ORIGINALFILENAME,ATTACHMENTTYPE) Values (@QuestionID,@AnswerID,@FileData,@OriginalFileName,@ATTACHMENTTYPE)";
|
|||
|
|
|
|||
|
|
SqlCommand cmd = new SqlCommand(strQuery, (SqlConnection)tc.Connection);
|
|||
|
|
|
|||
|
|
cmd.Transaction = (SqlTransaction)tc.Transaction;
|
|||
|
|
|
|||
|
|
//cmd.Parameters.Add("@empFileuploadID", SqlDbType.Int).Value = item.ID;
|
|||
|
|
cmd.Parameters.Add("@QuestionID", SqlDbType.Int).Value = item.QuestionID;
|
|||
|
|
cmd.Parameters.Add("@ANSWERID", SqlDbType.Int).Value = item.AnswerID;
|
|||
|
|
cmd.Parameters.Add("@OriginalFileName", SqlDbType.VarChar).Value = item.OriginalFileName;
|
|||
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = item.FileAsByteArray;
|
|||
|
|
cmd.Parameters.Add("@ATTACHMENTTYPE", SqlDbType.Int).Value = item.AttachmentType;
|
|||
|
|
//cmd.Parameters.Add("@createdBy", SqlDbType.VarChar).Value = item.CreatedBy;
|
|||
|
|
//cmd.Parameters.Add("@createdDate", SqlDbType.Binary).Value = item.CreatedDate;
|
|||
|
|
|
|||
|
|
//SqlConnection con = new SqlConnection(tc.Connection.ConnectionString);
|
|||
|
|
//cmd.CommandType = CommandType.Text;
|
|||
|
|
//cmd.Connection = con;
|
|||
|
|
cmd.ExecuteNonQuery();
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
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);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
}
|