First of all, I cannot forget what you have done, I have achieved a lot thanks to you, I hope you will continue to help me in this employee payroll.
There are two tables here, I call them logs, the two logs are directly related through id. There is a tax base in the 2nd register, this increases with each salary, sometimes the worker's tax base goes up, so I used ado net entity because of his daily wage, ef.
I will make a claret for 500 people, but I could not create the control part. I want 500 people to start from the beginning and show me the payrolls in the layout section and at the end give a report for accounting.
Dear great teacher, I compared it to visual basic. I apologize a little. I am very new to MVC. I could have written these codes very easily in Cobol 74 for 40 years. First of all, I'm curious now. I couldn't find a proper sample code on the net. There is no MVC code related to payroll. If I can make payroll for almost 500 people and add rdlc or crystal report to it, it would be great.
In short, I could not create the loop in the control section. You are the only one who understands these codes. I hope it will be useful to the company.
PART 0 A DATA ENTITY TABLES 1
//---------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------
namespace payrol.Models.tablolar
{
using System;
using System.Collections.Generic;
public partial class member
{
public short id { get; set; }
public string nsname { get; set; }
public string pictureway { get; set; }
public Nullable<System.DateTime> day { get; set; }
public Nullable<decimal> wage { get; set; }
public Nullable<decimal> specialdetuction1 { get; set; }
public Nullable<decimal> specialdetuction12 { get; set; }
public Nullable<decimal> legaldeduction1 { get; set; }
public Nullable<decimal> legaldeduction2 { get; set; }
public Nullable<decimal> legaldeduction3 { get; set; }
public Nullable<decimal> legaldeduction4 { get; set; }
public Nullable<int> EXTRAWORKINGHOURS { get; set; }
public Nullable<int> EXTRTAWORKINGDAYS { get; set; }
public virtual taxandinsurancetable taxandinsurancetable { get; set; }
}
}
----------------------------------------
PART 0 B DATA ENTITY TABLES 2
//---------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------
namespace payrol.Models.tablolar
{
using System;
using System.Collections.Generic;
public partial class taxandinsurancetable
{
public short id { get; set; }
public decimal basetax { get; set; }
public Nullable<short> memberid { get; set; }
public virtual member member { get; set; }
}
}
PART 2 CONTROLLER
namespace payrol.Controllers
{
public class kategorilerController : Controller
{
// GET: kategori
bgl db = new bgl();
public ActionResult Index()
{
var model1= db.member.Where(x => x.id).FirstOrDefault().tolist; /// member table
var model2 = db.taxandinsurancetable.Where(x => x.id).FirstOrDefault().tolist; // other table
////var degerler = db.member.ToList();
{
@foreach (var model1 in Model2)
var grosssalary =MODEL1.MEMBER.DAY * MODEL1.MEMBER.WAGE.value;
@VIEWBAG.GROSSSALARY=grosssalary;
var totalspecialduties=MODEL1.MEMBER.SPECIALDEDUCTION1+MODEL1.MEMBER.SPECIAL.DEDUCTION2;
@VIEWBAG.TOTALOFSPECIALDUTIES=totalspecialduties;
var totallegalduties=model1.MEMBER.LEGALDEDUCTION1+MODEL1MEMBER.LEGALDEDUCTION2+MODEL1.MEMBER.LEGALDEDUCTION3;
@VIEWBAG.TOTALLEGALDUTIES=totallegalduties;
var extraworkinghours=((model1.MEMBER.WAGE)/model1.MEMBER.EXTRAWORKINGHOURS);
@VIEWBAG.EXTRAWORKINGHOURS=extraworkinghours;
var extraworkingdays=model1.MEMBER.WAGE*model1.MEMBER.EXTRAWORKINGDAYS;
@VIEWBAG.EXTRAWORKINGDAYS=extraworkingdays;
/// Finding a basis from gross salary= MATRAH BULMA VE 2 INCI TABLOYA YAZMACA
var taxbase =taxbase+(grosssalary*model2.insurancegovermentrate) // % 15 30 40 and tax brackets 2nd table
0 15 10000 16 30 300000 31-40 50000 40- salary is tax free
db.Entry(model2).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
@viewbag.taxbase=taxbase
netsalary=(((grossalary)-totallegalduties)-(taxbase)
@VIEWBAG.NETSALARY=netsalary;
bigestgrosssalary=bigestgrosssalary+grosssalary;
bigestspecialduties=totalspecialduties+bigestspecialduties;
bigesttotallegalduties= bigesttotallegalduties+totallegalduties;
bigestextraworkinghours= bigestextraworkinghours+ extraworkinghours;
bigestextraworkingdays= bigestextraworkingdays+ extraworkingdays;
bigestnetsalary= bigestnetsalary+ netsalary;
grosssalary=0
totalspecialduties=0;
totallegalduties=0;
extraworkinghours=0;
extraworkingdays=0;
netsalary=0
}
@VIEWBAG.bigestgrosssalary= bigestgrosssalary;
@VIEWBAG.bigestspecialduties=bigestspecialduties;
@viewBAG.bigesttotallegalduties= bigesttotallegalduties;
@VİEWBAG.bigestextraworkinghours= bigestextraworkinghours;
@VIEWBAG.bigestextraworkingdays= bigestextraworkingdays;
@VIEWBAG.bigestnetsalary= bigestnetsalary;
return View(model1);
}
PART 3 LAYOUT SIDE
@using payrol.Models.baglantientities
@model List<member>
@{
ViewBag.Title = "Index";
Layout = "~/Views/shared/Anamasterform.cshtml";
}
<table class="table table-bordered">
<tr>
<th>ID </th>
<th>NAMESURNAME</th>
<th>DAY</th>
<th>WAGE </th>
<th> PICTURE</th>
<th>LEGALDEDUCTION1</th>
<th>LEGALDEDUCTION2</th>
<th>LEGALDEDUCTION3</th>
<th>SPECIALDEDUCTION1</th>
<th>SPECIALDEDUCT1</th>
<th>LEGALDEDUCTION2</th>
<th>LEGALDEDUCTION2</th>
<th>GROSSSALARY</th> /@ BRUT MAAŞ
<th>NETSALARY</th> /@ NET MAAŞ
<th>TOTALOFSPECIALDUTIES</th> /@ ÖZEL KESİNTİLER TOPLAMI
<th>TOTALLEGALDUTIES</th> /@ YASAL KESİNTİLER TOPLAMI
<th>EXTRAWORKINGHOURS</th> /@ EXTRA FAZLA çalışma SAATİ
<th>EXTRAWORKINGDAYS</th> /@ EXTRA FAZLA çalışma GUNU
<th> taxbase </th>
</tr>
<tbody>
@foreach (var MODEL1 in Model2)
{
<tr>
<td>@model1.ID </td>
<td>@model1.NSNAME</td>
<td>@model1.PICTUREWAY </td>
@if (@model1.PICTUREWAY=="" || @model1.PICTUREWAY==null)
{
<td>NOT PICTURE </td>
}
else
{
<td>
<img src="@Url.Content(@model1.PICTUREWAY)" width="250" height="250" />
</td>
<TD> VIEWBAG.GROSSSALARY </TD>
<TD> VIEWBAG.NETSALARY </TD>
<th> VIEWBAG.TOTALOFSPECIALDUTIES</th> /@ ÖZEL KESİNTİLER TOPLAMI
<th>VIEWBAG.TOTALLEGALDUTIES</th> /@ YASAL KESİNTİLER TOPLAMI
<th>VIEWBAG.EXTRAWORKINGHOURS</th> /@ EXTRA FAZLA çalışma SAATİ
<th>VIEWBAG.EXTRAWORKINGDAYS</th> /@ EXTRA FAZLA çalışma GUNU
<th> @viewbag.taxbase </th>
}
GENARAL REPORT SIDE for taking into account in accounting total total money to be paid from cash
<TD> @VIEWBAG.bigestgrosssalary </TD>
@VIEWBAG.bigestspecialduties
@viewBAG.bigesttotallegalduties
@VİEWBAG.bigestextraworkinghours
@VIEWBAG.bigestextraworkingdays
@VIEWBAG.bigestnetsalary
</tr>
}
</tbody>
</table>
Best regards, my great teacher.