Ejemplo n.º 1
0
        public static bool AddEmployeesBLL(Employee emp, Employee_Security empsec, string desig, string grade)
        {
            bool isEmployeeAdded     = false;
            bool isEmployeeValidated = false;

            try
            {
                isEmployeeValidated = ValidateEmployeeBLL(emp, empsec, desig, grade);
                if (isEmployeeValidated)
                {
                    isEmployeeAdded = EmployeeOperations.AddEmployeesDAL(emp, empsec, desig, grade);
                    return(isEmployeeAdded);
                }
                else
                {
                    throw new PayrollException("Error");
                }
            }
            catch (PayrollException)
            {
                throw;
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public static bool AddEmployeesDAL(Employee emp, Employee_Security empsec, string desig, string grade)
        {
            bool isEmployeeAdded = false;

            try
            {
                SqlCommand command = new SqlCommand("Group3_Payroll.usp_AddEmployee", connection);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter empid     = new SqlParameter("@EmpId", emp.Employee_Id);
                SqlParameter pwd       = new SqlParameter("@Password", emp.Employee_Password);
                SqlParameter doj       = new SqlParameter("@doj", emp.DOJ);
                SqlParameter fname     = new SqlParameter("@Firstname", emp.Employee_FirstName);
                SqlParameter lname     = new SqlParameter("@Lastname", emp.Employee_LastName);
                SqlParameter address   = new SqlParameter("@Address", emp.Employee_Address);
                SqlParameter squestion = new SqlParameter("@SecurityQuestion", empsec.Security_Question);
                SqlParameter sanswer   = new SqlParameter("@SecurityAnswer", empsec.Security_Answer);
                SqlParameter dsig      = new SqlParameter("@Designation", desig);
                SqlParameter grd       = new SqlParameter("@Grade", grade);

                command.Parameters.Add(empid);
                command.Parameters.Add(pwd);
                command.Parameters.Add(doj);
                command.Parameters.Add(fname);
                command.Parameters.Add(lname);
                command.Parameters.Add(address);
                command.Parameters.Add(squestion);
                command.Parameters.Add(sanswer);
                command.Parameters.Add(dsig);
                command.Parameters.Add(grd);

                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                command.ExecuteNonQuery();
                isEmployeeAdded = true;

                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }

                return(isEmployeeAdded);
            }
            catch (PayrollException)
            {
                throw;
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public static bool ValidateEmployeeBLL(Employee emp, Employee_Security empsec, string desig, string grade)
        {
            bool          isEmployeeValidated = true;
            StringBuilder sm = new StringBuilder();

            try
            {
                if (emp.Employee_Id == 0)
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Id should not be empty");
                }
                if (emp.Employee_Password == null)
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Password should not be empty");
                }
                if (emp.Employee_FirstName.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee First name should not be empty");
                }
                if (emp.Employee_LastName.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Last name should not be empty");
                }
                if (emp.Employee_Address.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Address name should not be empty");
                }
                if (emp.DOJ < DateTime.Now)
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee DOJ cannot be in past");
                }
                if (empsec.Security_Question.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Security Question should not be empty");
                }
                if (empsec.Security_Answer.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Security Answer should not be empty");
                }
                if (desig.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Designation should not be empty");
                }
                if (grade.Equals(string.Empty))
                {
                    isEmployeeValidated = false;
                    sm.Append("Employee Grade should not be empty");
                }

                if (!isEmployeeValidated)
                {
                    throw new PayrollException(sm.ToString());
                }
                return(isEmployeeValidated);
            }
            catch (PayrollException)
            {
                throw;
            }
            catch (System.Exception)
            {
                throw;
            }
        }