515 lines
25 KiB
C#
515 lines
25 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
|
||
namespace BLL
|
||
{
|
||
/// <summary>
|
||
/// 事故类型
|
||
/// </summary>
|
||
public static class DoorServerService
|
||
{
|
||
public static Model.SGGLDB db = Funs.DB;
|
||
|
||
/// <summary>
|
||
/// 根据主键获取事故类型
|
||
/// </summary>
|
||
/// <param name="accidentTypeId"></param>
|
||
/// <returns></returns>
|
||
public static Model.T_d_EmployInOutRecord GetEmployInOutRecordById(string id)
|
||
{
|
||
return Funs.DB.T_d_EmployInOutRecord.FirstOrDefault(e => e.NewID == id);
|
||
}
|
||
|
||
|
||
#region 根据出入记录 写入考勤记录
|
||
/// <summary>
|
||
/// 根据出入记录 写入考勤记录
|
||
/// </summary>
|
||
public static void InsertEmployInOutRecord(Model.SitePerson_PersonInOut newInOut)
|
||
{
|
||
if (newInOut.ChangeTime.HasValue)
|
||
{
|
||
Model.T_d_EmployInOutRecord newInOutRecord = new Model.T_d_EmployInOutRecord
|
||
{
|
||
NewID = SQLHelper.GetNewID(),
|
||
ProjectId = newInOut.ProjectId,
|
||
InstallationName = ProjectService.GetProjectNameByProjectId(newInOut.ProjectId),
|
||
RecordDate = newInOut.ChangeTime.Value.Date,
|
||
IDCardNo = newInOut.IdentityCard,
|
||
};
|
||
////获取人员
|
||
newInOutRecord.UnitId = newInOut.UnitId;
|
||
newInOutRecord.UnitName = newInOut.UnitName;
|
||
newInOutRecord.EmployNO = newInOut.IdentityCard;
|
||
newInOutRecord.EmployName = newInOut.PersonName;
|
||
newInOutRecord.PostId = newInOut.WorkPostId;
|
||
newInOutRecord.PostName = newInOut.WorkPostName;
|
||
|
||
#region 上下班时间
|
||
///上午上班 8
|
||
DateTime TWorkIn1 = newInOut.ChangeTime.Value.Date.AddHours(8);
|
||
///上午下班 12:30
|
||
DateTime TOffDuty1 = newInOut.ChangeTime.Value.Date.AddHours(12).AddMinutes(30);
|
||
///下午上班 1:30
|
||
DateTime TWorkIn2 = newInOut.ChangeTime.Value.Date.AddHours(13).AddMinutes(30);
|
||
///下午下班 7
|
||
DateTime TOffDuty2 = newInOut.ChangeTime.Value.Date.AddHours(19);
|
||
if (newInOut.IsIn == true)
|
||
{
|
||
///上午上班
|
||
if ( newInOut.ChangeTime < TOffDuty1)
|
||
{
|
||
newInOutRecord.WorkIn1 = newInOut.ChangeTime;
|
||
}
|
||
else if ( newInOut.ChangeTime < TOffDuty2)
|
||
{
|
||
newInOutRecord.WorkIn2 = newInOut.ChangeTime;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.WorkIn3 = newInOut.ChangeTime;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
///上午下班
|
||
if ( newInOut.ChangeTime < TWorkIn2)
|
||
{
|
||
newInOutRecord.OffDuty1 = newInOut.ChangeTime;
|
||
}
|
||
else if ( newInOut.ChangeTime < TOffDuty2.AddHours(1))
|
||
{
|
||
newInOutRecord.OffDuty2 = newInOut.ChangeTime;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.OffDuty3 = newInOut.ChangeTime;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
bool isInsert = false;
|
||
var getInOutRecord = Funs.DB.T_d_EmployInOutRecord.FirstOrDefault(x => x.ProjectId == newInOut.ProjectId && x.IDCardNo == newInOut.IdentityCard && x.RecordDate == newInOut.ChangeTime.Value.Date);
|
||
if (getInOutRecord == null)
|
||
{
|
||
isInsert = true;
|
||
}
|
||
if (isInsert)
|
||
{
|
||
newInOutRecord.ManHours = 4;
|
||
newInOutRecord.ManOverHours = 0;
|
||
Funs.DB.T_d_EmployInOutRecord.InsertOnSubmit(newInOutRecord);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
else
|
||
{
|
||
#region 计算人工时
|
||
if (newInOutRecord.WorkIn1.HasValue && (!getInOutRecord.WorkIn1.HasValue || getInOutRecord.WorkIn1 > newInOutRecord.WorkIn1))
|
||
{
|
||
getInOutRecord.WorkIn1 = newInOutRecord.WorkIn1;
|
||
}
|
||
if (newInOutRecord.WorkIn2.HasValue && (!getInOutRecord.WorkIn2.HasValue || getInOutRecord.WorkIn2 > newInOutRecord.WorkIn2))
|
||
{
|
||
getInOutRecord.WorkIn2 = newInOutRecord.WorkIn2;
|
||
}
|
||
if (newInOutRecord.WorkIn3.HasValue && (!getInOutRecord.WorkIn3.HasValue || getInOutRecord.WorkIn3 > newInOutRecord.WorkIn3))
|
||
{
|
||
getInOutRecord.WorkIn3 = newInOutRecord.WorkIn3;
|
||
}
|
||
|
||
if (newInOutRecord.OffDuty1.HasValue && (!getInOutRecord.OffDuty1.HasValue || getInOutRecord.OffDuty1 < newInOutRecord.OffDuty1))
|
||
{
|
||
getInOutRecord.OffDuty1 = newInOutRecord.OffDuty1;
|
||
}
|
||
if (newInOutRecord.OffDuty2.HasValue && (!getInOutRecord.OffDuty2.HasValue || getInOutRecord.OffDuty2 < newInOutRecord.OffDuty2))
|
||
{
|
||
getInOutRecord.OffDuty2 = newInOutRecord.OffDuty2;
|
||
}
|
||
if (newInOutRecord.OffDuty3.HasValue && (!getInOutRecord.OffDuty3.HasValue || getInOutRecord.OffDuty3 < newInOutRecord.OffDuty3))
|
||
{
|
||
getInOutRecord.OffDuty3 = newInOutRecord.OffDuty3;
|
||
}
|
||
int m1 = 0;
|
||
if (getInOutRecord.WorkIn1.HasValue || getInOutRecord.OffDuty1.HasValue)
|
||
{
|
||
m1 = 240;
|
||
if (getInOutRecord.WorkIn1.HasValue && getInOutRecord.OffDuty1.HasValue)
|
||
{
|
||
m1 = Convert.ToInt32((getInOutRecord.OffDuty1 - getInOutRecord.WorkIn1).Value.TotalMinutes);
|
||
}
|
||
}
|
||
int m2 = 0;
|
||
if (getInOutRecord.WorkIn2.HasValue || getInOutRecord.OffDuty2.HasValue)
|
||
{
|
||
m2 = 240;
|
||
if (getInOutRecord.WorkIn2.HasValue && getInOutRecord.OffDuty2.HasValue)
|
||
{
|
||
m2 = Convert.ToInt32((getInOutRecord.OffDuty2 - getInOutRecord.WorkIn2).Value.TotalMinutes);
|
||
}
|
||
}
|
||
int m3 = 0;
|
||
if (getInOutRecord.WorkIn3.HasValue || getInOutRecord.OffDuty3.HasValue)
|
||
{
|
||
m3 = 240;
|
||
if (getInOutRecord.WorkIn3.HasValue && getInOutRecord.OffDuty3.HasValue)
|
||
{
|
||
m3 = Convert.ToInt32((getInOutRecord.OffDuty3 - getInOutRecord.WorkIn3).Value.TotalMinutes);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
getInOutRecord.ManHours = Convert.ToInt32(Math.Ceiling((m1 + m2 + m3) * 1.0 / 60));
|
||
getInOutRecord.ManOverHours = Convert.ToInt32(Math.Ceiling(m3 * 1.0 / 60));
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
}
|
||
public static void InsertEmployInOutRecord(List<Model.SitePerson_PersonInOut> newInOuts)
|
||
{
|
||
var getInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == newInOuts[0].ProjectId && x.RecordDate == newInOuts[0].ChangeTime.Value.Date).ToList();
|
||
|
||
foreach (var newInOut in newInOuts)
|
||
{
|
||
if (newInOut.ChangeTime.HasValue)
|
||
{
|
||
Model.T_d_EmployInOutRecord newInOutRecord = new Model.T_d_EmployInOutRecord
|
||
{
|
||
NewID = SQLHelper.GetNewID(),
|
||
ProjectId = newInOut.ProjectId,
|
||
InstallationName = ProjectService.GetProjectNameByProjectId(newInOut.ProjectId),
|
||
RecordDate = newInOut.ChangeTime.Value.Date,
|
||
IDCardNo = newInOut.IdentityCard,
|
||
};
|
||
////获取人员
|
||
newInOutRecord.UnitId = newInOut.UnitId;
|
||
newInOutRecord.UnitName = newInOut.UnitName;
|
||
newInOutRecord.EmployNO = newInOut.IdentityCard;
|
||
newInOutRecord.EmployName = newInOut.PersonName;
|
||
newInOutRecord.PostId = newInOut.WorkPostId;
|
||
newInOutRecord.PostName = newInOut.WorkPostName;
|
||
|
||
#region 上下班时间
|
||
///上午上班 8
|
||
DateTime TWorkIn1 = newInOut.ChangeTime.Value.Date.AddHours(8);
|
||
///上午下班 12:30
|
||
DateTime TOffDuty1 = newInOut.ChangeTime.Value.Date.AddHours(12).AddMinutes(30);
|
||
///下午上班 1:30
|
||
DateTime TWorkIn2 = newInOut.ChangeTime.Value.Date.AddHours(13).AddMinutes(30);
|
||
///下午下班 7
|
||
DateTime TOffDuty2 = newInOut.ChangeTime.Value.Date.AddHours(19);
|
||
if (newInOut.IsIn == true)
|
||
{
|
||
///上午上班
|
||
if (newInOut.ChangeTime < TOffDuty1)
|
||
{
|
||
newInOutRecord.WorkIn1 = newInOut.ChangeTime;
|
||
}
|
||
else if (newInOut.ChangeTime < TOffDuty2)
|
||
{
|
||
newInOutRecord.WorkIn2 = newInOut.ChangeTime;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.WorkIn3 = newInOut.ChangeTime;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
///上午下班
|
||
if (newInOut.ChangeTime < TWorkIn2)
|
||
{
|
||
newInOutRecord.OffDuty1 = newInOut.ChangeTime;
|
||
}
|
||
else if (newInOut.ChangeTime < TOffDuty2.AddHours(1))
|
||
{
|
||
newInOutRecord.OffDuty2 = newInOut.ChangeTime;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.OffDuty3 = newInOut.ChangeTime;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
bool isInsert = false;
|
||
var getInOutRecord = getInOutRecords.FirstOrDefault(x => x.IDCardNo == newInOut.IdentityCard && x.RecordDate == newInOut.ChangeTime.Value.Date);
|
||
if (getInOutRecord == null)
|
||
{
|
||
isInsert = true;
|
||
}
|
||
if (isInsert)
|
||
{
|
||
newInOutRecord.ManHours = 4;
|
||
newInOutRecord.ManOverHours = 0;
|
||
Funs.DB.T_d_EmployInOutRecord.InsertOnSubmit(newInOutRecord);
|
||
|
||
}
|
||
else
|
||
{
|
||
#region 计算人工时
|
||
if (newInOutRecord.WorkIn1.HasValue && (!getInOutRecord.WorkIn1.HasValue || getInOutRecord.WorkIn1 > newInOutRecord.WorkIn1))
|
||
{
|
||
getInOutRecord.WorkIn1 = newInOutRecord.WorkIn1;
|
||
}
|
||
if (newInOutRecord.WorkIn2.HasValue && (!getInOutRecord.WorkIn2.HasValue || getInOutRecord.WorkIn2 > newInOutRecord.WorkIn2))
|
||
{
|
||
getInOutRecord.WorkIn2 = newInOutRecord.WorkIn2;
|
||
}
|
||
if (newInOutRecord.WorkIn3.HasValue && (!getInOutRecord.WorkIn3.HasValue || getInOutRecord.WorkIn3 > newInOutRecord.WorkIn3))
|
||
{
|
||
getInOutRecord.WorkIn3 = newInOutRecord.WorkIn3;
|
||
}
|
||
|
||
if (newInOutRecord.OffDuty1.HasValue && (!getInOutRecord.OffDuty1.HasValue || getInOutRecord.OffDuty1 < newInOutRecord.OffDuty1))
|
||
{
|
||
getInOutRecord.OffDuty1 = newInOutRecord.OffDuty1;
|
||
}
|
||
if (newInOutRecord.OffDuty2.HasValue && (!getInOutRecord.OffDuty2.HasValue || getInOutRecord.OffDuty2 < newInOutRecord.OffDuty2))
|
||
{
|
||
getInOutRecord.OffDuty2 = newInOutRecord.OffDuty2;
|
||
}
|
||
if (newInOutRecord.OffDuty3.HasValue && (!getInOutRecord.OffDuty3.HasValue || getInOutRecord.OffDuty3 < newInOutRecord.OffDuty3))
|
||
{
|
||
getInOutRecord.OffDuty3 = newInOutRecord.OffDuty3;
|
||
}
|
||
int m1 = 0;
|
||
if (getInOutRecord.WorkIn1.HasValue || getInOutRecord.OffDuty1.HasValue)
|
||
{
|
||
m1 = 240;
|
||
if (getInOutRecord.WorkIn1.HasValue && getInOutRecord.OffDuty1.HasValue)
|
||
{
|
||
m1 = Convert.ToInt32((getInOutRecord.OffDuty1 - getInOutRecord.WorkIn1).Value.TotalMinutes);
|
||
}
|
||
}
|
||
int m2 = 0;
|
||
if (getInOutRecord.WorkIn2.HasValue || getInOutRecord.OffDuty2.HasValue)
|
||
{
|
||
m2 = 240;
|
||
if (getInOutRecord.WorkIn2.HasValue && getInOutRecord.OffDuty2.HasValue)
|
||
{
|
||
m2 = Convert.ToInt32((getInOutRecord.OffDuty2 - getInOutRecord.WorkIn2).Value.TotalMinutes);
|
||
}
|
||
}
|
||
int m3 = 0;
|
||
if (getInOutRecord.WorkIn3.HasValue || getInOutRecord.OffDuty3.HasValue)
|
||
{
|
||
m3 = 240;
|
||
if (getInOutRecord.WorkIn3.HasValue && getInOutRecord.OffDuty3.HasValue)
|
||
{
|
||
m3 = Convert.ToInt32((getInOutRecord.OffDuty3 - getInOutRecord.WorkIn3).Value.TotalMinutes);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
getInOutRecord.ManHours = Convert.ToInt32(Math.Ceiling((m1 + m2 + m3) * 1.0 / 60));
|
||
getInOutRecord.ManOverHours = Convert.ToInt32(Math.Ceiling(m3 * 1.0 / 60));
|
||
|
||
}
|
||
}
|
||
}
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
#endregion
|
||
|
||
#region 获取单位信息
|
||
/// <summary>
|
||
/// 获取单位信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static Model.T_d_department GetSupDep(string projectId, int? departmentID, int ParentID)
|
||
{
|
||
var getDep = Funs.DB.T_d_department.FirstOrDefault(x => x.ProjectId == projectId && x.DepartmentID == departmentID);
|
||
if (getDep != null)
|
||
{
|
||
if (getDep.ParentID == ParentID)
|
||
{
|
||
return getDep;
|
||
}
|
||
else
|
||
{
|
||
return GetSupDep(projectId, getDep.ParentID, ParentID);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
///<summary>
|
||
/// 根据出入记录 写入考勤记录
|
||
/// </summary>
|
||
public static void InsertEmployInOutRecord(Model.t_d_facerecordItem drecord, Model.SitePerson_Person getPerson)
|
||
{
|
||
if (drecord.DateTimeRecord.HasValue)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
Model.T_d_EmployInOutRecord newInOutRecord = new Model.T_d_EmployInOutRecord
|
||
{
|
||
NewID = SQLHelper.GetNewID(),
|
||
ProjectId = drecord.ProjectId,
|
||
InstallationName = ProjectService.GetProjectNameByProjectId(drecord.ProjectId),
|
||
RecordDate = drecord.DateTimeRecord.Value.Date,
|
||
IDCardNo = drecord.IDCardNo,
|
||
};
|
||
////获取人员
|
||
if (getPerson != null)
|
||
{
|
||
newInOutRecord.UnitId = getPerson.UnitId;
|
||
newInOutRecord.UnitName = UnitService.GetUnitNameByUnitId(getPerson.UnitId);
|
||
newInOutRecord.DepartmentID = getPerson.TeamGroupId;
|
||
newInOutRecord.DepartName = TeamGroupService.GetTeamGroupNameByTeamGroupId(getPerson.TeamGroupId);
|
||
newInOutRecord.EmployNO = getPerson.CardNo;
|
||
newInOutRecord.EmployName = getPerson.PersonName;
|
||
newInOutRecord.Nation = getPerson.Nation;
|
||
newInOutRecord.NationName = BasicDataService.GetDictNameByDictCode(getPerson.Nation);
|
||
newInOutRecord.PostId = getPerson.WorkPostId;
|
||
newInOutRecord.PostName = WorkPostService.getWorkPostNameById(getPerson.WorkPostId);
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.EmployName = drecord.EmployName;
|
||
newInOutRecord.UnitId = null;
|
||
newInOutRecord.PostId = null;
|
||
}
|
||
|
||
#region 上下班时间
|
||
///上午上班 8
|
||
DateTime TWorkIn1 = drecord.DateTimeRecord.Value.Date.AddHours(8);
|
||
///上午下班 12:30
|
||
DateTime TOffDuty1 = drecord.DateTimeRecord.Value.Date.AddHours(12).AddMinutes(30);
|
||
///下午上班 1:30
|
||
DateTime TWorkIn2 = drecord.DateTimeRecord.Value.Date.AddHours(13).AddMinutes(30);
|
||
///下午下班 7
|
||
DateTime TOffDuty2 = drecord.DateTimeRecord.Value.Date.AddHours(19);
|
||
if (drecord.InOrOut == "进门")
|
||
{
|
||
///上午上班
|
||
if (drecord.DateTimeRecord < TOffDuty1)
|
||
{
|
||
newInOutRecord.WorkIn1 = drecord.DateTimeRecord;
|
||
}
|
||
else if (drecord.DateTimeRecord < TOffDuty2)
|
||
{
|
||
newInOutRecord.WorkIn2 = drecord.DateTimeRecord;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.WorkIn3 = drecord.DateTimeRecord;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
///上午下班
|
||
if (drecord.DateTimeRecord < TWorkIn2)
|
||
{
|
||
newInOutRecord.OffDuty1 = drecord.DateTimeRecord;
|
||
}
|
||
else if (drecord.DateTimeRecord < TOffDuty2.AddHours(1))
|
||
{
|
||
newInOutRecord.OffDuty2 = drecord.DateTimeRecord;
|
||
}
|
||
else
|
||
{
|
||
newInOutRecord.OffDuty3 = drecord.DateTimeRecord;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
bool isInsert = false;
|
||
var getInOutRecord = db.T_d_EmployInOutRecord.FirstOrDefault(x => x.ProjectId == drecord.ProjectId && x.IDCardNo == drecord.IDCardNo && x.RecordDate == drecord.DateTimeRecord.Value.Date);
|
||
if (getInOutRecord == null)
|
||
{
|
||
isInsert = true;
|
||
}
|
||
if (isInsert)
|
||
{
|
||
newInOutRecord.ManHours = 4;
|
||
newInOutRecord.ManOverHours = 0;
|
||
db.T_d_EmployInOutRecord.InsertOnSubmit(newInOutRecord);
|
||
db.SubmitChanges();
|
||
}
|
||
else
|
||
{
|
||
#region 计算人工时
|
||
if (newInOutRecord.WorkIn1.HasValue && (!getInOutRecord.WorkIn1.HasValue || getInOutRecord.WorkIn1 > newInOutRecord.WorkIn1))
|
||
{
|
||
getInOutRecord.WorkIn1 = newInOutRecord.WorkIn1;
|
||
}
|
||
if (newInOutRecord.WorkIn2.HasValue && (!getInOutRecord.WorkIn2.HasValue || getInOutRecord.WorkIn2 > newInOutRecord.WorkIn2))
|
||
{
|
||
getInOutRecord.WorkIn2 = newInOutRecord.WorkIn2;
|
||
}
|
||
if (newInOutRecord.WorkIn3.HasValue && (!getInOutRecord.WorkIn3.HasValue || getInOutRecord.WorkIn3 > newInOutRecord.WorkIn3))
|
||
{
|
||
getInOutRecord.WorkIn3 = newInOutRecord.WorkIn3;
|
||
}
|
||
|
||
if (newInOutRecord.OffDuty1.HasValue && (!getInOutRecord.OffDuty1.HasValue || getInOutRecord.OffDuty1 < newInOutRecord.OffDuty1))
|
||
{
|
||
getInOutRecord.OffDuty1 = newInOutRecord.OffDuty1;
|
||
}
|
||
if (newInOutRecord.OffDuty2.HasValue && (!getInOutRecord.OffDuty2.HasValue || getInOutRecord.OffDuty2 < newInOutRecord.OffDuty2))
|
||
{
|
||
getInOutRecord.OffDuty2 = newInOutRecord.OffDuty2;
|
||
}
|
||
if (newInOutRecord.OffDuty3.HasValue && (!getInOutRecord.OffDuty3.HasValue || getInOutRecord.OffDuty3 < newInOutRecord.OffDuty3))
|
||
{
|
||
getInOutRecord.OffDuty3 = newInOutRecord.OffDuty3;
|
||
}
|
||
int m1 = 0;
|
||
if (getInOutRecord.WorkIn1.HasValue || getInOutRecord.OffDuty1.HasValue)
|
||
{
|
||
m1 = 240;
|
||
if (getInOutRecord.WorkIn1.HasValue && getInOutRecord.OffDuty1.HasValue && getInOutRecord.OffDuty1 > getInOutRecord.WorkIn1)
|
||
{
|
||
m1 = Convert.ToInt32((getInOutRecord.OffDuty1 - getInOutRecord.WorkIn1).Value.TotalMinutes);
|
||
if (m1 < 0)
|
||
{
|
||
m1 = 0;
|
||
}
|
||
}
|
||
}
|
||
int m2 = 0;
|
||
if (getInOutRecord.WorkIn2.HasValue || getInOutRecord.OffDuty2.HasValue)
|
||
{
|
||
m2 = 240;
|
||
if (getInOutRecord.WorkIn2.HasValue && getInOutRecord.OffDuty2.HasValue && getInOutRecord.OffDuty2 > getInOutRecord.WorkIn2)
|
||
{
|
||
m2 = Convert.ToInt32((getInOutRecord.OffDuty2 - getInOutRecord.WorkIn2).Value.TotalMinutes);
|
||
if (m2 < 0)
|
||
{
|
||
m2 = 0;
|
||
}
|
||
}
|
||
}
|
||
int m3 = 0;
|
||
if (getInOutRecord.WorkIn3.HasValue || getInOutRecord.OffDuty3.HasValue)
|
||
{
|
||
m3 = 240;
|
||
if (getInOutRecord.WorkIn3.HasValue && getInOutRecord.OffDuty3.HasValue && getInOutRecord.OffDuty3 > getInOutRecord.WorkIn3)
|
||
{
|
||
m3 = Convert.ToInt32((getInOutRecord.OffDuty3 - getInOutRecord.WorkIn3).Value.TotalMinutes);
|
||
if (m3 < 0)
|
||
{
|
||
m3 = 0;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
getInOutRecord.ManHours = Convert.ToInt32(Math.Ceiling((m1 + m2 + m3) * 1.0 / 60));
|
||
getInOutRecord.ManOverHours = Convert.ToInt32(Math.Ceiling(m3 * 1.0 / 60));
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|