Ejemplo n.º 1
0
    /// <summary>
    /// Insert_UpdateVisitFormSign
    /// 公出申請、公出修改
    /// 申請後送簽流程
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool Insert_UpdateVisitFormSign(OnBizPublicOutModel model, string regStr, out long seccessCount, out string msg)
    {
        bool result = false;

        seccessCount = 0;
        msg          = "";
        try
        {
            Dictionary <string, string> ValidUserData = new Dictionary <string, string>();
            FlowExpress flow                       = new FlowExpress(Util.getAppSetting("app://AattendantDB_OnBiz/"));
            string      KeyValue                   = "";//字串
            string[]    strarray                   = null;
            string      strFlowCaseID              = "";
            Dictionary <string, string> empData    = new Dictionary <string, string>();
            Dictionary <string, string> toUserData = new Dictionary <string, string>();
            string flowCode       = "";
            string flowSN         = "";
            bool   nextIsLastFlow = false;
            string meassge        = "";

            DbHelper      db = new DbHelper(_attendantDBName);
            CommandHelper sb = db.CreateCommandHelper();
            DbConnection  cn = db.OpenConnection();

            OnBizPublicOutBean dataBean = new OnBizPublicOutBean()
            {
                CompID            = model.CompID,
                oldCompID         = model.oldCompID,
                EmpID             = model.EmpID,
                oldEmpID          = model.oldEmpID,
                EmpNameN          = model.EmpNameN,
                WriteDate         = model.OBWriteDate,
                WriteTime         = model.OBWriteTime,
                WriterID          = model.OBWriterID,
                oldWriteDate      = model.oldOBWriteDate,
                WriterName        = model.OBWriterName,
                FormSeq           = model.OBFormSeq,
                oldFormSeq        = model.oldOBFormSeq,
                FlowCaseID        = "",
                TransactionSeq    = "",
                OBFormStatus      = "2",
                ValidDate         = "",
                ValidID           = "",
                ValidName         = "",
                RejectReasonID    = "",
                RejectReasonCN    = "",
                DeptID            = model.OBDeptID,
                DeptName          = model.OBDeptName,
                OrganID           = model.OBOrganID,
                OrganName         = model.OBOrganName,
                WorkTypeID        = model.OBWorkTypeID,
                WorkType          = model.OBWorkType,
                FlowOrganID       = model.OBFlowOrganID,
                FlowOrganName     = model.OBFlowOrganName,
                TitleID           = model.OBTitleID,
                TitleName         = model.OBTitleName,
                PositionID        = model.OBPositionID,
                Position          = model.OBPosition,
                Tel_1             = model.OBTel_1,
                Tel_2             = model.OBTel_2,
                VisitBeginDate    = model.OBVisitBeginDate,
                BeginTime         = model.OBBeginTime,
                VisitEndDate      = model.OBVisitEndDate,
                EndTime           = model.OBEndTime,
                DeputyID          = model.OBDeputyID,
                DeputyName        = model.OBDeputyName,
                LocationType      = model.OBLocationType,
                InterLocationID   = model.OBInterLocationID,
                InterLocationName = model.OBInterLocationName,
                ExterLocationName = model.OBExterLocationName,
                VisiterName       = model.OBVisiterName,
                VisiterTel        = model.OBVisiterTel,
                VisitReasonID     = model.OBVisitReasonID,
                VisitReasonCN     = model.OBVisitReasonCN,
                VisitReasonDesc   = model.OBVisitReasonDesc,
                LastChgComp       = model.OBLastChgComp,
                LastChgID         = model.OBLastChgID,
            };
            OBFlowUtility.QueryFlowDataAndToUserData_First(dataBean.CompID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.EmpID, dataBean.WriterID, dataBean.VisitBeginDate,
                                                           out empData, out toUserData, out flowCode, out flowSN, out nextIsLastFlow, out meassge);

            dataBean.ValidID   = toUserData["SignID"].ToString();
            dataBean.ValidName = SelectSupervisor(toUserData["SignIDComp"], toUserData["SignID"]);

            KeyValue      = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.WriteDate + "," + dataBean.FormSeq;
            strarray      = (dataBean.EmpID + "," + dataBean.EmpNameN + "," + dataBean.VisitBeginDate + "," + dataBean.BeginTime + "," + dataBean.EndTime).Split(",");
            ValidUserData = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]);
            if (FlowExpress.IsFlowInsVerify(flow.FlowID, KeyValue.Split(","), strarray, "btnBefore", ValidUserData, ""))
            {
                strFlowCaseID       = FlowExpress.getFlowCaseID(flow.FlowID, KeyValue);
                dataBean.FlowCaseID = strFlowCaseID;
                switch (regStr)
                {
                case "Addes": { SqlCommand.InesrtVisitFormSendSql(dataBean, ref sb); break; }

                case "Modify": { SqlCommand.UpdateVisitFormSend(dataBean, ref sb); break; }
                }
                OBFlowUtility.InsertHROtherFlowLogCommand(strFlowCaseID, "1", strFlowCaseID + "1".PadLeft(5, '0'), "B", dataBean.EmpID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.WriterID,
                                                          flowCode, flowSN, "1", "1", toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb);

                sendEMail(dataBean, ref sb);
            }
            try
            {
                using (var trans = cn.BeginTransaction())
                {
                    try
                    {
                        seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), trans); //執行新增,成功筆數回傳,並做Transaction機制
                        trans.Commit();                                              //成功Transaction直接Commit
                    }
                    catch (Exception)
                    {
                        trans.Rollback(); //失敗Transaction Rollback
                        FlowExpress.IsFlowRollBack(flow.FlowID, dataBean.FlowCaseID);
                        throw;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }
    /// <summary>
    /// 原本不允許送審重複主管,現在又改成可以,所以把這方法註解,改成不檢核直接查詢
    /// </summary>
    /// <param name="SignID">下一關主管ID</param>
    /// <param name="SignIDComp">下一關主管公司</param>
    /// <param name="oAssDic">回傳Dictionary格式給永豐流程使用</param>
//    private void oAssDicCheck(string SignID, string SignIDComp, ref  Dictionary<string, string> oAssDic)
//{
//    if (SignID.Trim().Equals(UserInfo.getUserInfo().UserID.Trim()))
//        {
//            oAssDic.Clear();
//        }
//        else
//        {
//            oAssDic = CustVerify.getEmpID_Name_Dictionary(SignID, SignIDComp);
//        }
//}

    protected void Page_Load(object sender, EventArgs e)
    {
        //代辦畫面傳來的多筆審核資料
        DataTable dtOverTimeAdvance     = (DataTable)Session["dtOverTimeAdvance"];
        DataTable dtOverTimeDeclaration = (DataTable)Session["dtOverTimeDeclaration"];

        //永豐流程相關資料
        FlowExpress oFlow = new FlowExpress(Aattendant._AattendantFlowID, Request["FlowLogID"], true);

        //錯誤訊息儲存
        string     ErrMsg = "";
        CustVerify CV     = new CustVerify();
        Dictionary <string, string> toUserData = (Dictionary <string, string>)Session["toUserData"];

        //EmpInfo.QueryOrganData || EmpInfo.QueryFlowOrganData 使用
        //string SignOrganID = "", SignID = "", SignIDComp = "";

        if (!IsPostBack)
        {
            if (Session["FlowVerifyInfo"] != null)
            {
                #region "變數"
                //TrtCatchIsFlowVerify()使用
                DbHelper      db = new DbHelper(Aattendant._AattendantDBName);
                CommandHelper sb = db.CreateCommandHelper();
                DbConnection  cn = db.OpenConnection();
                DbTransaction tx = cn.BeginTransaction();

                //撈取該筆加班單相關資料
                DataTable dtOverTime;

                //預設下關待辦人(會變,沒變代表沒找到相關資料)
                Dictionary <string, string> oVerifyInfo = (Dictionary <string, string>)Session["FlowVerifyInfo"];
                Util.setJSContent(oVerifyInfo["FlowVerifyJS"]);
                Session["FlowVerifyInfo"] = null;
                Dictionary <string, string> oAssDic = Util.getDictionary(oVerifyInfo["FlowStepAssignToList"]);

                //共用檔
                Aattendant _Aattendant = new Aattendant();

                //Para撈取參數設定
                DataTable dtOverTimePara_All = db.ExecuteDataSet(CommandType.Text, string.Format("SELECT DISTINCT CompID,Para FROM OverTimePara ")).Tables[0];

                string AD = "";
                #endregion "變數"
                switch (oVerifyInfo["FlowStepBtnID"].ToString())
                {
                case "btnClose":
                case "btnReApprove":
                case "FlowReassign":
                case "btnApprove":      //審核
                    //單筆審核(使用oFlow.FlowCaseID判斷)
                    if (dtOverTimeAdvance == null && dtOverTimeDeclaration == null)
                    {
                        #region "單筆審核"
                        //給IsFlowVerify的下一關簽核主管
                        //oAssDicCheck(toUserData["SignID"], toUserData["SignIDComp"], ref oAssDic); //原本要檢核主管是否重複,後來說不要了
                        oAssDic = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]);
                        switch (oFlow.FlowCurrStepID)
                        {
                        //事先
                        case "A10":
                        case "A20":
                            AD = "A";
                            break;

                        //事後
                        case "A30":
                        case "A40":
                            AD = "D";
                            break;
                        }
                        dtOverTime = CustVerify.OverTime_find_by_FlowCaseID(oFlow.FlowCaseID, AD);
                        if (oVerifyInfo["FlowStepBtnID"].ToString() == "btnClose")     //結案
                        {
                            sb.Reset();
                            CustVerify.UpdateOverTime(AD, "3", oFlow.FlowCaseID, ref sb);
                            CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "2", ref sb);
                            CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb);
                            if (AD == "A")
                            {
                                CustVerify.insertFromAdvanceToData(oFlow.FlowCaseID, ref sb);
                            }
                            if (TryCatchIsFlowVerify(Request["FlowLogID"], oVerifyInfo["FlowStepBtnID"], oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true))
                            {
                                CV.MailLogContent(oFlow.FlowCaseID, "3", AD, "", "", true);
                                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                            }
                            else
                            {
                                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                            }
                        }
                        else     //沒結案
                        {
                            sb.Reset();
                            DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(oFlow.FlowCaseID, false);
                            CustVerify.UpdateOverTime(AD, "2", oFlow.FlowCaseID, ref sb);
                            CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "2", ref sb);
                            FlowUtility.InsertHROverTimeLogCommand(
                                oFlow.FlowCaseID,
                                CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()),
                                CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()),
                                AD,
                                dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(),
                                dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(),
                                dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(),
                                UserInfo.getUserInfo().UserID,
                                dtHROverTimeLog.Rows[0]["FlowCode"].ToString(),
                                dtHROverTimeLog.Rows[0]["FlowSN"].ToString(),
                                CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()),
                                toUserData["SignLine"],
                                toUserData["SignIDComp"],
                                toUserData["SignID"],
                                toUserData["SignOrganID"],
                                toUserData["SignFlowOrganID"],
                                "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1
                                );

                            if (TryCatchIsFlowVerify(Request["FlowLogID"], oVerifyInfo["FlowStepBtnID"], oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true))
                            {
                                CV.MailLogContent(oFlow.FlowCaseID, "2", AD, "", "", false);
                                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                            }
                            else
                            {
                                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                            }
                        }
                        #endregion "單筆審核"
                    }
                    /*================================================*/
                    //多筆審核有四個迴圈,事先兩個是後兩個
                    //UpdateAD、HROverTimeLog、MailLog在第一迴圈
                    //其他在第二迴圈
                    //多筆審核按鈕(非印章)
                    else
                    {
                        #region "事先多筆"
                        if (dtOverTimeAdvance.Rows.Count > 0)
                        {
                            AD = "A";
                            for (int i = 0; i < dtOverTimeAdvance.Rows.Count; i++)
                            {
                                if (dtOverTimeAdvance.Rows[i]["OTSeqNo"].ToString() == "1")
                                {
                                    oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "A"), true);
                                    string btnName = dtOverTimeAdvance.Rows[i]["btnName"].ToString();
                                    //oAssDicCheck(dtOverTimeAdvance.Rows[i]["SignID"].ToString(), dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString(), ref oAssDic);
                                    oAssDic = CustVerify.getEmpID_Name_Dictionary(dtOverTimeAdvance.Rows[i]["SignID"].ToString(), dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString());
                                    if (btnName == "btnClose")     //結案
                                    {
                                        sb.Reset();
                                        CustVerify.UpdateOverTime(AD, "3", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                        CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", ref sb);
                                        CustVerify.CloseHROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), AD, ref sb);
                                        CustVerify.insertFromAdvanceToData(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                        if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false))
                                        {
                                            CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "3", AD, "", "", true);
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                        }
                                        else
                                        {
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                        }
                                    }
                                    else     //沒結案
                                    {
                                        sb.Reset();
                                        DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), false);
                                        CustVerify.UpdateOverTime(AD, "2", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                        CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", ref sb);
                                        FlowUtility.InsertHROverTimeLogCommand(
                                            dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(),
                                            CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()),
                                            CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()),
                                            AD,
                                            dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(),
                                            dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(),
                                            dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(),
                                            UserInfo.getUserInfo().UserID,
                                            dtHROverTimeLog.Rows[0]["FlowCode"].ToString(),
                                            dtHROverTimeLog.Rows[0]["FlowSN"].ToString(),
                                            CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()),
                                            //toUserData start
                                            dtOverTimeAdvance.Rows[i]["SignLine"].ToString(),
                                            dtOverTimeAdvance.Rows[i]["SignIDComp"].ToString(),
                                            dtOverTimeAdvance.Rows[i]["SignID"].ToString(),
                                            dtOverTimeAdvance.Rows[i]["SignOrganID"].ToString(),
                                            dtOverTimeAdvance.Rows[i]["SignFlowOrganID"].ToString(),
                                            //toUserData end
                                            "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1
                                            );

                                        if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false))
                                        {
                                            CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "2", AD, "", "", false);
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                        }
                                        else
                                        {
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                        }
                                    }
                                }
                            }
                        }
                        #endregion "事先多筆"
                        /*------------------*/
                        #region "事後多筆"
                        if (dtOverTimeDeclaration.Rows.Count > 0)
                        {
                            AD = "D";
                            for (int i = 0; i < dtOverTimeDeclaration.Rows.Count; i++)
                            {
                                if (dtOverTimeDeclaration.Rows[i]["OTSeqNo"].ToString() == "1")
                                {
                                    oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "D"), true);
                                    string btnName = dtOverTimeDeclaration.Rows[i]["btnName"].ToString();
                                    //oAssDicCheck(dtOverTimeDeclaration.Rows[i]["SignID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString(), ref oAssDic);
                                    oAssDic = CustVerify.getEmpID_Name_Dictionary(dtOverTimeDeclaration.Rows[i]["SignID"].ToString(), dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString());
                                    if (btnName == "btnClose")     //結案
                                    {
                                        sb.Reset();
                                        CustVerify.UpdateOverTime(AD, "3", dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                        CustVerify.UpdateHROrverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", ref sb);
                                        CustVerify.CloseHROverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), AD, ref sb);

                                        if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false))
                                        {
                                            CV.MailLogContent(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "3", AD, "", "", true);
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                        }
                                        else
                                        {
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                        }
                                    }
                                    else     //沒結案
                                    {
                                        sb.Reset();
                                        DataTable dtHROverTimeLog = CustVerify.HROverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), false);
                                        CustVerify.UpdateOverTime(AD, "2", dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                        CustVerify.UpdateHROrverTimeLog(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", ref sb);
                                        FlowUtility.InsertHROverTimeLogCommand(
                                            dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(),
                                            CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowLogBatNo"].ToString()),
                                            CustVerify.FlowLogIDadd(dtHROverTimeLog.Rows[0]["FlowLogID"].ToString()),
                                            AD,
                                            dtHROverTimeLog.Rows[0]["OTEmpID"].ToString(),
                                            dtHROverTimeLog.Rows[0]["EmpOrganID"].ToString(),
                                            dtHROverTimeLog.Rows[0]["EmpFlowOrganID"].ToString(),
                                            UserInfo.getUserInfo().UserID,
                                            dtHROverTimeLog.Rows[0]["FlowCode"].ToString(),
                                            dtHROverTimeLog.Rows[0]["FlowSN"].ToString(),
                                            CustVerify.addone(dtHROverTimeLog.Rows[0]["FlowSeq"].ToString()),
                                            //toUserData start
                                            dtOverTimeDeclaration.Rows[i]["SignLine"].ToString(),
                                            dtOverTimeDeclaration.Rows[i]["SignIDComp"].ToString(),
                                            dtOverTimeDeclaration.Rows[i]["SignID"].ToString(),
                                            dtOverTimeDeclaration.Rows[i]["SignOrganID"].ToString(),
                                            dtOverTimeDeclaration.Rows[i]["SignFlowOrganID"].ToString(),
                                            //toUserData end
                                            "1", false, ref sb, int.Parse(dtHROverTimeLog.Rows[0]["Seq"].ToString()) + 1
                                            );

                                        if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, btnName, oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false))
                                        {
                                            CV.MailLogContent(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "2", AD, "", "", false);
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                        }
                                        else
                                        {
                                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                        }
                                    }
                                }
                            }
                        }
                        #endregion "事後多筆"
                    }
                    break;

                /*=================================================*/
                case "btnReject":                                                   //駁回
                    if (dtOverTimeAdvance == null && dtOverTimeDeclaration == null) //true 印章 false 多筆審核按鈕
                    {
                        #region "單筆駁回"
                        switch (oFlow.FlowCurrStepID)
                        {
                        //事先
                        case "A10":
                        case "A20":
                            AD = "A";
                            break;

                        //事後
                        case "A30":
                        case "A40":
                            AD = "D";
                            break;
                        }
                        dtOverTime = CustVerify.OverTime_find_by_FlowCaseID(oFlow.FlowCaseID, AD);
                        sb.Reset();
                        CustVerify.UpdateOverTime(AD, "4", oFlow.FlowCaseID, ref sb);
                        CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "3", ref sb);
                        CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb);
                        if (AD == "D")
                        {
                            CustVerify.AfterReject_CheckAndInsert(oFlow.FlowCaseID, ref sb);
                        }
                        //ClearBtn(oFlow.FlowCurrLogAssignTo);
                        if (TryCatchIsFlowVerify(Request["FlowLogID"], "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTime.Rows[0], true))
                        {
                            CV.MailLogContent(oFlow.FlowCaseID, "4", AD, "", "", true);
                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                        }
                        else
                        {
                            labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                        }
                        #endregion "單筆駁回"
                    }

                    else     //多筆審核按鈕
                    {
                        #region "多筆駁回"
                        if (dtOverTimeAdvance.Rows.Count > 0)
                        {
                            AD = "A";
                            for (int i = 0; i < dtOverTimeAdvance.Rows.Count; i++)
                            {
                                if (dtOverTimeAdvance.Rows[i]["OTSeqNo"].ToString() == "1")
                                {
                                    oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "A"), true);
                                    sb.Reset();
                                    CustVerify.UpdateOverTime(AD, "4", dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), ref sb);
                                    CustVerify.UpdateHROrverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "3", ref sb);
                                    CustVerify.CloseHROverTimeLog(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), AD, ref sb);
                                    //ClearBtn(oFlow.FlowCurrLogAssignTo);
                                    if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeAdvance.Rows[i], false))
                                    {
                                        CV.MailLogContent(dtOverTimeAdvance.Rows[i]["FlowCaseID"].ToString(), "4", AD, "", "", true);
                                        labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                    }
                                    else
                                    {
                                        labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                    }
                                }
                            }
                        }
                        if (dtOverTimeDeclaration.Rows.Count > 0)
                        {
                            AD = "D";
                            for (int i = 0; i < dtOverTimeDeclaration.Rows.Count; i++)
                            {
                                if (dtOverTimeDeclaration.Rows[i]["OTSeqNo"].ToString() == "1")
                                {
                                    oFlow = new FlowExpress(Aattendant._AattendantFlowID, CustVerify.getFlowLogID(dtOverTimeDeclaration.Rows[i]["FlowCaseID"].ToString(), "D"), true);
                                    sb.Reset();
                                    CustVerify.UpdateOverTime(AD, "4", oFlow.FlowCaseID, ref sb);
                                    CustVerify.UpdateHROrverTimeLog(oFlow.FlowCaseID, "3", ref sb);
                                    CustVerify.CloseHROverTimeLog(oFlow.FlowCaseID, AD, ref sb);
                                    CustVerify.AfterReject_CheckAndInsert(oFlow.FlowCaseID, ref sb);
                                    //ClearBtn(oFlow.FlowCurrLogAssignTo);
                                    if (TryCatchIsFlowVerify(oFlow.FlowCurrLastLogID, "btnReject", oAssDic, oVerifyInfo["FlowStepOpinion"].ToString().Replace("'", "''"), sb, out ErrMsg, dtOverTimeDeclaration.Rows[i], false))
                                    {
                                        CV.MailLogContent(oFlow.FlowCaseID, "4", AD, "", "", true);
                                        labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Succeed, "審核成功!");
                                    }
                                    else
                                    {
                                        labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.Error, "審核失敗");
                                    }
                                }
                            }
                        }
                        #endregion "多筆駁回"
                    }
                    break;
                    /*==============================*/
                }
                if (txtErrMsg.Text != "")
                {
                    txtErrMsg.Text    = "審核失敗清單:" + txtErrMsg.Text;
                    txtErrMsg.Visible = true;
                }
            }
            else
            {
                //參數錯誤
                labMsg.Text = Util.getHtmlMessage(Util.HtmlMessageKind.ParaError);
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// CancelVisitForm
    /// 公出查詢
    /// 送簽後取消流程
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool CancelVisitForm(List <OnBizPublicOutModel> model, out long seccessCount, out string msg)
    {
        bool result = false;

        seccessCount = 0;
        msg          = "";
        try
        {
            Dictionary <string, string> ValidUserData = new Dictionary <string, string>();
            FlowExpress   flow = new FlowExpress(Util.getAppSetting("app://AattendantDB_OnBiz/"));
            DbHelper      db   = new DbHelper(_attendantDBName);
            CommandHelper sb   = db.CreateCommandHelper();
            DbConnection  cn   = db.OpenConnection();
            string        flowCaseIDForRollBack = "";
            try
            {
                using (var trans = cn.BeginTransaction())
                {
                    try
                    {
                        foreach (OnBizPublicOutModel item in model)
                        {
                            OnBizPublicOutBean dataBean = new OnBizPublicOutBean()
                            {
                                CompID      = item.CompID,
                                EmpID       = item.EmpID,
                                WriteDate   = item.OBWriteDate,
                                FormSeq     = item.OBFormSeq,
                                FlowCaseID  = item.FlowCaseID,
                                FlowLogID   = item.FlowLogID,
                                ValidID     = item.ValidID,
                                LastChgComp = item.OBLastChgComp,
                                LastChgID   = item.OBLastChgID,
                                LastChgDate = item.OBLastChgDate
                            };

                            ValidUserData = CustVerify.getEmpID_Name_Dictionary(dataBean.ValidID, dataBean.CompID);

                            if (FlowExpress.IsFlowVerify(flow.FlowID, dataBean.FlowLogID, "btnCancel", ValidUserData, "取消"))
                            {
                                sb.Reset();
                                flowCaseIDForRollBack += dataBean.FlowCaseID + ",";
                                OBFlowUtility.ChangeFlowFlag(dataBean.FlowCaseID, "OB01", "0001", dataBean.CompID, dataBean.ValidID, "0", ref sb);
                                SqlCommand.CancelVisitFormSql(dataBean, ref sb);
                                SqlCommand.UpdateHROtherFlowLogSql(dataBean, ref sb);
                            }
                        }
                        seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), trans); //執行新增,成功筆數回傳,並做Transaction機制
                        trans.Commit();                                              //成功Transaction直接Commit
                    }
                    catch (Exception)
                    {
                        trans.Rollback(); //失敗Transaction Rollback
                        string[] flowCaseIDAry = flowCaseIDForRollBack.Split(",");
                        for (int i = 0; i < flowCaseIDAry.Length - 1; i++)
                        {
                            FlowExpress.IsFlowRollBack(flow.FlowID, flowCaseIDAry[i]);
                        }
                        throw;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }
Ejemplo n.º 4
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;
            }
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 審核
    /// </summary>
    private void DoRelease()
    {
        DbHelper      db                    = new DbHelper(_attendantDBName);
        CommandHelper sb                    = db.CreateCommandHelper();
        DbConnection  cn                    = db.OpenConnection();
        DbTransaction tx                    = cn.BeginTransaction();
        FlowExpress   oFlow                 = new FlowExpress("OnBizReqAppd_ITRD");
        string        FlowCustDB            = oFlow.FlowID;
        Dictionary <string, string> oAssDic = CustVerify.getEmpID_Name_Dictionary(UserInfo.getUserInfo().UserID, UserInfo.getUserInfo().CompID);

        try
        {
            for (int introw = 0; introw < gvCheckVisitForm.Rows.Count; introw++)
            {
                CheckBox objchk = (CheckBox)gvCheckVisitForm.Rows[introw].FindControl("chkChoiced");


                if (objchk.Checked == true)
                {
                    RadioButton rdoApp        = (RadioButton)gvCheckVisitForm.Rows[introw].FindControl("rbnApproved");
                    RadioButton rdoRej        = (RadioButton)gvCheckVisitForm.Rows[introw].FindControl("rbnReject");
                    TextBox     txtReson      = (TextBox)gvCheckVisitForm.Rows[introw].FindControl("txtReson");
                    string      rowCompID     = gvCheckVisitForm.DataKeys[introw].Values["CompID"].ToString();
                    string      rowEmpID      = gvCheckVisitForm.DataKeys[introw].Values["EmpID"].ToString();
                    string      rowWriteDate  = gvCheckVisitForm.DataKeys[introw].Values["WriteDate"].ToString();
                    string      rowFormSeq    = gvCheckVisitForm.DataKeys[introw].Values["FormSeq"].ToString();
                    string      rowFlowCaseID = gvCheckVisitForm.DataKeys[introw].Values["FlowCaseID"].ToString();
                    string      rowFlowLogID  = gvCheckVisitForm.DataKeys[introw].Values["FlowLogID"].ToString();
                    string      btnAct        = "";
                    string      OBFormStatus  = "";
                    string      HRLogStatus   = "";
                    if (rdoApp.Checked == true)
                    {
                        btnAct       = "btnClose";
                        OBFormStatus = "3";
                        HRLogStatus  = "2";
                    }
                    else if (rdoRej.Checked == true)
                    {
                        btnAct       = "btnReject";
                        OBFormStatus = "4";
                        HRLogStatus  = "3";
                    }

                    OnBizReqAppdOperationSql.UpdateVisitForm(rowCompID, rowEmpID, rowWriteDate, rowFormSeq, OBFormStatus, txtReson.Text.ToString(), ref sb);
                    OnBizReqAppdOperationSql.UpdateHROverTimeLog(rowFlowCaseID, HRLogStatus, ref sb);
                    FlowUtility.ChangeFlowFlag(rowFlowCaseID, "OB01", "0001", UserInfo.getUserInfo().CompID, UserInfo.getUserInfo().UserID, "0", ref sb);


                    //先執行SQL,if(永豐流程成功)則Commit,else則RollBack。 //20170613 leo modify
                    db.ExecuteNonQuery(sb.BuildCommand(), tx);
                    if (FlowExpress.IsFlowVerify(FlowCustDB, rowFlowLogID, btnAct, oAssDic, txtReson.Text.ToString()))
                    {
                        tx.Commit();
                        Util.MsgBox("審核成功!");
                    }
                    else
                    {
                        throw new Exception("審核失敗!");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            tx.Rollback();
            Util.MsgBox(ex.Message);
        }
    }
    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("審核成功");
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 申請後送簽流程
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool PunchUpdateModify_SaveData(Punch_Confirm_Remedy_Bean model, out long seccessCount, out string msg)
    {
        bool result = false;

        seccessCount = 0;
        msg          = "";

        bool validResult = false;
        Punch_Confirm_Remedy_Bean datas = new Punch_Confirm_Remedy_Bean();
        string validMsg = "";

        try
        {
            Dictionary <string, string> empData       = new Dictionary <string, string>();
            Dictionary <string, string> toUserData    = new Dictionary <string, string>();
            Dictionary <string, string> ValidUserData = new Dictionary <string, string>();
            string      flowCode       = "";
            string      flowSN         = "";
            bool        nextIsLastFlow = false;
            string      meassge        = "";
            FlowExpress flow           = new FlowExpress(Util.getAppSetting("app://AattendantDB_PunchUpdate/"));
            string      KeyValue       = "";//字串
            string      ShowValue      = "";
            string      strFlowCaseID  = "";

            DbHelper      db = new DbHelper(Aattendant._AattendantDBName);
            CommandHelper sb = db.CreateCommandHelper();
            DbConnection  cn = db.OpenConnection();
            DbTransaction tx = cn.BeginTransaction();

            Punch_Confirm_Remedy_Bean dataBean = new Punch_Confirm_Remedy_Bean()
            {
                FlowCaseID              = model.FlowCaseID,
                CompID                  = model.CompID,
                EmpID                   = model.EmpID,
                EmpName                 = model.EmpName,
                DutyDate                = model.DutyDate,
                DutyTime                = model.DutyTime,
                PunchDate               = model.PunchDate,
                PunchTime               = model.PunchTime,
                PunchConfirmSeq         = model.PunchConfirmSeq,
                DeptID                  = model.DeptID,
                DeptName                = model.DeptName,
                OrganID                 = model.OrganID,
                OrganName               = model.OrganName,
                FlowOrganID             = model.FlowOrganID,
                FlowOrganName           = model.FlowOrganName,
                MAFT10_FLAG             = model.MAFT10_FLAG,
                ConfirmStatus           = model.ConfirmStatus,
                PunchRemedySeq          = model.PunchRemedySeq,
                RemedyReasonID          = model.RemedyReasonID,
                RemedyReasonCN          = model.RemedyReasonCN,
                RemedyPunchTime         = model.RemedyPunchTime,
                AbnormalFlag            = model.AbnormalFlag,
                AbnormalReasonID        = model.AbnormalReasonID,
                AbnormalReasonCN        = model.AbnormalReasonCN,
                AbnormalDesc            = model.AbnormalDesc,
                Remedy_MAFT10_FLAG      = model.Remedy_MAFT10_FLAG,
                Remedy_AbnormalFlag     = model.Remedy_AbnormalFlag,
                Remedy_AbnormalReasonID = model.Remedy_AbnormalReasonID,
                Remedy_AbnormalReasonCN = model.Remedy_AbnormalReasonCN,
                Remedy_AbnormalDesc     = model.Remedy_AbnormalReasonID == "99" ? model.Remedy_AbnormalDesc : "",
                LastChgComp             = model.LastChgComp,
                LastChgID               = model.LastChgID,
                LastChgDate             = model.LastChgDate,
                //Remedy
                RemedyPunchFlag = model.RemedyPunchFlag,
                BatchFlag       = model.BatchFlag,
                PORemedyStatus  = model.PORemedyStatus,
                RejectReason    = model.RejectReason,
                RejectReasonCN  = model.RejectReasonCN,
                ValidDateTime   = model.ValidDateTime,
                //ValidTime = model.ValidTime,
                ValidCompID = model.ValidCompID,
                ValidID     = model.ValidID,
                ValidName   = model.ValidName
            };

            OBFlowUtility.QueryFlowDataAndToUserData_First(dataBean.CompID, dataBean.OrganID, dataBean.FlowOrganID, dataBean.EmpID, dataBean.EmpID, dataBean.PunchDate, out empData, out toUserData, out flowCode, out flowSN, out nextIsLastFlow, out meassge, "PO01", "PO");

            Punch_Confirm_Remedy_Model validInfo = new Punch_Confirm_Remedy_Model()
            {
                CompID = toUserData["SignIDComp"],
                EmpID  = toUserData["SignID"]
            };
            validResult = GetValidInfo(validInfo, out datas, out validMsg);
            if (!validResult)
            {
                throw new Exception(validMsg);
            }
            dataBean.ValidCompID = toUserData["SignIDComp"];
            dataBean.ValidID     = toUserData["SignID"];
            dataBean.ValidName   = datas.ValidName;

            KeyValue      = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.PunchDate + "," + dataBean.PunchRemedySeq;
            ShowValue     = dataBean.CompID + "," + dataBean.EmpID + "," + dataBean.PunchDate + "," + dataBean.PunchTime;
            ValidUserData = CustVerify.getEmpID_Name_Dictionary(toUserData["SignID"], toUserData["SignIDComp"]);

            if (FlowExpress.IsFlowInsVerify(flow.FlowID, KeyValue.Split(","), ShowValue.Split(","), nextIsLastFlow ? "btnSendLast" : "btnSend", ValidUserData, ""))
            {
                strFlowCaseID       = FlowExpress.getFlowCaseID(flow.FlowID, KeyValue);
                dataBean.FlowCaseID = strFlowCaseID;
                SqlCommand.PunchUpdateModify_InsertPunchRemedyLog(dataBean, ref sb);
                OBFlowUtility.ChangeFlowFlag(strFlowCaseID, flowCode, flowSN, dataBean.ValidCompID, dataBean.ValidID, "1", ref sb);
                OBFlowUtility.InsertHROtherFlowLogCommand(strFlowCaseID, "1", strFlowCaseID + "." + "1".PadLeft(5, '0'), "P", dataBean.EmpID, dataBean.OrganID,
                                                          dataBean.FlowOrganID, dataBean.ValidID, flowCode, flowSN, "1", "1", toUserData["SignIDComp"], toUserData["SignID"], toUserData["SignOrganID"], toUserData["SignFlowOrganID"], "1", false, ref sb);

                try
                {
                    //================
                    //sb.Append("錯誤製造");
                    //=================
                    seccessCount = db.ExecuteNonQuery(sb.BuildCommand(), tx); //執行新增,成功筆數回傳,並做Transaction機制
                    tx.Commit();                                              //成功Transaction直接Commit
                }
                catch (Exception)
                {
                    FlowExpress.IsFlowCaseDeleted(flow.FlowID, strFlowCaseID, true); //送簽用IsFlowCaseDeleted //審核用IsFlowRollBack
                    tx.Rollback();                                                   //失敗Transaction Rollback
                    throw;
                }
                result = true;
            }
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }