private void Page_Load(object sender, System.EventArgs e) { //考勤操作 try { WA_Duty wd = new WA_Duty(Int32.Parse(Request.Cookies["UserID"].Value.Trim())); int DutyStat = 0; DutyStat = wd.HaveCompletedDuty(DateTime.Now); //检查当天是否已经完成上班考勤 if ((DutyStat != -1) && (DutyStat != 0)) { if (wd.CheckStatus(DutyAction.OffDuty)) //没有早退 { wd.RecordOffDutyData(DutyStat, DateTime.Now, true, ""); //弹出新页面表示成功 Response.Write("<script language=javascript>window.open('../WorkAttendance/checksucessful.aspx?login=out','_blank','height=200,width=400,status=no,toolbar=no,menubar=no,location=no')</script>"); } else //早退 { //跳转到填写理由页面 Response.Write("<script language=javascript>location.href='../WorkAttendance/Default.aspx?notnormal=1&login=out';</script>"); } } Response.Write("<script>window.parent.parent.location.href='logout.aspx';</script>"); } catch (Exception ex) { UDS.Components.Error.Log(ex.Message); Server.Transfer("../Error.aspx"); } }
private void DutyOperation() { //try //{ WA_Duty wd = new WA_Duty(Int32.Parse(Request.Cookies["UserID"].Value.Trim())); int Duty = wd.HaveCompletedDuty(DateTime.Now); //检查当天是否已经完成上班考勤 if (Duty == -1) { if (wd.CheckStatus(DutyAction.OnDuty)) //没有迟到 { wd.RecordOnDutyData(DateTime.Now, true, "").ToString(); //弹出新页面表示成功 Response.Write("<script language=javascript>window.open('../WorkAttendance/checksucessful.aspx?login=in','_blank','height=200,width=400,status=no,toolbar=no,menubar=no,location=no')</script>"); } else //迟到 { //跳转到填写理由页面 Response.Redirect("../WorkAttendance/Default.aspx?notnormal=1&login=in"); } } //} //catch(Exception ex) //{ // //UDS.Components.Error.Log(ex.Message); // //Server.Transfer("../Error.aspx"); //} }
protected void btnCheckAttendance_Click(object sender, System.EventArgs e) { try { WA_Duty wd = new WA_Duty(Int32.Parse(Request.Cookies["UserID"].Value.Trim())); //检查当天是否已经完成考勤 int Duty = wd.HaveCompletedDuty(DateTime.Now); if (Duty == 0) { lblDutyMessage.Text = "你已经完成了今天的考勤!"; btnCheckAttendance.Visible = false; } else { //检查是否迟到早退 if (DutyStatus == true) //上班考勤 { if (((Button)(sender)).CommandArgument.ToString() != "notnormal") { if (wd.CheckStatus(DutyAction.OnDuty)) { wd.RecordOnDutyData(DateTime.Now, true, "").ToString(); lblDutyMessage.Text = "正常上班没有迟到。考勤成功!"; btnCheckAttendance.Visible = false; DutyStatus = false; } else { lblDutyMessage.Text = "上班迟到,请填写理由!"; txtAttendanceMemo.Visible = true; btnCheckAttendance.Text = "上班"; btnCheckAttendance.CommandArgument = "notnormal"; } } else { wd.RecordOnDutyData(DateTime.Now, false, txtAttendanceMemo.Text).ToString(); lblDutyMessage.Text = "上班迟到。考勤成功!"; txtAttendanceMemo.Visible = false; btnCheckAttendance.Visible = false; DutyStatus = false; btnCheckAttendance.CommandArgument = ""; } } else //下班考勤 { if (((Button)(sender)).CommandArgument.ToString() != "notnormal") { if (wd.CheckStatus(DutyAction.OffDuty)) { wd.RecordOffDutyData(Duty, DateTime.Now, true, ""); lblDutyMessage.Text = "正常下班没有早退。考勤成功!"; btnCheckAttendance.Visible = false; DutyStatus = true; } else { lblDutyMessage.Text = "下班早退,请填写理由!"; txtAttendanceMemo.Visible = true; btnCheckAttendance.Text = "下班"; btnCheckAttendance.CommandArgument = "notnormal"; } } else { wd.RecordOffDutyData(Duty, DateTime.Now, false, txtAttendanceMemo.Text); lblDutyMessage.Text = "下班早退。考勤成功!"; txtAttendanceMemo.Visible = false; btnCheckAttendance.Visible = false; DutyStatus = true; btnCheckAttendance.CommandArgument = ""; } } } GridBind(); } catch (Exception ex) { UDS.Components.Error.Log(ex.Message); Server.Transfer("../Error.aspx"); } }