protected void Btn_Register_Click(object sender, EventArgs e)
{
Employee_Register();
}
public void Employee_Register()
{
try
{
int id = Convert.ToInt32(Txt_E_Id.Text);
string name = Txt_E_Name.Text;
int age = Convert.ToInt32(Txt_E_Age.Text);
string gender = "";
if (RB_Male.Checked)
gender = RB_Male.Text;
if (RB_Female.Checked)
gender = RB_Female.Text;
string address = Txt_Address.Text;
string phone = Txt_Phone.Text;
string qualification = Txt_Qualification.Text;
string attachment = "~/img/" + imm;
string designation = DDL_Designation.Text;
string date1 = Txt_J_Date.Text;
DateTime dat = DateTime.Parse(date1.ToString());
string date = dat.ToString("MM/dd/yyyy");
float salary = float.Parse(Txt_Salary.Text);
float allowance = float.Parse(Txt_Allavance.Text);
string cworking = DDL_C_Working.Text;
string image = Image1.ImageUrl;
SqlCommand cmd = new SqlCommand("insert into EmployeeRegistration(EmpId,EmpName,Age,Gender,Address,Phone,Qualification,Attachment,Image,Designation,JoiningDate,Salary,Allowance,CurrentWorking) values(@empid,@empnam,@age,@gen,@addr,@phon,@qual,@atta,@imag,@desi,@join,@sal,@allow,@curren)", DbConnection.mCon);
cmd.Parameters.Add("@empid", SqlDbType.Int).Value = id;
cmd.Parameters.Add("@empnam", SqlDbType.VarChar).Value = name;
cmd.Parameters.Add("@age", SqlDbType.Int).Value = age;
cmd.Parameters.Add("@gen", SqlDbType.VarChar).Value = gender;
cmd.Parameters.Add("@addr", SqlDbType.VarChar).Value = address;
cmd.Parameters.Add("@phon", SqlDbType.VarChar).Value = phone;
cmd.Parameters.Add("@qual", SqlDbType.VarChar).Value = qualification;
cmd.Parameters.Add("@atta", SqlDbType.VarChar).Value = attachment;
cmd.Parameters.Add("@imag", SqlDbType.VarChar).Value = Image1.ImageUrl;
cmd.Parameters.Add("@desi", SqlDbType.VarChar).Value = designation;
cmd.Parameters.Add("@join", SqlDbType.VarChar).Value = date;
cmd.Parameters.Add("@sal", SqlDbType.Float).Value = salary;
cmd.Parameters.Add("@allow", SqlDbType.Float).Value = allowance;
cmd.Parameters.Add("@curren", SqlDbType.VarChar).Value = cworking;
cmd.ExecuteNonQuery();
Lbl_Msg.Visible = true;
Lbl_Msg.Text = "[" + name + "]" + "Registration Successfully Added !";
Txt_E_Name.Text = Txt_E_Age.Text = Txt_Address.Text = Txt_Phone.Text = Txt_Qualification.Text = DDL_Designation.Text = DDL_C_Working.Text = Txt_J_Date.Text = Txt_Salary.Text = Txt_Allavance.Text = "";
RB_Male.Checked = false;
RB_Female.Checked = false;
Image1.ImageUrl = null;
}
catch
{
string name = Txt_E_Name.Text;
Lbl_Msg.Visible = true;
Lbl_Msg.Text = "[" + name + "]" + "Registration Failed !";
}
}
protected void Btn_Cancel_Click(object sender, EventArgs e)
{
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string date = Calendar1.SelectedDate.ToShortDateString();
DateTime dt1 = DateTime.Parse(date.ToString());
string dt = dt1.ToString("MM/dd/yyyy");
Txt_J_Date.Text = dt.ToString();
}
protected void Btn_Upload_Click(object sender, EventArgs e)
{
img_upload = "~/img/" + FileUpload1.FileName;
FileUpload1.SaveAs(MapPath(img_upload));
Image1.ImageUrl = img_upload;
}
protected void Btn_Upload1_Click(object sender, EventArgs e)
{
img_upload1 = "~/img/" + FU_Attachment.FileName;
FU_Attachment.SaveAs(MapPath(img_upload1));
imm = FU_Attachment.PostedFile.FileName;
Lbl_Msg1.Text = "File name: " + FU_Attachment.PostedFile.FileName + "<br>" + FU_Attachment.PostedFile.ContentLength + " kb<br>" + "Content type: " + FU_Attachment.PostedFile.ContentType;
}