예제 #1
0
        public ActionResult DashboardofSalaryData(int?BranchId, int?Year, byte?Month, int?EmployeeId)
        {
            BranchId   = BranchId == 0 ? BRANCHID : BranchId;
            Month      = Month == 0 ? null : Month;
            EmployeeId = EmployeeId == 0 ? null : EmployeeId;
            ClaimsReportVm vm = new ClaimsReportVm();

            vm.TravelClaimReport    = new List <USP_TRAVELCLAIMREPORT_Result>();
            vm.TravelClaimReportYTD = new List <USP_TRAVELCLAIMREPORTYTD_Result>();
            using (var dbCntx = new HrDataContext())
            {
                vm.TravelClaimReport    = dbCntx.USP_TRAVELCLAIMREPORT(BranchId, Year, Month, EmployeeId).ToList();
                vm.TravelClaimReportYTD = dbCntx.USP_TRAVELCLAIMREPORTYTD(BranchId, Year, EmployeeId).ToList();
                vm.dt = TRAVELCLAIMEMPLOYEEYTD(BranchId, Year, Month, EmployeeId);
            }
            vm.BranchID          = BranchId;
            vm.Year              = Year;
            vm.Month             = Month;
            vm.EmployeeID        = EmployeeId;
            ViewData["RoleCode"] = ROLECODE.ToUpper();

            foreach (var item in vm.TravelClaimReport)
            {
                if (item.ClaimCategory == "TAXILOCAL")
                {
                    item.ClaimCategory = "TAXI LOCAL";
                }
                else if (item.ClaimCategory == "TAXIOVERSEAS")
                {
                    item.ClaimCategory = "TAXI OVERSEAS";
                }
                else if (item.ClaimCategory == "FOODBILLSLOCAL")
                {
                    item.ClaimCategory = "FOOD BILLS LOCAL";
                }
                else if (item.ClaimCategory == "FOODBILLSOVERSEAS")
                {
                    item.ClaimCategory = "FOOD BILLS OVERSEAS";
                }
                else if (item.ClaimCategory == "OTHEREXPENSES")
                {
                    item.ClaimCategory = "OTHER EXPENSES";
                }
            }

            if (vm.dt != null && vm.dt.Columns.Count > 0)
            {
                DataRow totalsRow = vm.dt.NewRow();
                totalsRow["EMPLOYEE NAME"] = "TOTAL";
                for (int j = 1; j < vm.dt.Columns.Count; j++)
                {
                    DataColumn col = vm.dt.Columns[j];

                    decimal colTotal = 0;
                    for (int i = 0; i < col.Table.Rows.Count; i++)
                    {
                        DataRow row = col.Table.Rows[i];
                        if (row[col] == null || row[col].ToString() == "")
                        {
                            row[col] = "0.00";
                        }
                        colTotal += Convert.ToDecimal(row[col]);
                    }
                    //col.Table.Rows[j]. = Color.Red;
                    totalsRow[col.ColumnName] = colTotal;
                    if (col.ColumnName == "TAXILOCAL")
                    {
                        vm.dt.Columns[j].ColumnName = "TAXI LOCAL";
                    }
                    if (col.ColumnName == "TAXIOVERSEAS")
                    {
                        vm.dt.Columns[j].ColumnName = "TAXI OVERSEAS";
                    }
                    if (col.ColumnName == "FOODBILLSLOCAL")
                    {
                        vm.dt.Columns[j].ColumnName = "FOOD BILLS LOCAL";
                    }
                    if (col.ColumnName == "FOODBILLSOVERSEAS")
                    {
                        vm.dt.Columns[j].ColumnName = "FOOD BILLS OVERSEAS";
                    }
                    if (col.ColumnName == "OTHEREXPENSES")
                    {
                        vm.dt.Columns[j].ColumnName = "OTHER EXPENSES";
                    }
                }

                vm.dt.Rows.Add(totalsRow);
            }

            return(View(vm));
        }