Ejemplo n.º 1
0
    private void DoSubmit()
    {
        if (Session["FlowVerifyInfo"] != null)
        {
            Dictionary <string, string> oVerifyInfo = (Dictionary <string, string>)Session["FlowVerifyInfo"];
            Dictionary <string, string> dic         = (Dictionary <string, string>)Session["PunchAppdOperation_GridView"];
            Dictionary <string, string> toUserData  = (Dictionary <string, string>)Session["PunchAppdOperation_toUserData"];
            Util.setJSContent(oVerifyInfo["FlowVerifyJS"]);
            Session["FlowVerifyInfo"] = null;
            Punch_Confirm_Remedy_Bean model = new Punch_Confirm_Remedy_Bean()
            {
                //跟共用條件
                CompID      = dic["CompID"],
                EmpID       = dic["EmpID"],
                EmpName     = dic["EmpName"],
                LastChgComp = UserInfo.getUserInfo().CompID.Trim(),
                LastChgID   = UserInfo.getUserInfo().UserID.Trim(),
                LastChgDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),

                //預存所需資料
                PunchTime        = dic["PunchTime"],
                ConfirmPunchFlag = dic["ConfirmPunchFlag"],
                DutyTime         = dic["DutyTime"],
                RestBeginTime    = dic["RestBeginTime"],
                RestEndTime      = dic["RestEndTime"],

                //Remedy所需資料
                PunchDate      = dic["PunchDate"],
                PunchRemedySeq = dic["PunchRemedySeq"],
                FlowCaseID     = dic["FlowCaseID"],
                ValidDateTime  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                ValidCompID    = UserInfo.getUserInfo().CompID.Trim(),
                ValidID        = UserInfo.getUserInfo().UserID.Trim(),
                ValidName      = UserInfo.getUserInfo().UserName.Trim(),

                //Confirm所需資料
                DutyDate                = dic["DutyDate"],
                PunchConfirmSeq         = dic["PunchConfirmSeq"],
                RemedyReasonID          = dic["RemedyReasonID"],
                RemedyReasonCN          = dic["RemedyReasonCN"],
                RemedyPunchTime         = dic["RemedyPunchTime"],
                Remedy_MAFT10_FLAG      = dic["Remedy_MAFT10_FLAG"],
                Remedy_AbnormalFlag     = dic["Remedy_AbnormalFlag"],
                Remedy_AbnormalReasonID = dic["Remedy_AbnormalReasonID"],
                Remedy_AbnormalReasonCN = dic["Remedy_AbnormalReasonCN"],
                Remedy_AbnormalDesc     = dic["Remedy_AbnormalDesc"]
            };

            switch (oVerifyInfo["FlowStepBtnID"].ToString())
            {
            //PORemedyStatus。0:未處理,1:未送簽,2:送簽中,3:核准,4:駁回
            //ConfirmStatus。0:正常,1:異常,2:送簽中,3:異常不控管
            case "btnClose":
                model.PORemedyStatus = "3";
                string strConfirmStatus = "", strAbnormalType = "";
                if (!PunchUpdate.PunchAppdOperation_EXEC_PunchCheckData(model, out strConfirmStatus, out strAbnormalType))
                {
                    Util.MsgBox("打卡異常檢核失敗!!");
                    return;
                }
                model.ConfirmStatus = strConfirmStatus;     //0 or 1記得用John的TSQL
                model.AbnormalType  = strAbnormalType;
                break;

            case "btnApprove":
            case "btnReApprove":
                model.PORemedyStatus = "2";
                model.ConfirmStatus  = "2";
                break;

            case "btnReject":
                model.PORemedyStatus = "4";
                model.ConfirmStatus  = "1";
                break;
            }
            Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]);
            DataTable LastHROtherFlowLog        = PunchUpdate.HROtherFlowLog(model.FlowCaseID, true);
            long      seccessCount = 0;
            string    msg          = "";
            bool      result       = false;
            result = PunchUpdate.PunchAppdOperation_SaveData(model, oAssDic, oVerifyInfo["FlowStepBtnID"].ToString(), oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), out seccessCount, out msg, LastHROtherFlowLog.Rows[0]["FlowCode"].ToString(), LastHROtherFlowLog.Rows[0]["FlowSN"].ToString(), LastHROtherFlowLog.Rows[0]["FlowSeq"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogBatNo"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogID"].ToString(), toUserData);

            if (result)
            {
                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
            }
            else
            {
                labMsg.Text       = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                txtErrMsg.Text    = msg;
                txtErrMsg.Visible = true;
            }
        }
    }
    private void SaveData()
    {
        string ErrorIndex = "";

        for (int index = 0; index < gvMain.Rows.Count; index++)
        {
            CheckBox objchk = (CheckBox)gvMain.Rows[index].FindControl("chkChoiced");
            if (objchk.Checked == true)
            {
                bool   result = false;
                long   seccessCount = 0;
                string msg = "", flowCode = "", flowSN = "";
                string btnName = "";

                RadioButton rdoApp    = (RadioButton)gvMain.Rows[index].FindControl("rbnApproved");
                RadioButton rdoRej    = (RadioButton)gvMain.Rows[index].FindControl("rbnReject");
                TextBox     txtReason = (TextBox)gvMain.Rows[index].FindControl("txtReason");

                Dictionary <string, string> dic        = new Dictionary <string, string>();
                Dictionary <string, string> toUserData = new Dictionary <string, string>();
                PunchUpdate.GridViewToDictionary(gvMain, out dic, index, strDataKeyNames);
                Punch_Confirm_Remedy_Bean model = new Punch_Confirm_Remedy_Bean()
                {
                    //跟共用條件
                    CompID      = dic["CompID"],
                    EmpID       = dic["EmpID"],
                    EmpName     = dic["EmpName"],
                    LastChgComp = UserInfo.getUserInfo().CompID.Trim(),
                    LastChgID   = UserInfo.getUserInfo().UserID.Trim(),
                    LastChgDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),

                    //預存所需資料
                    PunchTime        = dic["PunchTime"],
                    ConfirmPunchFlag = dic["ConfirmPunchFlag"],
                    DutyTime         = dic["DutyTime"],
                    RestBeginTime    = dic["RestBeginTime"],
                    RestEndTime      = dic["RestEndTime"],
                    //Remedy所需資料
                    PunchDate      = dic["PunchDate"],
                    PunchRemedySeq = dic["PunchRemedySeq"],
                    FlowCaseID     = dic["FlowCaseID"],
                    ValidDateTime  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                    ValidCompID    = UserInfo.getUserInfo().CompID.Trim(),
                    ValidID        = UserInfo.getUserInfo().UserID.Trim(),
                    ValidName      = UserInfo.getUserInfo().UserName.Trim(),

                    //Confirm所需資料
                    DutyDate                = dic["DutyDate"],
                    PunchConfirmSeq         = dic["PunchConfirmSeq"],
                    RemedyReasonID          = dic["RemedyReasonID"],
                    RemedyReasonCN          = dic["RemedyReasonCN"],
                    RemedyPunchTime         = dic["RemedyPunchTime"],
                    Remedy_MAFT10_FLAG      = dic["Remedy_MAFT10_FLAG"],
                    Remedy_AbnormalFlag     = dic["Remedy_AbnormalFlag"],
                    Remedy_AbnormalReasonID = dic["Remedy_AbnormalReasonID"],
                    Remedy_AbnormalReasonCN = dic["Remedy_AbnormalReasonCN"],
                    Remedy_AbnormalDesc     = dic["Remedy_AbnormalDesc"]
                };

                if (rdoApp.Checked == true)                                                                  //核准
                {
                    if (!nextFlowBtn(model, out flowCode, out flowSN, ref btnName, out toUserData, out msg)) //判斷審核按鈕
                    {
                        Util.MsgBox(msg);
                        return;
                    }
                    switch (btnName)
                    {
                    //PORemedyStatus。0:未處理,1:未送簽,2:送簽中,3:核准,4:駁回
                    //ConfirmStatus。0:正常,1:異常,2:送簽中,3:異常不控管
                    case "btnClose":
                        model.PORemedyStatus = "3";
                        string strConfirmStatus = "", strAbnormalType = "";
                        if (!PunchUpdate.PunchAppdOperation_EXEC_PunchCheckData(model, out strConfirmStatus, out strAbnormalType))
                        {
                            Util.MsgBox("打卡異常檢核失敗!!");
                            return;
                        }
                        model.ConfirmStatus = strConfirmStatus;     //0 or 1記得用John的TSQL
                        model.AbnormalType  = strAbnormalType;
                        break;

                    case "btnApprove":
                    case "btnReApprove":
                        model.PORemedyStatus = "2";
                        model.ConfirmStatus  = "2";
                        break;
                    }
                }
                else if (rdoRej.Checked == true)//駁回
                {
                    btnName = "btnReject";
                    model.PORemedyStatus = "4";
                    model.ConfirmStatus  = "1";
                }

                DataTable LastHROtherFlowLog        = PunchUpdate.HROtherFlowLog(model.FlowCaseID, true);
                Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]);

                if (!string.IsNullOrEmpty(btnName))
                {
                    //審核動作
                    result = PunchUpdate.PunchAppdOperation_SaveData(model, oAssDic, btnName, txtReason.Text, out seccessCount, out msg, flowCode, flowSN, LastHROtherFlowLog.Rows[0]["FlowSeq"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogBatNo"].ToString(), LastHROtherFlowLog.Rows[0]["FlowLogID"].ToString(), toUserData);
                }
                else
                {
                    result = false;
                }

                if (!result)
                {
                    //Util.MsgBox(msg);
                    ErrorIndex += (index + 1).ToString() + ",";
                    continue;
                }
                if (seccessCount == 0)
                {
                    ErrorIndex += (index + 1).ToString() + ",";
                    continue;
                }
            }
        }
        if (ErrorIndex.Length > 0)
        {
            ErrorIndex = ErrorIndex.Substring(0, ErrorIndex.Length - 1);
            Util.MsgBox("第" + ErrorIndex + "筆審核失敗");
        }
        else
        {
            Util.MsgBox("審核成功");
        }
    }
    private bool nextFlowBtn(Punch_Confirm_Remedy_Bean Bean, out string flowCode, out string flowSN, ref string btnName, out Dictionary <string, string> toUserData, out string msg)
    {
        flowCode   = ""; flowSN = ""; msg = "";
        toUserData = new Dictionary <string, string>();
        string OTEmpID    = Bean.EmpID,
               AssignTo   = Bean.ValidID,
               CompID     = Bean.CompID,
               PunchDate  = Bean.PunchDate,
               FlowCaseID = Bean.FlowCaseID;

        bool IsUpValidRankID = true;
        bool IsUpEmpRankID   = false;

        bool   isLastFlow, nextIsLastFlow;
        string signLineDefine = "", meassge = "";
        string SignOrganID = "", SignID = "", SignIDComp = "";

        string        FlowStepID = "";
        DbHelper      db         = new DbHelper(Aattendant._AattendantDBName);
        CommandHelper sb         = db.CreateCommandHelper();

        sb.Reset();
        sb.Append("SELECT FlowStepID from " + FlowCustDB + "FlowOpenLog ");
        sb.Append(" where FlowCaseID=").AppendParameter("FlowCaseID", FlowCaseID);
        try
        {
            FlowStepID = db.ExecuteScalar(sb.BuildCommand()).ToString();
        }
        catch (Exception)
        {
            FlowStepID = "";
            msg        = "永豐流程查無資料";
            return(false);
        }
        //讀取現在關卡與下一關相關資料,因為不論回傳是否,我還是要資料,所以沒檢核return與meassge
        OBFlowUtility.QueryFlowDataAndToUserData(CompID, AssignTo, PunchDate, FlowCaseID, "P",
                                                 out toUserData, out flowCode, out flowSN, out signLineDefine, out isLastFlow, out nextIsLastFlow, out meassge, "PO");

        //如果QueryFlowDataAndToUserData出錯(HR關與改派容易出現沒有下一關卻無法判定現在是最後一關的狀況),會找不到現在是否為最後一關,這裡單獨再找一次
        isLastFlow = isLastFlowNow(Bean.CompID, FlowCaseID, "P", "PO");

        //如果沒有下一關資料,則用現在關卡資料取代(對應上述QueryFlowDataAndToUserData問題 )
        if (toUserData.Count == 0)
        {
            //取[最近的行政or功能]資料 取代 [現在關卡]資料
            DataTable dtHROtherFlowLog_toUD = PunchUpdate.HROtherFlowLog(FlowCaseID, true);
            toUserData.Add("SignLine", dtHROtherFlowLog_toUD.Rows[0]["SignLine"].ToString());
            toUserData.Add("SignIDComp", dtHROtherFlowLog_toUD.Rows[0]["SignIDComp"].ToString());
            toUserData.Add("SignID", AssignTo);
            toUserData.Add("SignOrganID", dtHROtherFlowLog_toUD.Rows[0]["SignOrganID"].ToString());
            toUserData.Add("SignFlowOrganID", dtHROtherFlowLog_toUD.Rows[0]["SignFlowOrganID"].ToString());
        }

        //如果下一關主管與現在主管相同,則再往上階找下一關主管資料
        if (toUserData["SignID"] == AssignTo && signLineDefine != "3")
        {
            switch (toUserData["SignLine"])
            {
            //HR線 或 行政線
            case "4":
            case "1":
                if (EmpInfo.QueryOrganData(Bean.CompID, toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                {
                    toUserData["SignID"]          = SignID;
                    toUserData["SignIDComp"]      = SignIDComp;
                    toUserData["SignOrganID"]     = SignOrganID;
                    toUserData["SignFlowOrganID"] = "";
                }
                break;

            //功能線
            case "2":
                if (EmpInfo.QueryFlowOrganData(toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                {
                    toUserData["SignID"]          = SignID;
                    toUserData["SignIDComp"]      = SignIDComp;
                    toUserData["SignOrganID"]     = "";
                    toUserData["SignFlowOrganID"] = SignOrganID;
                }
                break;

            //原本switch的是signLineDefine,現在改成toUserData["SignLine"]後,
            //case "3"裏頭的if基本只會用到else[非功能線一律走行政線],以防萬一先保留。
            //改派
            case "3":
                if (toUserData["SignLine"] == "2")
                {
                    if (EmpInfo.QueryFlowOrganData(toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                    {
                        toUserData["SignID"]          = SignID;
                        toUserData["SignIDComp"]      = SignIDComp;
                        toUserData["SignOrganID"]     = "";
                        toUserData["SignFlowOrganID"] = SignOrganID;
                    }
                }
                else
                {
                    if (EmpInfo.QueryOrganData(Bean.CompID, toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                    {
                        toUserData["SignID"]          = SignID;
                        toUserData["SignIDComp"]      = SignIDComp;
                        toUserData["SignOrganID"]     = SignOrganID;
                        toUserData["SignFlowOrganID"] = "";
                    }
                }
                break;
            }
        }

        RankIDCheck(CompID, FlowCaseID, out IsUpValidRankID, out IsUpEmpRankID);
        if (signLineDefine == "4")           //HR特別關(後台沒有送簽功能的話,這裡不會用到)
        {
            if (IsUpValidRankID)             //大於Rank16
            {
                Session["btnVisible"] = "2"; //給永豐流程按鈕隱藏判斷
                btnName = "btnClose";        //回傳按鈕名稱,給多筆審核組進DataTable傳給審核畫面
            }
            else
            {
                if (FlowStepID == "A10") //預防HR送錯關,本來資料上HR關是只有A20或A40等最後一關
                {
                    Session["btnVisible"] = "0";
                    btnName = "btnApprove";
                }
                else
                {
                    Session["btnVisible"] = "1";
                    btnName = "btnReApprove";
                }
            }
        }
        else if (!isLastFlowNow(CompID, FlowCaseID, "P", "PO")) //非最後一關
        {
            if (IsUpEmpRankID)                                  //大於Rank19
            {
                Session["btnVisible"] = "2";
                btnName = "btnClose";
            }
            else
            {
                if (nextIsLastFlow) //下一關是否進入A40最後一關
                {
                    Session["btnVisible"] = "0";
                    btnName = "btnApprove";
                }
                else
                {
                    Session["btnVisible"] = "1";
                    btnName = "btnReApprove";
                }
            }
        }
        else//最後一關
        {
            if (OTEmpID.Trim().Equals(UserInfo.getUserInfo().UserID.Trim()))//當加班人是自己主管的代理人並審自己的加班單
            {
                if (IsUpEmpRankID)//加班人RankID>19
                {
                    Session["btnVisible"] = "2";
                    btnName = "btnClose";
                }
                else
                {
                    Session["btnVisible"] = "1";
                    btnName = "btnReApprove";
                }
            }
            else if (IsUpValidRankID)//大於Rank16
            {
                Session["btnVisible"] = "2";
                btnName = "btnClose";
            }
            else
            {
                Session["btnVisible"] = "1";
                btnName = "btnReApprove";
            }
        }

        //如果找不到下一關主管資料,彈跳視窗並且return false
        if (toUserData["SignID"] == "")
        {
            toUserData["SignIDComp"] = UserInfo.getUserInfo().CompID.Trim();
            toUserData["SignID"]     = UserInfo.getUserInfo().UserID.Trim();
            //Util.MsgBox("查無下一關主管資料");
            if (isLastFlow) //最後一關不用找下一關主管
            {
                return(true);
            }
            else
            {
                msg = "查無下一關主管資料";
                return(false);
            }
        }
        return(true);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 檢核所有東西,並將下一關相關資訊回傳
    /// </summary>
    public static bool nextAssignTo(Punch_Confirm_Remedy_Bean Bean, out Dictionary <string, string> toUserData)
    {
        string
            CompID      = Bean.CompID,
            AssignTo    = Bean.ValidID,
            OTStartDate = Bean.PunchDate,
            FlowCaseID  = Bean.FlowCaseID;

        bool   isLastFlow, nextIsLastFlow;
        string flowCode = "", flowSN = "", signLineDefine = "", meassge = "";

        string SignOrganID = "", SignID = "", SignIDComp = "";

        //讀取現在關卡與下一關相關資料,因為不論回傳是否,我還是要資料,所以沒檢核回傳值與錯誤訊息
        OBFlowUtility.QueryFlowDataAndToUserData(CompID, AssignTo, OTStartDate, FlowCaseID, "P",
                                                 out toUserData, out flowCode, out flowSN, out signLineDefine, out isLastFlow, out nextIsLastFlow, out meassge, "PO");

        //若是後台HR送簽依照填單人公司,否則用加班人公司
        //string HRLogCompID = signLineDefine == "4" || flowCode.Trim() == "" ?Bean.CompID :Bean.CompID;
        string HRLogCompID = Bean.CompID;

        //如果沒有下一關資料,則用現在關卡資料取代
        if (toUserData.Count == 0)
        {
            //取[最近的行政or功能]資料 取代 [現在關卡]資料
            DataTable dtHROtherFlowLog_toUD = PunchUpdate.HROtherFlowLog(FlowCaseID, true);
            toUserData.Add("SignLine", dtHROtherFlowLog_toUD.Rows[0]["SignLine"].ToString());
            toUserData.Add("SignIDComp", dtHROtherFlowLog_toUD.Rows[0]["SignIDComp"].ToString());
            toUserData.Add("SignID", AssignTo);
            toUserData.Add("SignOrganID", dtHROtherFlowLog_toUD.Rows[0]["SignOrganID"].ToString());
            toUserData.Add("SignFlowOrganID", dtHROtherFlowLog_toUD.Rows[0]["SignFlowOrganID"].ToString());
        }

        //如果下一關主管與現在主管相同,則再往上階找下一關主管資料
        if (toUserData["SignID"] == AssignTo && signLineDefine != "3")
        {
            switch (toUserData["SignLine"])
            {
            //HR線 或 行政線
            case "4":
            case "1":
                if (EmpInfo.QueryOrganData(HRLogCompID, toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                {
                    toUserData["SignID"]          = SignID;
                    toUserData["SignIDComp"]      = SignIDComp;
                    toUserData["SignOrganID"]     = SignOrganID;
                    toUserData["SignFlowOrganID"] = "";
                }
                break;

            //功能線
            case "2":
                if (EmpInfo.QueryFlowOrganData(toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                {
                    toUserData["SignID"]          = SignID;
                    toUserData["SignIDComp"]      = SignIDComp;
                    toUserData["SignOrganID"]     = "";
                    toUserData["SignFlowOrganID"] = SignOrganID;
                }
                break;

            //原本switch的是signLineDefine,現在改成toUserData["SignLine"]後,
            //case "3"裏頭的if基本只會用到else[非功能線一律走行政線],以防萬一先保留。
            //改派
            case "3":
                if (toUserData["SignLine"] == "2")
                {
                    if (EmpInfo.QueryFlowOrganData(toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                    {
                        toUserData["SignID"]          = SignID;
                        toUserData["SignIDComp"]      = SignIDComp;
                        toUserData["SignOrganID"]     = "";
                        toUserData["SignFlowOrganID"] = SignOrganID;
                    }
                }
                else
                {
                    if (EmpInfo.QueryOrganData(HRLogCompID, toUserData["SignOrganID"], Bean.PunchDate, out SignOrganID, out SignID, out SignIDComp))
                    {
                        toUserData["SignID"]          = SignID;
                        toUserData["SignIDComp"]      = SignIDComp;
                        toUserData["SignOrganID"]     = SignOrganID;
                        toUserData["SignFlowOrganID"] = "";
                    }
                }
                break;
            }
        }

        //如果找不到下一關主管資料,彈跳視窗並且return false
        if (toUserData["SignID"] == "")
        {
            toUserData["SignIDComp"] = UserInfo.getUserInfo().CompID.Trim();
            toUserData["SignID"]     = UserInfo.getUserInfo().UserID.Trim();
            //Util.MsgBox("查無下一關主管資料");
            if (isLastFlow) //最後一關不用找下一關主管
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        return(true);
    }