using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Diagnostics;
Boolean IsClick = true;
byte[] Attachmnt;
ClassLibrary1.Entity objEntity = new ClassLibrary1.Entity();
Query objQuery = new Query();
string Connstr = System.Configuration.ConfigurationManager.AppSettings["Connstr"].ToString();
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Select ur file ";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.DefaultExt = "doc";
openFileDialog1.Filter = "Excel file(*.xls)|*.xls";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.ReadOnlyChecked = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
tbUpload.Text = openFileDialog1.SafeFileName;
FilePath = openFileDialog1.FileName;
if (openFileDialog1.FileName != null)
{
v_Filepath = FilePath;
System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fs);
long byteLength = new System.IO.FileInfo(FilePath).Length;
Attachmnt = binaryReader.ReadBytes((Int32)byteLength);
fs.Close();
fs.Dispose();
binaryReader.Close();
}
}
}
private void btnSubmit_Click(object sender, EventArgs e)
{
Document objDoc = new Document();
objDoc.DocContent = Attachmnt;
objEntity.ResumeData_ = objDoc.DocContent;
objEntity.Submit();
}
public class Document
{
public int DocId { get; set; }
public string DocName { get; set; }
public byte[] DocContent { get; set; }
}
namespace ClassLibrary1
{
public class Entity
{
private byte[] ResumeData;
public byte[] ResumeData_
{
get { return ResumeData; }
set { ResumeData = value; }
}
string Connstr=System.Configuration.ConfigurationManager.AppSettings["Connstr"].ToString();
public void Submit()
{
SqlCommand Cmd = new SqlCommand();
SqlConnection Conn = new SqlConnection(Connstr);
Conn.Open();
Cmd.Connection = Conn;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = "SP_Insert_Joinee";
Cmd.ExecuteNonQuery();
}
}
}