public override void FillingRecord()
{
int pid = 0;
OutgoingWebResponseContext outgoingResponse = WebOperationContext.Current.OutgoingResponse;
outgoingResponse.Headers.Add("Cache-Control", "no-cache");
outgoingResponse.Headers.Add("Pragma", "no-cache");
IList<AttendanceMember> list = new List<AttendanceMember>();
DateTime now = DateTime.Now;
int checkStatus = 0;
using (SqlDatabase db = new SqlDatabase())
{
//获取考勤参考时间
db.Parameters.Clear();
db.CommandText = "SELECT * FROM [dk_Attendance_Members]";
using (DataReaderWrapper dr = db.ExecuteReader())
{
while (dr.Read())
{
AttendanceMember msg = new AttendanceMember();
msg.AttendanceID = dr.GetInt32("AttendanceID");
msg.MemberID = dr.GetInt32("MemberID");
msg.CheckInTime = dr.GetDateTime("CheckInTime");
msg.CheckOutTime = dr.GetDateTime("CheckOutTime");
msg.Status = (AttendanceStatus)dr.GetInt32("Status");
list.Add(msg);
if (dr.Read())
{
DateTime checkInTimeStr = dr.GetDateTime("CheckInTime");
DateTime checkOutTimeStr = dr.GetDateTime("CheckOutTime");
pid = dr.GetInt32("MemberID");
checkStatus = dr.GetInt32("Status");
dr.Close();
string today = now.ToString("yyyy-MM-dd");
//确定今天是否已有的考勤记录
db.Parameters.Clear();
db.CommandText = "SELECT MemberID,CheckInTime, CheckOutTime FROM [dk_Attendance_Records] WHERE [MemberID] = @PID AND [AttendanceDate] = @Today";
db.CreateParameter<int>("@PID", pid, System.Data.SqlDbType.Int);
db.CreateParameter<string>("@Today", today, System.Data.SqlDbType.VarChar, 10);
bool hasRecord = false;
DateTime amTime = new DateTime();
DateTime pmTime = new DateTime();
using (DataReaderWrapper drw = db.ExecuteReader())
{
if (drw.Read())
{
//已有考勤记录,读取上下班的时间记录。
hasRecord = true;
amTime = drw.GetDateTime("CheckInTime");
pmTime = drw.GetDateTime("CheckOutTime");
}
drw.Close();
}
bool isAM = now.Hour <= 12;//是否上午