EchoTex_Payroll/HRM.DA/DA/Assets/AssetSerialTranAttachmentDA.cs

54 lines
2.1 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using HRM.BO.Assets;
using Microsoft.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HRM.DA.DA.Assets
{
internal class AssetSerialTranAttachmentDA
{
public static void Insert(AssetSerialTranAttachment item, string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
string commandText = @"INSERT INTO AssetSerialTranAttachment( AssetID, AssetSerialID, AssetSerialTranID, FileName, FilePath , FileAsByteArray, Extension) Values (@AssetID, @AssetSerialID, @AssetSerialTranID, @FileName, @FilePath, @FileAsByteArray, @Extension)";
cmd.CommandText = commandText;
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@AssetID", SqlDbType.Int);
cmd.Parameters["@AssetID"].Value = item.AssetID;
cmd.Parameters.Add("@AssetSerialID", SqlDbType.Int);
cmd.Parameters["@AssetSerialID"].Value = item.AssetSerialID;
cmd.Parameters.Add("@AssetSerialTranID", SqlDbType.Int);
cmd.Parameters["@AssetSerialTranID"].Value = item.AssetSerailTranID;
cmd.Parameters.Add("@FileName", SqlDbType.VarChar);
cmd.Parameters["@FileName"].Value = item.FileName;
cmd.Parameters.Add("@FilePath", SqlDbType.VarChar);
cmd.Parameters["@FilePath"].Value = item.FilePath;
cmd.Parameters.Add("@FileAsByteArray", SqlDbType.VarBinary);
cmd.Parameters["@FileAsByteArray"].Value = item.FileAsByteArray;
cmd.Parameters.Add("@Extension", SqlDbType.VarChar);
cmd.Parameters["@Extension"].Value = item.Extension;
cmd.ExecuteNonQuery();
cmd.Dispose();
connection.Close();
}
}
}
}