프로그래밍
UpdateList_AttendList SQLDB 활용 예제
준이바라기얍
2021. 9. 5. 12:05
반응형
- UpdateList_AttendList SQLDB 활용 예제
private void UpdateList_AttendList()
{
if (this.intUserKey != 0)
{
try
{
this.Cursor = Cursors.WaitCursor;
int num6 = 0;
int num4 = 0;
int num2 = 0;
int num3 = 0;
this.intStaticAttendCount = 0;
this.intStaticLateCount = 0;
this.intStaticHomeCount = 0;
this.intStaticEarlyCount = 0;
this.intStaticAbsentCount = 0;
DataTable tbl1 = PLAcaDBManager.UsersAttendSelectListMonth(intUserKey, dtpRegDate.GetStartDate(), dtpRegDate.GetEndDate());
if(tbl1 != null && tbl1.Rows.Count > 0)
{
foreach (DataRow dr in tbl1.Rows)
{
string str2 = dr["AttendResult"].ToString();
if (str2 == "출근")
{
this.intStaticAttendCount++;
}
else if (str2 == "지각")
{
this.intStaticLateCount++;
}
else
{
this.intStaticAbsentCount++;
}
if (!dr.IsNull("Home"))
{
switch (dr["HomeResult"].ToString())
{
case "퇴근":
this.intStaticHomeCount++;
break;
case "조퇴":
this.intStaticEarlyCount++;
break;
}
num4 = Convert.ToInt32((Convert.ToDateTime(dr["Attend"]) - Convert.ToDateTime(dr["Home"])).TotalMinutes);
if (num4 < 0)
{
num4 += 1440;
}
num2 += num4;
if (num4 > 60)
{
num6 = num4 % 60;
}
}
}
}
int backRow = gridAttendListView.FocusedRowHandle;
gridAttendList.DataSource = null;
gridAttendList.DataSource = PLAcaDBManager.UsersAttendSelect(intUserKey, dtpRegDate.GetStartDate(), dtpRegDate.GetEndDate());
gridAttendListView.FocusedRowHandle = backRow;
DataTable tbl = PLAcaDBManager.UsersAttendMonthlyMemoSelect(intUserKey, dtpRegDate.GetStartDate().Year, dtpRegDate.GetStartDate().Month);
if(tbl != null && tbl.Rows.Count > 0)
{
foreach(DataRow dr in tbl.Rows)
{
this.txtAttendMonthlyMemo.Text = dr["AttendMemo"].ToString();
}
}
else
{
this.txtAttendMonthlyMemo.Text = "";
}
this.txtAttendCount.Text = Convert.ToString(this.intStaticAttendCount) + "일";
this.txtLateCount.Text = Convert.ToString(this.intStaticLateCount) + "일";
this.txtHomeCount.Text = Convert.ToString(this.intStaticHomeCount) + "일";
this.txtEarlyCount.Text = Convert.ToString(this.intStaticEarlyCount) + "일";
this.txtAbsentCount.Text = Convert.ToString(this.intStaticAbsentCount) + "일";
this.txtAttendRate1.Text = Convert.ToString((int)Math.Round((double)((((double)this.intStaticAttendCount) / 20.0) * 100.0))) + "%";
this.txtAttendRate2.Text = Convert.ToString((int)Math.Round((double)((((double)this.intStaticAttendCount) / 25.0) * 100.0))) + "%";
if ((this.intStaticAttendCount + this.intStaticAbsentCount) > 0)
{
this.txtAttendRate3.Text = Convert.ToString((int)Math.Round((double)((((double)this.intStaticAttendCount) / ((double)(this.intStaticAttendCount + this.intStaticAbsentCount))) * 100.0))) + "%";
}
else
{
this.txtAttendRate3.Text = "0%";
}
if (num2 > 60)
{
num6 = num2 % 60;
this.txtWorkTime.Text = Convert.ToString(Math.Floor((double)(((double)num2) / 60.0))) + "시간 " + num6.ToString() + "분";
}
else
{
this.txtWorkTime.Text = num2.ToString() + "분";
}
if (this.intStaticAttendCount == 0)
{
num3 = 0;
}
else
{
num3 = (int)Math.Round((double)(((double)num3) / ((double)this.intStaticAttendCount)));
}
if (num3 > 60)
{
this.txtWorkTimeAvg.Text = Convert.ToString(Math.Floor((double)(((double)num3) / 60.0))) + "시간 " + ((num3 % 60)).ToString() + "분";
}
else
{
this.txtWorkTimeAvg.Text = num3.ToString() + "분";
}
}
catch (Exception ee)
{
TraceManager.AddLog(string.Format("{0}r\n{1}", ee.StackTrace, ee.Message));
System.Diagnostics.Debug.WriteLine(string.Format("{0}r\n{1}", ee.StackTrace, ee.Message));
}
finally
{
this.Cursor = Cursors.Default;
}
}
}
반응형