Beispiel #1
0
    /// <summary>
    /// 刪除EmpWorkTime資料
    /// </summary>
    /// <param name="model">畫面model</param>
    /// <param name="msg">回傳訊息</param>
    /// <returns>bool</returns>
    public static bool DeleteEmpWorkTime(List <EmpWorkTimeBean> dataBean, out string msg)
    {
        bool result = false;

        msg = "";
        try
        {
            using (var conn = new SqlConnection()
            {
                ConnectionString = DbHelper.getConnectionStrings(_attendantDBName).ConnectionString
            })
            {
                conn.Open();

                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        conn.Execute(WorkTimeSql.DeleteEmpWorkTime(), dataBean, trans); //執行修改,並做Transaction機制
                        trans.Commit();                                                 //成功Transaction直接Commit
                    }
                    catch (Exception)
                    {
                        trans.Rollback(); //失敗Transaction Rollback
                        result = false;
                        throw;
                    }
                }
            }
            result = true;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        return(result);
    }