using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public partial class Default4 : System.Web.UI.Page
{
SqlConnection db = new SqlConnection("database=bank;server=.;uid=sa");
protected void Page_Load(object sender, EventArgs e)
{
Panel1.Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
Panel1.Visible = true;
Label1.Text = CheckBox1.Text;
}
if (CheckBox2.Checked)
{
Panel1.Visible = true;
Label1.Text = CheckBox2.Text;
}
if (CheckBox3.Checked)
{
Panel1.Visible = true;
Label1.Text = CheckBox3.Text;
}
if (CheckBox4.Checked)
{
Panel1.Visible = true;
Label1.Text =CheckBox4.Text;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked)
{
TextBox3.Text = RadioButton1.Text;
}
else
if (RadioButton2.Checked)
{
TextBox3.Text = RadioButton2.Text;
}
if (FileUpload1.HasFile) return;
byte[] binary = new byte[FileUpload1.PostedFile.ContentLength];
binary = FileUpload1.FileBytes;
SqlParameter param = null;
SqlCommand cmd = new SqlCommand("Sp_Loan",db);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fathername",TextBox1.Text);
cmd.Parameters.AddWithValue("@mothername",TextBox2.Text);
cmd.Parameters.AddWithValue("@ms",TextBox3.Text);
cmd.Parameters.AddWithValue("@occupation",DropDownList1.Text);
param = new SqlParameter("@docname", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "",
DataRowVersion.Default, FileUpload1.FileName);
param = new SqlParameter("@document", SqlDbType.Image);
param.Direction = ParameterDirection.Input;
param.Value = binary;
cmd.Parameters.Add(param);
param= new SqlParameter("@doctype",SqlDbType.NVarChar,50,ParameterDirection.Input,false,0,0,"",
DataRowVersion.Default,FileUpload1.PostedFile.ContentType);
cmd.Parameters.Add(param);
cmd.Parameters.AddWithValue("@address",TextBox4.Text);
cmd.Parameters.AddWithValue("@zipcode", TextBox7.Text);
cmd.Parameters.AddWithValue("@phone", TextBox5.Text);
cmd.Parameters.AddWithValue("@mobile", TextBox6.Text);
db.Open();
cmd.ExecuteNonQuery();
Label2.Text = "success";
}
}
sql query
select * from loans
create proc Sp_Loan
@fathername varchar(50),@mothername varchar(50),@ms varchar(50),@occupation varchar(50),@docname nvarchar(50),@document image, @doctype nvarchar(50),
@address varchar(50),@zipcode int,@phone varchar(50),@mobile varchar(50)
as
begin
insert into loans values(@fathername,@mothername,@ms,@occupation,@docname,@document,@doctype,@address,@zipcode,@phone,@mobile)
end
go