protected void GVEmployee_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row;
row = GVEmployee.Rows[e.RowIndex];
Label Emp_code = row.FindControl("lblEMP_Code") as Label;
DropDownList Dept_Code= row.FindControl("DDLemp_CODE") as DropDownList;
TextBox Emp_Name = row.FindControl("txtIEmpName") as TextBox;
TextBox Address = row.FindControl("txtIAddress") as TextBox;
FileUpload image = row.FindControl("fuIIMage") as FileUpload;
Textbox Doj = row.FindControl("txtIDOJ") as Textbox;
Textbox Bdate = row.FindControl("txtIBDate") as Textbox;
txtNumber Phone = row.FindControl("txtIPhonw") as txtNumber;
DropDownList Status = row.FindControl("ddlIStatus") as DropDownList;
DropDownList Gender = row.FindControl("ddlIGender") as DropDownList;
DropDownList exp = row.FindControl("ddlIExp") as DropDownList;
TextBox NoofExp = row.FindControl("txtINOExp") as TextBox;
bl.EMP_Code = Emp_code.Text;
bl.DEP_Code = Dept_Code.SelectedValue;
bl.EMP_Name = Emp_Name.Text;
if (image.HasFile)
{
byte[] imageData = File.ReadAllBytes(image.FileName);
bl.IMage = imageData;
}
bl.Address = Address.Text;
bl.Doj = Doj.EmpDate;
bl.Doj = Bdate.EmpDate;
bl.Phone = Phone.NUmber;
bl.Status = Status.SelectedValue;
bl.Gender = Gender.SelectedValue;
if (exp.SelectedValue == "1")
{
bl.Exp = true;
}
else
{
bl.Exp = false;
}
if (NoofExp.Text != "")
{
bl.NOofexp = Convert.ToInt16(NoofExp.Text);
}
bl.update();
GVEmployee.EditIndex = -1;
bind();
}
protected void GVEmployee_RowEditing(object sender, GridViewEditEventArgs e)
{
GVEmployee.EditIndex = e.NewEditIndex;
bind();
}
protected void GVEmployee_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GVEmployee.EditIndex = -1;
bind();
}
protected void GVEmployee_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GVEmployee.PageIndex = e.NewPageIndex;
bind();
}
protected void GVEmployee_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string emp_code;
emp_code = GVEmployee.DataKeys[e.RowIndex].Value.ToString();
bl.EMP_Code = emp_code;
bl.Delete();
int i = bl.RET;
if (i == 1)
{
System.Windows.Forms.MessageBox.Show("Record Delete Successfully!", "Alert", System.Windows.Forms.MessageBoxButtons.OK);
}
if (i == 0)
{
System.Windows.Forms.MessageBox.Show("Record Delete Failed!", "Alert", System.Windows.Forms.MessageBoxButtons.OK);
}
bind();
}
protected void btnInsert_Click(object sender, EventArgs e)
{
TextBox Emp_code = GVEmployee.FooterRow.FindControl("txtEmpCode") as TextBox;
DropDownList Dept_Code = GVEmployee.FooterRow.FindControl("DDLIemp_CODE") as DropDownList;
TextBox Emp_Name = GVEmployee.FooterRow.FindControl("txtEmpName") as TextBox;
TextBox Address = GVEmployee.FooterRow.FindControl("txtAddress") as TextBox;
FileUpload image = GVEmployee.FooterRow.FindControl("fuIMage") as FileUpload;
Textbox Doj = GVEmployee.FooterRow.FindControl("txtDOJ") as Textbox;
Textbox Bdate = GVEmployee.FooterRow.FindControl("txtBDate") as Textbox;
txtNumber Phone = GVEmployee.FooterRow.FindControl("txtPhone") as txtNumber;
DropDownList Status = GVEmployee.FooterRow.FindControl("ddlStatus") as DropDownList;
DropDownList Gender = GVEmployee.FooterRow.FindControl("ddlGender") as DropDownList;
DropDownList exp = GVEmployee.FooterRow.FindControl("ddlExp") as DropDownList;
TextBox NoofExp = GVEmployee.FooterRow.FindControl("txtNOExp") as TextBox;
bl.EMP_Code = Emp_code.Text;
bl.DEP_Code = Dept_Code.SelectedValue;
bl.EMP_Name = Emp_Name.Text;
if (image.HasFile)
{
image.SaveAs(Server.MapPath("~/" + image.FileName));
byte[] imageData = File.ReadAllBytes(Server.MapPath("~/" + image.FileName));
bl.IMage =imageData;
}
bl.Address = Address.Text;
bl.Doj = Doj.EmpDate;
//if (Bdate.EmpDate == "")
//{
//
//}
bl.Bod = Bdate.EmpDate;
//if (Phone.NUmber != "")
//{
//
//}
bl.Phone = Phone.NUmber;
bl.Status = Status.SelectedValue;
bl.Gender = Gender.SelectedValue;
if (exp.SelectedValue == "1")
{
bl.Exp = true;
}
else
{
bl.Exp = false;
}
if (NoofExp.Text != "")
{
bl.NOofexp = Convert.ToInt16(NoofExp.Text);
}
bl.Insert();
int i;
i = bl.RET;
if (i == 2)
{
System.Windows.Forms.MessageBox.Show("Emp_code Already Exist","Warning", System.Windows.Forms.MessageBoxButtons.OK);
}
if (i == 0)
{
System.Windows.Forms.MessageBox.Show("Record Insert Successfully!", "Alert", System.Windows.Forms.MessageBoxButtons.OK);
}
if (i == 1)
{
System.Windows.Forms.MessageBox.Show("Record Insert Failed!", "Alert", System.Windows.Forms.MessageBoxButtons.OK);
}
bind();
}
No comments:
Post a Comment