public EmployeeOptionalInfo GetExtendedEmployeeData(int EmpId) { EmployeeOptionalInfo empOptInfo = null; if (Validator.ValidateEmployeeId(EmpId)) { EmployeeDataAccess empDataAccess = new EmployeeDataAccess(); empOptInfo = empDataAccess.GetExtendedEmployeeData(EmpId); } return(empOptInfo); }
private void button2_Click(object sender, EventArgs e) { EmployeeDataController employeeDataController = new EmployeeDataController(); EmployeeOptionalInfo employeeOptInfo = employeeDataController.GetExtendedEmployeeData(int.Parse(textBox1.Text)); if (employeeOptInfo != null) { textBox7.Text = employeeOptInfo.EmpEduInfo; textBox8.Text = employeeOptInfo.EmpFamilyInfo; textBox9.Text = employeeOptInfo.EmpHobbies; } btnUpdate.Enabled = true; }
protected void Button2_Click(object sender, EventArgs e) { EmployeeDataController employeeDataController = new EmployeeDataController(); EmployeeOptionalInfo employeeOptInfo = employeeDataController.GetExtendedEmployeeData(int.Parse(TextBox1.Text)); if (employeeOptInfo != null) { Label6.Text = "Educational Info: " + employeeOptInfo.EmpEduInfo; Label7.Text = "Family Details: "; // +employeeOptInfo.EmpFamilyInfo; Label8.Text = "Hobbies: "; // +employeeOptInfo.EmpHobbies; Label6.Visible = true; Label7.Visible = true; Label8.Visible = true; } }
public string SetOptionalEmployee(int empId, string eduInfo, string family, string hobbies) { string retVal = ""; EmployeeOptionalInfo empOptInfo = new EmployeeOptionalInfo(empId, eduInfo, family, hobbies); SSGS_EMS_Data_Access.EmployeeDataAccess empDataAccess = new EmployeeDataAccess(); if (empDataAccess.UpdateEmpOptionalDetails(empOptInfo)) { retVal = "optioanl info updated"; } else { retVal = "optional info not updated"; } return(retVal); }
public bool AddEmployeeOptional(EmployeeOptionalInfo empOptInfo) { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=SSGS EMS Data;Integrated Security=SSPI"); SqlCommand cmd1 = new SqlCommand("SELECT EmpId FROM EmpMaster WHERE EmpId = IDENT_CURRENT('EmpMaster')", con); con.Open(); int empID = Convert.ToInt32(cmd1.ExecuteScalar()); con.Close(); SqlCommand cmd = new SqlCommand("INSERT INTO EmpOptionalData (EmpId, EmpEduInfo,EmpFamilyInfo, EmpHobbies) VALUES ('" + empID + "', '" + empOptInfo.EmpEduInfo + "' , '" + empOptInfo.EmpFamilyInfo + "','" + empOptInfo.EmpHobbies + "')", con); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return(true); } con.Close(); return(false); }
public bool UpdateEmpOptionalDetails(EmployeeOptionalInfo empOptInfo) { bool retVal = false; SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=SSGS EMS Data;Integrated Security=SSPI"); SqlCommand cmd; cmd = new SqlCommand("UPDATE EmpOptionalData SET EmpEduInfo='" + empOptInfo.EmpEduInfo + "',EmpFamilyInfo='" + empOptInfo.EmpFamilyInfo + "', EmpHobbies='" + empOptInfo.EmpHobbies + "' WHERE EmpId=" + empOptInfo.EmpId, con); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); retVal = true; } else { con.Close(); retVal = false; } return(retVal); }
public EmployeeOptionalInfo GetExtendedEmployeeData(int EmpId) { EmployeeOptionalInfo employeeOptionalInfo = new EmployeeOptionalInfo(); SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=SSGS EMS Data;Integrated Security=SSPI"); SqlCommand cmd = new SqlCommand("SELECT * FROM EmpOptionalData WHERE EmpId=" + EmpId, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.Read()) { employeeOptionalInfo.EmpId = int.Parse(dr["EmpId"].ToString()); employeeOptionalInfo.EmpEduInfo = dr["EmpEduInfo"].ToString(); employeeOptionalInfo.EmpFamilyInfo = dr["EmpFamilyInfo"].ToString(); employeeOptionalInfo.EmpHobbies = dr["EmpHobbies"].ToString(); return(employeeOptionalInfo); } else { return(null); } }
public string AddEmployee(int empid, string fname, string lname, string desig, string dept, string reportsTo, string pwd, string empEduInfo, string empFamily, string empHobbies) { string retVal = ""; Employee employee = new Employee(empid, fname, lname, desig, dept, reportsTo); EmployeeOptionalInfo empOptInfo = new EmployeeOptionalInfo(empid, empEduInfo, empFamily, empHobbies); SSGS_EMS_Data_Access.EmployeeDataAccess empDataAccess = new EmployeeDataAccess(); #region Department Validity Check if (Validator.CheckDept(Convert.ToInt32(dept), fname, lname)) { retVal = "Valid"; //dept valid //check if report to fields is correct } else { retVal = "Department wrong"; } #endregion if (empDataAccess.AddEmployee(employee)) { if (empDataAccess.AddEmployeeOptional(empOptInfo)) { retVal = "Employee Added"; } } else { retVal = "Employee Cannot be Added"; } return(retVal); }