public clsTransferAttachment GetTransferAttachment(int id)
        {
            clsTransferAttachment attachment1 = new clsTransferAttachment();

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_GetTransferAttachment"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@id", id);
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    attachment1.RegistrationNo = reader["RegistrationNo"].ToString();
                                    attachment1.ClientID       = reader["ClientID"].ToString();
                                    attachment1.FileName       = reader["fileName"].ToString();
                                    attachment1.FileContents   = (byte[])reader["fileData"];
                                }
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            return(attachment1);
        }
        public List <clsTransferAttachment> GetTransferAttachments(int id)
        {
            List <clsTransferAttachment> attachments = new List <clsTransferAttachment>();

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_GetTransferAttachments"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@TransferID", id);

                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    clsTransferAttachment attach = new clsTransferAttachment();

                                    attach.RegistrationNo = reader["RegistrationNo"].ToString();
                                    attach.ClientID       = reader["ClientID"].ToString();
                                    attach.FileName       = reader["fileName"].ToString();
                                    attach.FileDate       = Convert.ToDateTime(reader["FileDate"]);
                                    attach.Remarks        = reader["Remarks"].ToString();
                                    attach.id             = Convert.ToInt32(reader["id"]);

                                    attachments.Add(attach);
                                }
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            return(attachments);
        }
        public bool AddTransferAttachment(clsTransferAttachment attachment)
        {
            int st = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_AddTransferAttachment"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@TransferID", attachment.TransferId);
                            cmd.Parameters.AddWithValue("@RegistrationNo", attachment.RegistrationNo);
                            cmd.Parameters.AddWithValue("@ClientID", attachment.ClientID);
                            cmd.Parameters.AddWithValue("@filedata", attachment.FileContents);
                            cmd.Parameters.AddWithValue("@fileName", attachment.FileName);
                            cmd.Parameters.AddWithValue("@remarks", attachment.Remarks);
                            cmd.Parameters.AddWithValue("@filedate", attachment.FileDate);
                            st = cmd.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }