Home > Net >  Automatic accumulate days sick
Automatic accumulate days sick

Time:11-08

C # 4 days of sick leave for a full year, less than a year to increase 2 days sick leave, how to write ah


Var employee_Name=LeaveSystem_BaseNumBLL. The Select ();
Var employee=BPMU_USERBLL. BPMU_USERSelect1 ();
The foreach (var item in the employee)
{
Var name=item. The Account;
Var dateTimeNow=DateTime. Now. The Date;
TimeSpan span=new TimeSpan ();
Var basenum=0;
Span=dateTimeNow - item. JoinDate;
//is more than 28 days may be greater than 1 months
If (span) TotalDays & gt; 28)
{
//in whether there are changes sent more than 1 months
If (item. JoinDate. The Month & lt; DateTimeNow. Month)
{
//judge need to add a few months
Int OneYearMonth=0;
Int OverOneYearMonth=0;

//judgment in time to less than 1 year
If (span. Days & gt; 365)
{





The foreach (var items in employee_Name)
{
//get LeaveSystem table staff name
Var names=items. The Account;
//judge BPMU_USER table of employees with LeaveSystem table is the same employee name
If (names==name)
{
Directly modified//if the same number of days
LeaveSystem_BaseNumBLL. Update (basenum, names);
}
The else
{
//get the value to the ID
String t=Guid. NewGuid (). The ToString (" N ");
//conversion type
String id=t.S ubstring (0, 32);
//if you don't add BPMU_USER table employee name to the same in the table with LeaveSystem
LeaveSystem_BaseNumBLL. Add (id, name);
//modify days
LeaveSystem_BaseNumBLL. Update (basenum, names);
}
}
//for (int OverOneYearMonth)
//{
//Func (adddays, 4)
//}

//add 4 days
}
The else
{




The foreach (var items in employee_Name)
{
//get LeaveSystem table staff name
Var names=items. The Account;
//judge BPMU_USER table of employees with LeaveSystem table is the same employee name
If (names==name)
{
Directly modified//if the same number of days
LeaveSystem_BaseNumBLL. Update (basenum, names);
}
The else
{
//get the value to the ID
String t=Guid. NewGuid (). The ToString (" N ");
//conversion type
String id=t.S ubstring (0, 32);
//if you don't add BPMU_USER table employee name to the same in the table with LeaveSystem
LeaveSystem_BaseNumBLL. Add (id, name);
//modify days
LeaveSystem_BaseNumBLL. Update (basenum, names);
}
}
//for (int OneYearMonth)
//Func (adddays, 2)
//+ 2 days
}


}
}

CodePudding user response:

Int intDays=0 days//
System. TimeSpan TS=new System. TimeSpan (now - induction time);
Double diffYear=the Convert. ToDouble (TS) TotalDays)/365;//take a number of years with decimal point
IntDays=remove diffYear integer bit * 4;
If (remove diffYear small digital & gt; 0)
{
IntDays=intDays + 2;
}

Should be like this

CodePudding user response:

You can be so
If take this month==on induction and today, induction day + 1==
Then the number of days=- induction year (today) * 4
If take this month & lt; In month or take months==today on induction and today, + 1 & lt; Induction day
The number of days=(today - in - 1) * 4 + 2
If take this month & gt; In month or take months==today on induction and today, + 1 & gt; Induction day
Then the number of days=- induction year (today) * 4 + 2
  • Related