Example #1
0
        public IActionResult SalaryDetails(int id)
        {
            string        Query1 = "select employee.employee_id,employee.name,SalaryDetails.salary_elements,SalaryDetails.value from SalaryDetails inner join employee on SalaryDetails.employee_id = employee.employee_id where employee.employee_id=" + id;
            SqlDataReader reader = SqlDBOperation.Query(Query1);

            Employee emp = new Employee();

            emp.EmpID = id;
            while (reader.Read())
            {
                string salary_elements = reader.GetString(2);

                if (salary_elements == "Basic_salary")
                {
                    emp.EmpID    = reader.GetInt32(0);
                    emp.Name     = reader.GetString(1);
                    emp.BasicPay = reader.GetDecimal(3);
                }
                else if (salary_elements == "HRA")
                {
                    emp.EmpID = reader.GetInt32(0);
                    emp.Name  = reader.GetString(1);
                    emp.HRA   = reader.GetDecimal(3);
                }
                else if (salary_elements == "TA")
                {
                    emp.EmpID = reader.GetInt32(0);
                    emp.Name  = reader.GetString(1);
                    emp.TA    = reader.GetDecimal(3);
                }
            }
            return(View(emp));
        }
Example #2
0
        public IActionResult Index()
        {
            List <Employee> employeeList1 = new List <Employee>();
            string          Query1        = "select employee_id,name,age,gender,phone,email,designation,employee.designation_id from employee inner join designation on employee.designation_id = designation.designation_id";

            try
            {
                SqlDataReader reader = SqlDBOperation.Query(Query1);

                while (reader.Read())
                {
                    Employee emp = new Employee();
                    emp.EmpID           = reader.GetInt32(0);
                    emp.Name            = reader.GetString(1);
                    emp.Age             = reader.GetInt32(2);
                    emp.Gender          = reader.GetString(3);
                    emp.Phone           = reader.GetString(4);
                    emp.Email           = reader.GetString(5);
                    emp.DesignationName = reader.GetString(6);
                    emp.DesignationID   = reader.GetInt32(7);

                    employeeList1.Add(emp);
                }
            }catch (Exception e)
            {
            }
            employeeList = employeeList1;
            return(View(employeeList1));
        }
        public IActionResult PayRoll(int id)
        {
            string        Query2 = "select SalaryDetails.employee_id,employee.name, sum(value) from employee inner join SalaryDetails  on employee.employee_id = SalaryDetails.employee_id where SalaryDetails.employee_id=" + id + "  group by employee.name,SalaryDetails.employee_id ";
            SqlDataReader reader = SqlDBOperation.Query(Query2);

            Employee emp = new Employee();

            emp.EmpID = id;

            while (reader.Read())
            {
                emp.EmpID    = reader.GetInt32(0);
                emp.Name     = reader.GetString(1);
                emp.TotalSal = reader.GetDecimal(2);
            }
            emp.Salary = emp.TotalSal;
            return(View(emp));
        }