public void UpdateData() { lblEmpID.Text = Convert.ToString(employeeID); lblEmpID.Visible = true; emDAL = new EMDataAccessLayer(); try { Employee empObj = emDAL.FetchEmployee(employeeID); string val = empObj.Skills; for (int ctr = 0; ctr <= val.Length - 1; ctr++) { if (val[ctr] != Convert.ToChar(",")) { updateSkills = updateSkills + val[ctr]; } else { SelectCheckBoxList(updateSkills); updateSkills = null; } } SelectCheckBoxList(updateSkills); txtEmployeeName.Text = empObj.EmployeeName; txtDepartment.Text = empObj.Department; //cblSkills.Text = empObj.Skills; rbGender.Text = Convert.ToString(empObj.Gender); ddlStream.Text = empObj.Stream; } catch { lblStatus.Text = "Error in Fetching Employee Details"; } }
protected void btnSave_Click(object sender, EventArgs e) { foreach (ListItem li in chkSkills.Items) { string val; if (li.Selected == true) { val = li.Value; if (string.IsNullOrEmpty(chSkills) == true) { chSkills = chSkills + val; } else { chSkills = chSkills +","+ val; } } } emDAL = new EMDataAccessLayer(); try { Employee empObj = new Employee(); empObj.EmployeeName = txtEmployeeName.Text; empObj.Department = txtDepartment.Text; empObj.Skills = chSkills; empObj.Gender = Convert.ToChar(rbGender.SelectedValue); empObj.Stream = ddlStream.SelectedValue; int retVal = emDAL.AddEmployee(empObj); if (retVal == 1) { lblStatus.Text = "Employee Added Successfully"; //lblStatus.Text = chSkills; lblStatus.Visible = true; } else // lblStatus.Text = "Employee addition failed!"; lblStatus.Text = "error is "+retVal; lblStatus.Visible = true; } catch { lblStatus.Text = "Operation failed!"; lblStatus.Visible = true; } finally { } }
private void ViewEmployee() { emDAL = new EMDataAccessLayer(); if (!IsPostBack) { try { gvViewEmployee.DataSource = emDAL.ViewJoinedEmployee(); gvViewEmployee.DataBind(); } catch { lblStatus.Text = "Error in fetching the employee details!"; lblStatus.Visible = true; } } }
protected void gvViewEmployee_RowDeleting(object sender, GridViewDeleteEventArgs e) { TableCell cell = gvViewEmployee.Rows[e.RowIndex].Cells[1]; int employeeID = Convert.ToInt32(cell.Text); emDAL = new EMDataAccessLayer(); try { int retVal = emDAL.DeleteEmployee(employeeID); if (retVal == 1) { lblStatus.Text = "Deleted Successfully!!!"; lblStatus.Visible = true; try { gvViewEmployee.DataSource = emDAL.ViewJoinedEmployee(); gvViewEmployee.DataBind(); } catch { lblStatus.Text = "Error in fetching the employee details!"; lblStatus.Visible = true; } } else { lblStatus.Text = "Error occured in deleting"; lblStatus.Visible = true; } } catch { lblStatus.Text = "Delete Operation Failed!!"; lblStatus.Visible = true; } }