public ActionResult Generated_PaySlip(int? emplID, String month)
{
if (!String.IsNullOrEmpty(Session["Admin"] as string))
{
int? basicSalary= 0;
int? BSalaryPerHour = 0;
IEnumerable<getmonthlyreportresult> PaySlip = DataContext.GetMonthlyReport(emplID, month, ref basicSalary, ref BSalaryPerHour).ToList();
ViewBag.Month = Request.QueryString["Month"];
ViewBag.Salary = basicSalary;
return View(PaySlip);
}
else
{
return RedirectToAction("IsAuth_Page", "Home");
}
</getmonthlyreportresult>
USE [a1]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetMonthlyReport] @emplID INT = NULL,
@month VARCHAR(50) = NULL, @BasicSalary int = null out ,@BSalaryHour int= Null out
AS
BEGIN
SET NOCOUNT ON;
IF (@emplID IS NOT NULL AND @month IS NOT NULL)
BEGIN
SELECT *
FROM MonthlyRecord
WHERE Month = @month AND EmplID = @emplID
Declare @StartDate Date, @EndDate Date, @mydate date, @TotalDays int, @TotalHours int
Set @mydate = GETUTCDATE()
Set @StartDate = (SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101))
Set @EndDate = (SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101))
Set @TotalDays =((DATEDIFF(dd, @StartDate, @EndDate) + 1)
-(DATEDIFF(wk, @StartDate, @EndDate) * 1)
-(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END))
Set @TotalHours = (@TotalDays * 8)
Set @BasicSalary = (Select BasicSalary from HrEmployee where EmplID=@emplID)
Set @BSalaryHour = @BasicSalary / @TotalHours
Select @BasicSalary as NetSalary, @BSalaryHour as SalaryPerHour
Declare @No_Rows int
Select No_Rows= count(*) FROM MonthlyRecord
WHERE Month = @month AND EmplID = @emplID
Return @No_Rows
END
ELSE
BEGIN
RETURN 0
END
END