/// <summary>
    /// 取得執勤、個人、公司班表
    /// </summary>
    /// <returns></returns>
    private bool getReport(string regStr, out PunchModel viewData)
    {
        bool   result  = false;
        string NowTime = DateTime.Now.ToString("HH:mm:ss.fff");
        var    msg     = "";
        var    datas   = new PunchBean();

        viewData = new PunchModel()
        {
            CompID      = UserInfo.getUserInfo().CompID,
            EmpID       = UserInfo.getUserInfo().UserID,
            EmpName     = UserInfo.getUserInfo().UserName,
            DeptID      = UserInfo.getUserInfo().DeptID,
            DeptName    = UserInfo.getUserInfo().DeptName,
            OrganID     = UserInfo.getUserInfo().OrganID,
            OrganName   = UserInfo.getUserInfo().OrganName,
            WorkTypeID  = UserInfo.getUserInfo().WorkTypeID,
            WorkType    = UserInfo.getUserInfo().WorkTypeName,
            Sex         = UserInfo.getUserInfo().Sex,
            PunchFlag   = "0",
            MAFT10_FLAG = "0",
            PunchDate   = DateTime.Now.ToString("yyyy/MM/dd"),
            //PunchDate = "2017/05/02",
            PunchTime       = NowTime,
            PunchTime4Count = NowTime.Replace(":", "").Substring(0, 4),
            LastChgComp     = UserInfo.getUserInfo().CompID,
            LastChgID       = UserInfo.getUserInfo().UserID
        };

        switch (regStr)
        {
        case "Duty":
        {
            result = Punch.GetDutyReport(viewData, out datas, out msg);
            break;
        }

        case "EmpWork":
        {
            result = Punch.GetEmpWorkReport(viewData, out datas, out msg);
            break;
        }

        case "PersonOther":
        {
            result = Punch.GetPersonalOtherReport(viewData, out datas, out msg);
            break;
        }
        }

        if (result && datas != null)
        {
            viewData.BeginTime     = datas.BeginTime;
            viewData.EndTime       = datas.EndTime;
            viewData.RestBeginTime = datas.RestBeginTime;
            viewData.RestEndTime   = datas.RestEndTime;
        }

        return(result);
    }
Exemple #2
0
    //-------------------------------------------------------------主要邏輯區

    /// <summary>
    /// 確定打卡邏輯
    /// </summary>
    private void DoDefine()
    {
        bool   result       = false;
        long   seccessCount = 0;
        string msg          = "";

        try
        {
            PunchModel model = _PunchModel;

            string abnormalFlag = rbtAbnormal.Checked ? "1" : "2";
            model.AbnormalFlag     = StringIIF(abnormalFlag);
            model.AbnormalReasonID = StringIIF(ddlAbnormalReason.SelectedValue);
            model.AbnormalReasonCN = StringIIF("".Equals(ddlAbnormalReason.SelectedValue)?"":ddlAbnormalReason.SelectedItem.Text);
            model.AbnormalDesc     = StringIIF(AbnormalDesc.Text);

            result = Punch.InsertPunchLog(model, out seccessCount, out msg);
            if (!result)
            {
                throw new Exception(msg);
            }
            if (seccessCount == 0)
            {
                throw new Exception("無資料被新增!!");
            }
            _SessionPunchModel = model;
            Response.Redirect("~/Punch/PO1000_Finish.aspx" + "?id=" + _SessionID);
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    /// <summary>
    /// 將Model轉換為Json字串(沒用到)
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    private string reverToJson(PunchModel model)
    {
        string result = "";

        if (model == null)
        {
            throw new Exception("");
        }
        result = JsonConvert.SerializeObject(model);
        return(result);
    }
    /// <summary>
    /// 將Json字串轉換為Model
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    private PunchModel reverToObject(string json)
    {
        PunchModel result = new PunchModel();

        if (json.Equals(""))
        {
            throw new Exception("");
        }
        result = JsonConvert.DeserializeObject <PunchModel>(json);
        return(result);
    }
 /// <summary>
 /// btnCheckIn_Click
 /// 出勤打卡
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnCheckIn_Click(object sender, EventArgs e)
 {
     if ("".Equals(_PunchModel.ErrorFlag))
     {
         DoDefine("CheckIn");
     }
     else
     {
         _SessionPunchModel = _PunchModel;
         Response.Redirect("PO1000_Error.aspx" + "?id=" + _SessionID);
     }
 }
    private void initScreen()
    {
        PunchModel model = _PunchModel;

        try
        {
            EmpID_NameN.Text   = model.EmpID + " " + model.EmpName;
            PunchDateTime.Text = model.PunchDate + " " + model.PunchTime.Substring(0, model.PunchTime.Length - 7);
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    /// <summary>
    /// 取得班表,順序:值勤 > 個人
    /// </summary>
    /// <param name="datas"></param>
    /// <returns></returns>
    private bool getPunchReport(out PunchModel datas)
    {
        bool result = true;

        datas = new PunchModel();

        if (!QueryReport("Duty", out datas))
        {
            if (!QueryReport("EmpWork", out datas))
            {
                return(false);
            }
        }
        return(result);
    }
Exemple #8
0
    //-------------------------------------------------------------初始物件

    /// <summary>
    /// 畫面初始值
    /// </summary>
    private void initScreen()
    {
        PunchModel model = _PunchModel;

        try
        {
            AbnormalFlagSwitch("rbtAbnormal");
            EmpID_NameN.Text   = model.EmpID + " " + model.EmpName;
            PunchDateTime.Text = model.PunchDate + " " + model.PunchTime.Substring(0, model.PunchTime.Length - 7);
            ShowMsg.Text       = model.RemindMsg;
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    /// <summary>
    /// 組成訊息
    /// </summary>
    /// <returns></returns>
    private string comBinMsg(PunchModel model, bool specialFlag)
    {
        string result = "~/Punch/";

        if (!model.ErrorFlag.Equals(""))        //下班異常訊息 + 關懷訊息
        {
            if (model.ErrorFlag.StartsWith("F"))
            {
                string punchOutFlag = _MsgParamodel.PunchOutMsgFlag;
                model.RemindMsg = punchOutFlag.Equals("0") ? _MsgParamodel.PunchOutDefaultContent : _MsgParamodel.PunchOutSelfContent;
                if (model.ErrorFlag.Length == 2)
                {
                    string ovTenFlag = _MsgParamodel.OVTenMsgFlag;
                    model.CareMsg = ovTenFlag.Equals("0") ? _MsgParamodel.OVTenDefaultContent : _MsgParamodel.OVTenSelfContent;
                }
                if (model.Sex.Equals("2"))
                {
                    string femaleFlag = _MsgParamodel.FemaleMsgFlag;
                    string femaleMsg  = femaleFlag.Equals("0") ? _MsgParamodel.FemaleDefaultContent : _MsgParamodel.FemaleSelfContent;
                    model.CareMsg     = model.CareMsg.Substring(0, model.CareMsg.Length - 1) + femaleMsg;
                    model.MAFT10_FLAG = "1";
                }
            }
            else if ("T".Equals(model.ErrorFlag))   //上班異常訊息
            {
                string punchInFlag = _MsgParamodel.PunchInMsgFlag;
                model.RemindMsg = punchInFlag.Equals("0") ? _MsgParamodel.PunchInDefaultContent : _MsgParamodel.PunchInSelfContent;
            }

            string affairFlag = _MsgParamodel.AffairMsgFlag;
            model.RemindMsgAf = affairFlag.Equals("0") ? _MsgParamodel.AffairDefaultContent : _MsgParamodel.AffairSelfContent;
            result           += specialFlag ? "PO1000_Special.aspx" : "PO1000_Error.aspx";
        }
        else if ("".Equals(model.ErrorFlag))    //正常上班
        {
            result += specialFlag ? "PO1000_Special.aspx" : "PO1000_Finish.aspx";
        }
        model.ResultMsg = "打卡成功";
        //串Key給下一頁尋找Session用
        string sessionId = model.EmpID + '_' + DateTime.Now.ToString("HH:mm:ss.fff");

        result            += "?id=" + sessionId;
        _SessionID         = sessionId;
        _SessionPunchModel = model;
        return(result);
    }
    /// <summary>
    /// 取得個人FlowOrganID
    /// </summary>
    /// <returns></returns>
    private bool getEmpFlowOrgan(ref PunchModel viewData)
    {
        bool result = false;
        var  msg    = "";
        var  datas  = new PunchBean();

        result = Punch.SelectEmpFlowOrgan(viewData, out datas, out msg);
        if (result && datas != null)
        {
            viewData.FlowOrganID   = datas.FlowOrganID;
            viewData.FlowOrganName = datas.FlowOrganName;
        }
        else
        {
            throw new Exception("".Equals(msg) ? "查無資料" : msg);
        }
        return(result);
    }
    /// <summary>
    /// 檢查打卡時間是否異常
    /// </summary>
    /// <param name="viewData"></param>
    /// <returns></returns>
    private string isPunchError(PunchModel viewData)
    {
        string       result   = "";
        bool         hasPara  = false;
        ParaModel    paraTime = new ParaModel();
        MsgParaModel paraMsg  = new MsgParaModel();

        try
        {
            hasPara = getPunchPara(out paraTime, out paraMsg);
            if (hasPara && paraMsg != null && paraTime != null)
            {
                int punchTime = Int32.Parse(viewData.PunchTime4Count);//要把時間:去掉,轉換格式,Model還要再多一個存取欄位
                //int punchTime = Int32.Parse("0630");
                int beginTime  = Int32.Parse(viewData.BeginTime);
                int endTime    = Int32.Parse(viewData.EndTime);
                int punchInBT  = Int32.Parse(paraTime.PunchInBT);
                int punchOutBT = Int32.Parse(paraTime.PunchOutBT);
                int regularIn  = beginTime - punchInBT;
                int regularOut = endTime + punchOutBT;

                if (punchTime < regularIn)
                {
                    result = "T";
                }
                if (punchTime > regularOut)
                {
                    result = "F";
                    if (punchTime >= 2200 && punchTime < 2400 || punchTime >= 0 && punchTime < 600)
                    {
                        result += "L";
                    }
                }
                _MsgParamodel = paraMsg;
            }
        }
        catch (Exception ex)
        {
            //Util.MsgBox(ex.Message);
            throw new Exception(ex.Message);
        }
        return(result);
    }
Exemple #12
0
    /// <summary>
    /// 查詢最大PunchSeq
    /// </summary>
    private static string QueryMaxSeq(PunchModel viewData)
    {
        var result    = "";
        var isSuccess = false;
        var msg       = "";
        var datas     = new PunchBean();

        isSuccess = GetMaxFormSeq(viewData, out datas, out msg);
        if (isSuccess && datas != null)
        {
            var seq = Int32.Parse(datas.PunchSeq) + 1;
            result = seq.ToString();
        }
        else
        {
            result = "1";
        }
        return(result);
    }
    private void DoDefine(string regStr)
    {
        bool   result       = false;
        long   seccessCount = 0;
        string msg          = "";

        try
        {
            PunchModel model = _PunchModel;
            switch (regStr)
            {
            case "CheckIn":
            {
                model.PunchFlag = "0";
                break;
            }

            case "NapCheckIn":
            {
                model.PunchFlag = "1";
                break;
            }
            }
            ;

            result = Punch.InsertPunchLog(model, out seccessCount, out msg);
            if (!result)
            {
                throw new Exception(msg);
            }
            if (seccessCount == 0)
            {
                throw new Exception("無資料被新增!!");
            }
            _SessionPunchModel = model;
            Response.Redirect("~/Punch/PO1000_Finish.aspx" + "?id=" + _SessionID);
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
Exemple #14
0
    /// <summary>
    /// 取得DB資料
    /// 特殊單位
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool GetPunchSpecial(PunchModel model, out PunchBean datas, out string msg)
    {
        bool result = false;

        msg   = "";
        datas = new PunchBean();
        try
        {
            using (var conn = new SqlConnection()
            {
                ConnectionString = DbHelper.getConnectionStrings(_attendantDBName).ConnectionString
            })
            {
                PunchBean dataBean = new PunchBean()
                {
                    CompID  = model.CompID,
                    DeptID  = model.DeptID,
                    OrganID = model.OrganID
                };
                StringBuilder sb = new StringBuilder();
                SqlCommand.SelectPunchSpecialUnitDefine(ref sb);
                try
                {
                    datas = conn.Query <PunchBean>(sb.ToString(), dataBean).FirstOrDefault();
                }
                catch (Exception)
                {
                    throw;
                }
                if (datas == null)
                {
                    throw new Exception("查無資料!");
                }
            }
            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }
Exemple #15
0
    /// <summary>
    /// 取得FlowOrgan資料
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="datas">回傳資料</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool SelectEmpFlowOrgan(PunchModel model, out PunchBean datas, out string msg)
    {
        bool result = false;

        msg   = "";
        datas = new PunchBean();
        try
        {
            using (var conn = new SqlConnection()
            {
                ConnectionString = DbHelper.getConnectionStrings(_eHRMSDB_ITRD).ConnectionString
            })
            {
                PunchBean dataBean = new PunchBean()
                {
                    CompID = model.CompID,
                    EmpID  = model.EmpID,
                };
                StringBuilder sb = new StringBuilder();
                SqlCommand.SelectEmpFlowOrganSql(ref sb);
                try
                {
                    datas = conn.Query <PunchBean>(sb.ToString(), dataBean).FirstOrDefault();
                }
                catch (Exception)
                {
                    throw;
                }
                if (datas == null)
                {
                    throw new Exception("查無資料!");
                }
            }
            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }
    private void LoadData()
    {
        bool       hasFlow   = false;             //FlowOrgan
        bool       hasReport = false;             //是否有班表
        bool       isSpecial = getPunchSpecial(); //是否為特殊單位
        String     errorFlag = "";                //是否打卡時間異常(早到晚退 T-上班,F-下班)
        String     url       = "";                //目的網頁
        PunchModel report    = new PunchModel();

        try
        {
            hasReport = getPunchReport(out report);
            if (!hasReport)
            {
                throw new Exception("查無班表,無法打卡!");
            }
            hasFlow = getEmpFlowOrgan(ref report);
            if (!hasFlow)
            {
                throw new Exception("查無FlowOrganID");
            }
            errorFlag        = isPunchError(report);
            report.ErrorFlag = errorFlag;
            url = comBinMsg(report, isSpecial);
            if (!isSpecial && "".Equals(errorFlag))
            {
                DoDefine(report);
            }
            else
            {
                Response.Redirect(url);
            }
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    /// <summary>
    /// 取得執勤、個人、公司班表
    /// </summary>
    /// <returns></returns>
    private bool QueryReport(string regStr, out PunchModel viewData)
    {
        bool   result  = false;
        string NowTime = DateTime.Now.ToString("HH:mm:ss");
        var    msg     = "";
        var    datas   = new PunchBean();

        viewData = new PunchModel()
        {
            CompID    = UserInfo.getUserInfo().CompID,
            EmpID     = StringIIF(txtEmpID.Text),
            PunchDate = StringIIF(txtVisitBeginDate.ucSelectedDate)
        };

        switch (regStr)
        {
        case "Duty":
        {
            result = Punch.GetDutyReport(viewData, out datas, out msg);
            break;
        }

        case "EmpWork":
        {
            result = Punch.GetEmpWorkReport(viewData, out datas, out msg);
            break;
        }
        }
        if (result && datas != null)
        {
            viewData.BeginTime     = datas.BeginTime;
            viewData.EndTime       = datas.EndTime;
            viewData.RestBeginTime = datas.RestBeginTime;
            viewData.RestEndTime   = datas.RestEndTime;
        }

        return(result);
    }
    private void initScreen()
    {
        PunchModel model = _PunchModel;

        try
        {
            EmpID_NameN.Text   = model.EmpID + " " + model.EmpName;
            PunchDateTime.Text = model.PunchDate + " " + model.PunchTime.Substring(0, model.PunchTime.Length - 7);
            ResultMsg.Text     = model.ResultMsg;
            if ("0".Equals(model.PunchFlag))
            {
                if (!"2".Equals(model.AbnormalFlag))
                {
                    RemindMsg.Text = model.RemindMsgAf;
                }
                CareMsg.Text = model.CareMsg;
            }
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    //-------------------------------------------------------------主要邏輯區

    /// <summary>
    /// 確定打卡邏輯
    /// </summary>
    private void DoDefine(PunchModel model)
    {
        bool   result       = false;
        long   seccessCount = 0;
        string msg          = "";

        try
        {
            result = Punch.InsertPunchLog(model, out seccessCount, out msg);
            if (!result)
            {
                throw new Exception(msg);
            }
            if (seccessCount == 0)
            {
                throw new Exception("無資料被新增!!");
            }
        }
        catch (Exception ex)
        {
            Util.MsgBox(ex.Message);
        }
    }
    //-------------------------------------------------------------方法

    /// <summary>
    /// 特殊單位
    /// </summary>
    /// <returns></returns>
    private bool getPunchSpecial()
    {
        bool       result    = false;
        bool       isSuccess = false;
        var        msg       = "";
        var        datas     = new PunchBean();
        PunchModel viewData  = new PunchModel()
        {
            CompID  = UserInfo.getUserInfo().CompID,
            DeptID  = UserInfo.getUserInfo().DeptID,
            OrganID = UserInfo.getUserInfo().OrganID,
        };

        isSuccess = Punch.GetPunchSpecial(viewData, out datas, out msg);
        if (isSuccess && datas != null)
        {
            if ("1".Equals(datas.SpecialFlag))
            {
                result = true;
            }
        }

        return(result);
    }
    /// <summary>
    /// 公出時間檢核
    /// </summary>
    /// <param name="msg">檢核失敗訊息</param>
    /// <returns>bool</returns>
    private bool TimeValidation(out string errorMsg, out string tipMsg)
    {
        bool result = true;

        errorMsg = "";
        tipMsg   = "";
        var BeginTimeA = StringIIF(ddlBeginTimeA.Text);
        var BeginTimeB = StringIIF(ddlBeginTimeB.Text);
        var EndTimeA   = StringIIF(ddlEndTimeA.Text);
        var EndTimeB   = StringIIF(ddlEndTimeB.Text);

        if (BeginTimeA == "" || BeginTimeB == "" || EndTimeA == "" || EndTimeB == "")
        {
            errorMsg = "請輸入公出時間";
        }
        else
        {
            var BTimeA = BeginTimeA.StartsWith("0") ? Int32.Parse(BeginTimeA.Substring(1)) : Int32.Parse(BeginTimeA);
            var BTimeB = BeginTimeB.StartsWith("0") ? Int32.Parse(BeginTimeB.Substring(1)) : Int32.Parse(BeginTimeB);
            var ETimeA = EndTimeA.StartsWith("0") ? Int32.Parse(EndTimeA.Substring(1)) : Int32.Parse(EndTimeA);
            var ETimeB = EndTimeB.StartsWith("0") ? Int32.Parse(EndTimeB.Substring(1)) : Int32.Parse(EndTimeB);

            if (BTimeA > 23 || ETimeA > 23)
            {
                errorMsg = "時間格式輸入錯誤(24小時制)";
            }
            else
            {
                if (BTimeA > ETimeA)
                {
                    errorMsg = "開始時間不可以晚於結束時間";
                }
                else if ((BTimeA == ETimeA))
                {
                    if (BTimeB > 59 || ETimeB > 59)
                    {
                        errorMsg = "時間格式輸入錯誤(60分鐘制)";
                    }
                    else if (BTimeB > ETimeB)
                    {
                        errorMsg = "開始時間不可以晚於結束時間";
                    }
                }
                else if (BTimeA < ETimeA)
                {
                    string startTime = BTimeA + ":" + BTimeB;
                    string endTime   = ETimeA + ":" + ETimeB;
                    int    totalMin  = OnBizReq.GetTimeDiff(startTime, endTime, "Minute");
                    if (totalMin > 720)
                    {
                        errorMsg = "公出時間不可以超過12小時";
                    }
                }
            }
        }

        PunchModel report    = new PunchModel();
        bool       hasReport = getPunchReport(out report);

        if (hasReport)
        {
            int chkEndTime = Int32.Parse(report.EndTime);
            int EndTime    = Int32.Parse(EndTimeA + EndTimeB);
            if (chkEndTime < EndTime)
            {
                tipMsg = "您的公出時間已超過下班時間,請至加班系統填寫加班單。";
            }
        }

        if (!"".Equals(errorMsg))
        {
            result = false;
        }
        return(result);
    }
Exemple #22
0
    /// <summary>
    /// 新增DB資料
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="seccessCount">新增筆數</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool InsertPunchLog(PunchModel model, out long seccessCount, out string msg)
    {
        bool result = false;

        seccessCount = 0;
        msg          = "";
        try
        {
            PunchBean databean = new PunchBean()
            {
                CompID           = StringIIF(model.CompID),
                EmpID            = StringIIF(model.EmpID),
                EmpName          = StringIIF(model.EmpName),
                PunchDate        = StringIIF(model.PunchDate),
                PunchTime        = StringIIF(model.PunchTime),
                PunchSeq         = StringIIF(QueryMaxSeq(model)),
                DeptID           = StringIIF(model.DeptID),
                DeptName         = StringIIF(model.DeptName),
                OrganID          = StringIIF(model.OrganID),
                OrganName        = StringIIF(model.OrganName),
                FlowOrganID      = StringIIF(model.FlowOrganID),
                FlowOrganName    = StringIIF(model.FlowOrganName),
                Sex              = StringIIF(model.Sex),
                PunchFlag        = StringIIF(model.PunchFlag),
                WorkTypeID       = StringIIF(model.WorkTypeID),
                WorkType         = StringIIF(model.WorkType),
                MAFT10_FLAG      = StringIIF(model.MAFT10_FLAG),
                AbnormalFlag     = StringIIF(model.AbnormalFlag),
                AbnormalReasonID = StringIIF(model.AbnormalReasonID),
                AbnormalReasonCN = StringIIF(model.AbnormalReasonCN),
                AbnormalDesc     = StringIIF(model.AbnormalDesc),
                BatchFlag        = StringIIF("0"),
                Source           = StringIIF("B"),
                PunchUserIP      = StringIIF(""),
                RotateFlag       = StringIIF(""),
                APPContent       = StringIIF(""),
                Lat              = StringIIF(decimal.Zero),
                Lon              = StringIIF(decimal.Zero),
                GPSType          = StringIIF(""),
                OS          = StringIIF(""),
                DeviceID    = StringIIF(""),
                LastChgComp = StringIIF(model.LastChgComp),
                LastChgID   = StringIIF(model.LastChgID)
            };

            using (var conn = new SqlConnection()
            {
                ConnectionString = DbHelper.getConnectionStrings(_attendantDBName).ConnectionString
            })
            {
                conn.Open();
                StringBuilder sb = new StringBuilder();
                SqlCommand.SelectPunchLogSql(ref sb); //建立查詢SqlCommand
                List <PunchBean> newDataBean = new List <PunchBean>();
                //新增前檢查資料庫是否有重複PK,沒有放進待新增容器
                try
                {
                    var count = conn.Query <PunchBean>(sb.ToString(), databean).Count(); //執行查詢,結果回傳至TestBean物件
                    if (count == 0)
                    {
                        newDataBean.Add(databean);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                if (newDataBean.Count > 0)
                {
                    SqlCommand.InsertPunchLogSql(ref sb, true); //建立新增SqlCommand
                    using (var trans = conn.BeginTransaction())
                    {
                        try
                        {
                            seccessCount = conn.Execute(sb.ToString(), newDataBean, trans); //執行新增,成功筆數回傳,並做Transaction機制
                            trans.Commit();                                                 //成功Transaction直接Commit
                        }
                        catch (Exception)
                        {
                            trans.Rollback(); //失敗Transaction Rollback
                            throw;
                        }
                    }
                }
            }
            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }