public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string WorkNo = context.Request.QueryString["WorkNo"];
            string KQDate = context.Request.QueryString["KQDate"];
            string ShiftNo = context.Request.QueryString["ShiftNo"];
            string sResult = "";

            Bll_AbnormalAttendanceHandle bll_abnormal = new Bll_AbnormalAttendanceHandle();
            DataTable dt_Card = new DataTable();

            dt_Card = bll_abnormal.GetBellCardData(WorkNo, KQDate, ShiftNo);
            sResult = "<table cellspacing=0 cellpadding=0 width=100%>";
            sResult += "<tr>";
            sResult += "<td class=td_label align=center height=25 width=20>No</td>";
            sResult += "<td class=td_label height=25 width=60>" + Message.WorkNo + "</td>";
            sResult += "<td class=td_label height=25 width=70>" + Message.LocalName + "</td>";
            sResult += "<td class=td_label height=25 width=140>" + Message.CardTime + "</td>";
            sResult += "<td class=td_label height=25 width=90>" + Message.BellNo + "</td>";
            sResult += "<td class=td_label height=25 width=140>" + Message.ReadTime + "</td>";
            sResult += "<td class=td_label height=25 width=80>" + Message.CardNo + "</td>";
            sResult += "</tr>";

            if (dt_Card != null && dt_Card.Rows.Count > 0)
            {
                for (int i = 0; i <dt_Card.Rows.Count; i++)
                {
                    string temp_WorkNo = dt_Card.Rows[i]["WORKNO"].ToString();
                    string temp_LocalName = dt_Card.Rows[i]["LOCALNAME"].ToString();
                    string temp_CardTime = dt_Card.Rows[i]["CARDTIME"].ToString();
                    string temp_BellNo = dt_Card.Rows[i]["BELLNO"].ToString();
                    string temp_ReadTime = dt_Card.Rows[i]["READTIME"].ToString();
                    string temp_CardNo = dt_Card.Rows[i]["CARDNO"].ToString();

                    sResult += "<tr>";
                    sResult += "<td class=td_label align=center height=25>" + (i+1).ToString() + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_WorkNo + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_LocalName + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_CardTime + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_BellNo + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_ReadTime + "</td>";
                    sResult += "<td class=td_label height=25>" + temp_CardNo + "</td>";
                    sResult += "</tr>";
                }

            }
            sResult += "</table>";
            context.Response.Write(sResult);
        }
 //考勤異常簽核單KQE
 protected void UltraWebGridKQE_DataBound(object sender, EventArgs e)
 {
     string WorkNo = "", KqDate = "";
     Bll_AbnormalAttendanceHandle bll_getExcep = new Bll_AbnormalAttendanceHandle();
     for (int i = 0; i < UltraWebGridKQE.Rows.Count; i++)
     {
         WorkNo = UltraWebGridKQE.Rows[i].Cells.FromKey("WorkNo").Value == null ? "" : UltraWebGridKQE.Rows[i].Cells.FromKey("WorkNo").Text;
         KqDate = UltraWebGridKQE.Rows[i].Cells.FromKey("KQDate").Value == null ? "" : Convert.ToDateTime(UltraWebGridKQE.Rows[i].Cells.FromKey("KQDate").Text).ToString("yyyy/MM/dd");
         UltraWebGridKQE.Rows[i].Cells.FromKey("ExcepTionQty").Value = bll_getExcep.GetExceptionqty(WorkNo, KqDate);
     }
 }
        private void Query(string BillNo)
        {
            string condition = "";
            //抓取簽核流程
            condition = "and a.BillNo ='" + BillNo + "'";
            this.dataSet = bll.GetAuditDataByCondition(condition);
            UltraWebGridStatus.DataSource = this.dataSet.Tables["WFM_AuditStatus"].DefaultView;
            UltraWebGridStatus.DataBind();
            //獲取表頭基本信息
            switch (this.HiddenBillTypeNo.Value)
            {
                //case "KQMLeaveApply"://請假申請簽核單OTE
                case "HolidayApplyC"://Holiday (<=5 day) HAC
                case "HolidayApplyD"://Holiday (>5 day) HAD
                case "HolidayApplyH"://Other leave HAH
                case "ExEvection"://國外出差申請簽核單OTE
                case "ExEvectionCancel"://國外銷差申請簽核單ERC
                case "CEMVacReportRequest"://述職/休假申請簽核單VRN
                case "InEvection"://國內出差申請簽核單

                case "InEvectionCancel"://國內銷差申請簽核單

                case "ETMCurriculaPlan"://課程規劃簽核單ECP
                    //condition = "SELECT * FROM (select (case when (select BillTypeCode From BFW_BillType c Where c.BillTypeNo=substr(a.BillNo,0,3))='KQMLeaveApply' " +
                    //        "then (select BillTypeName From BFW_BillType c Where c.BillTypeNo=substr(a.BillNo,0,3))||'-'|| " +
                    //        "(select LVTypeName from KQM_LeaveType c where c.LVTypeCode= " +
                    //        "(select LVTypeCode from kqm_leaveapply d where d.BillNo=a.BillNo and rownum=1)) " +
                    //        "else (select BillTypeName From BFW_BillType c Where c.BillTypeCode=a.BillTypeCode) end) BillTypeName " +
                    //        "from WFM_Bill a " +
                    //        "Where a.BillNo ='" + BillNo + "')";
                    //this.labelBillTypeName.Text = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetFunctionData().GetValue(condition);
                    break;
                default:
                    condition = "and a.BillNo ='" + BillNo + "'";
                    this.tempDataTable = bll.GetDataByCondition_Bill(condition).Tables["WFM_Bill"];
                    if (this.tempDataTable.Rows.Count > 0)
                    {
                        this.textBoxOrgName.Text = bll.GetAllDept(tempDataTable.Rows[0]["OrgCode"].ToString(), true);
                        this.HiddenOrgCode.Value = tempDataTable.Rows[0]["OrgCode"].ToString();
                        this.textBoxApplyMan.Text = tempDataTable.Rows[0]["ApplyManName"].ToString();
                        if (tempDataTable.Rows[0]["ApplyDate"].ToString().Length > 0)
                        {
                            this.textBoxApplyDate.Text = string.Format("{0:" + System.Convert.ToString("yyyy/MM/dd") + "}", Convert.ToDateTime(tempDataTable.Rows[0]["ApplyDate"].ToString()));
                        }
                        this.labelBillTypeName.Text = tempDataTable.Rows[0]["BillTypeName"].ToString();
                    }
                    else
                    {
                        Response.Write("<script type='text/javascript'>alert('" + Message.wfm_message_billdeleted + "');window.close();</script>");
                        return;
                    }
                    break;
            }

            string inWorkNum = "0", AdvanceNum = "0", LeaveNum = "0", Percent = "0";

            switch (this.HiddenBillTypeNo.Value)
            {
                case "LeaveTypeA"://辭職申請簽核單LVA
                case "LeaveTypeB"://自離申請簽核單LVB
                case "ExEvection"://國外出差申請簽核單OTE
                case "ExEvectionCancel"://國外銷差申請簽核單ERC
                case "CEMVacReportRequest"://述職/休假申請簽核單VRN
                case "InEvection"://國內出差申請簽核單

                case "InEvectionCancel"://國內銷差申請簽核單

                case "ETMCurriculaPlan"://課程規劃簽核單ECP
                case "SCMRequire"://鞋櫃申請單SCM
                case "OrgMove"://調動申請MVB
                    break;
                default:
                    //今日在職人數
                    condition = "select count(1) from GDS_ATT_EMPLOYEE a where a.flag='Local' and a.Status='0' " +
                                "and a.DCode in (SELECT DepCode FROM GDS_SC_DEPARTMENT START WITH  " +
                                "depcode='" + this.HiddenOrgCode.Value + "' CONNECT BY PRIOR depcode = parentdepcode) ";
                    inWorkNum = bll.GetValue(condition);
                    //今日加班預報人數
                    condition = "select count(1) from GDS_ATT_ADVANCEAPPLY a, GDS_ATT_EMPLOYEE b " +
                                "where a.WorkNo=b.WorkNo and a.OTDate=trunc(sysdate) and b.flag='Local' and b.Status='0' " +
                                "AND b.DCode in (SELECT DepCode FROM GDS_SC_DEPARTMENT START WITH  " +
                                "depcode='" + this.HiddenOrgCode.Value + "' CONNECT BY PRIOR depcode = parentdepcode) ";
                    AdvanceNum = bll.GetValue(condition);
                    //今日請假人數
                    condition = "select count(1) from GDS_ATT_LEAVEAPPLY a, GDS_ATT_EMPLOYEE b " +
                                "where a.WorkNo=b.WorkNo and a.StartDate>=trunc(sysdate) and a.EndDate<=trunc(sysdate) " +
                                "and b.flag='Local' and b.Status='0' " +
                                "AND b.DCode in (SELECT DepCode FROM GDS_SC_DEPARTMENT START WITH  " +
                                "depcode='" + this.HiddenOrgCode.Value + "' CONNECT BY PRIOR depcode = parentdepcode) ";
                    LeaveNum = bll.GetValue(condition);
                    break;
            }
            switch (this.HiddenBillTypeNo.Value)
            {

                case "D001"://加班預報簽核單OTA 需要做的操作
                case "OTMProjectApply":
                    string isProject = bll.GetValue("Select nvl(Max(isProject),'N') from GDS_ATT_ADVANCEAPPLY where billno='" + BillNo + "' and rownum<=1");
                    if (isProject.Equals("Y"))
                    {
                        //this.labelBillTypeName.Text = ((eBFW.Sys.ServiceLocator)Session["serviceLocator"]).GetFunctionData().GetValue("Select BillTypeName From Bfw_BillType Where BillTypeCode='OTMAdvanceApplyG3'");
                        this.HiddenisProject.Value = isProject;
                    }
                    else
                    {
                        this.UltraWebGridOTA.Bands[0].Columns.FromKey("CheckBoxISPay").Hidden = true;
                    }
                    condition = "";
                    condition += "and a.BillNo ='" + BillNo + "'";
                    if (!this.HiddenSFlag.Value.Equals("Y"))
                    {
                        condition += " and a.Status='1'";
                    }
                    this.dataSet = bll.GetDataByCondition(condition);
                    UltraWebGridOTA.Visible = true;
                    UltraWebGridOTA.DataSource = this.dataSet.Tables["OTM_AdvanceApply"].DefaultView;
                    UltraWebGridOTA.DataBind();

                    try
                    {
                        Percent = Convert.ToString(System.Math.Round(Convert.ToDecimal(AdvanceNum) / Convert.ToDecimal(inWorkNum) * 100, 0));
                    }
                    catch (System.Exception)
                    { }
                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" +
                                            Message.wfm_advancenum + AdvanceNum + ";" +
                                            Message.wfm_leavenum + LeaveNum + ";" +
                                            Message.wfm_advancepercent + Percent + "%;" +
                                            Message.wfm_billauditcount + this.dataSet.Tables["OTM_AdvanceApply"].Rows.Count.ToString();
                    break;
                case "KQMApplyOut"://外出申請簽核單KQT 需要做的操作
                    KQMEvectionApplyBll bllKQTOut = new KQMEvectionApplyBll();
                    KQMEvectionApplyModel modelKQTOut = new KQMEvectionApplyModel();
                    modelKQTOut.BillNo = BillNo;
                    //condition += "and a.BillNo ='" + BillNo + "'";
                    DataTable dt = bllKQTOut.GetEvectionList(modelKQTOut);
                    UltraWebGridKQT.Visible = true;
                    UltraWebGridKQT.DataSource = dt.DefaultView;
                    UltraWebGridKQT.DataBind();
                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" +
                                            Message.wfm_advancenum + AdvanceNum + ";" +
                                            Message.wfm_leavenum + LeaveNum + ";" +
                                            Message.wfm_advancepercent + Percent + "%;" +
                                            Message.wfm_billauditcount + dt.Rows.Count.ToString();
                    break;
                case "D002":
                    KQMLeaveApplyExportBll kqmLeaveApply = new KQMLeaveApplyExportBll();
                    LeaveApplyViewModel leaveApplyViewModel = new LeaveApplyViewModel();
                    leaveApplyViewModel.BillNo = BillNo;
                    DataTable dtLeaveApply = kqmLeaveApply.getLeaveApply(leaveApplyViewModel);
                    UltraWebGridLeaveApply.Visible = true;
                    UltraWebGridLeaveApply.DataSource = dtLeaveApply;
                    UltraWebGridLeaveApply.DataBind();
                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" +
                                      Message.wfm_advancenum + AdvanceNum + ";" +
                                      Message.wfm_leavenum + LeaveNum + ";" +
                                      Message.wfm_advancepercent + Percent + "%;" +
                                      Message.wfm_billauditcount + dtLeaveApply.Rows.Count.ToString();
                    break;

                case "KQMException"://考勤異常簽核單KQE
                    string Status = "";
                    condition = "";
                    condition += "and a.BillNo ='" + BillNo + "'";
                    if (!this.HiddenSFlag.Value.Equals("Y"))
                    {
                        Status = "4";
                    }
                    Bll_AbnormalAttendanceHandle bll_signabnormal = new Bll_AbnormalAttendanceHandle();
                    DataTable dt_signabnormal = bll_signabnormal.GetSignAbnormalAttendanceInfo(BillNo, Status);
                    UltraWebGridKQE.DataSource = dt_signabnormal;
                    UltraWebGridKQE.DataBind();
                    UltraWebGridKQE.Visible = true;

                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" + Message.wfm_leavenum + LeaveNum + ";" + Message.wfm_billauditcount + dt_signabnormal.Rows.Count.ToString();
                    break;
                case "KQMMonthTotal"://外出申請簽核單KQT 需要做的操作
                    OTMTotalQryModel modelMonthTotal = new OTMTotalQryModel();
                    OTMTotalQryBll bllOTMQry = new OTMTotalQryBll();
                    modelMonthTotal.BillNo = BillNo;
                    DataTable dt_monthtotal = bllOTMQry.GetOTMQryList(modelMonthTotal);
                    UltraWebGridKQM.Visible = true;
                    UltraWebGridKQM.DataSource = dt_monthtotal.DefaultView;
                    UltraWebGridKQM.DataBind();
                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" +
                                            Message.wfm_advancenum + AdvanceNum + ";" +
                                            Message.wfm_leavenum + LeaveNum + ";" +
                                            Message.wfm_advancepercent + Percent + "%;" +
                                            Message.wfm_billauditcount + dt_monthtotal.Rows.Count.ToString();
                    break;

                #region 免卡人員加班

                case "KQMOTMA":      //免卡人員加班TMA

                    Status = "";
                    condition = "";
                    condition += "and a.BillNo ='" + BillNo + "'";
                    if (!this.HiddenSFlag.Value.Equals("Y"))
                    {
                        Status = "1";
                    }
                    OTMActivityApplyBll activityApplyBll = new OTMActivityApplyBll();
                    DataTable tmaTB = activityApplyBll.getAuditBillInfoByBillNo(condition, Status);// bll_signabnormal.GetSignAbnormalAttendanceInfo(BillNo, Status);
                    UltraWebGridTMA.DataSource = tmaTB;
                    UltraWebGridTMA.DataBind();
                    UltraWebGridTMA.Visible = true;

                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" + Message.wfm_leavenum + LeaveNum + ";" + Message.wfm_billauditcount + tmaTB.Rows.Count.ToString();

                    break;

                #endregion

                #region 未刷補卡

                case "KQMMakeup":   //未刷補卡
                    Status = "";
                    condition = "";
                    condition += "and a.BillNo ='" + BillNo + "'";
                    if (!this.HiddenSFlag.Value.Equals("Y"))
                    {
                        condition += " and a.Status='1' ";
                    }
                    //  Bll_AbnormalAttendanceHandle bll_signabnormal = new Bll_AbnormalAttendanceHandle();
                    // OTMActivityApplyBll KQMMakeupBll = new OTMActivityApplyBll();
                    WorkFlowCardMakeupBll cardMakeupBll = new WorkFlowCardMakeupBll();
                    int totalCount = 0;
                    DataTable tmaKQMMakeupTB = cardMakeupBll.getCardMakeupList(condition, 1, Int32.MaxValue, out totalCount);
                    // DataTable tmaKQMMakeupTB = new DataTable();// bll_signabnormal.GetSignAbnormalAttendanceInfo(BillNo, Status);
                    UltraWebGridKQU.DataSource = tmaKQMMakeupTB;
                    UltraWebGridKQU.DataBind();
                    UltraWebGridKQU.Visible = true;

                    this.labelMessage.Text = Message.wfm_inworknum + inWorkNum + ";" + Message.wfm_leavenum + LeaveNum + ";" + Message.wfm_billauditcount + tmaKQMMakeupTB.Rows.Count.ToString();
                    break;
                #endregion

                default:
                    break;
            }
        }