Beispiel #1
0
        public JsonResult execInsert(String cParentFunctionID, String cFunctionName, int iSortBy, String cFlag, String vFunctionUrl, String vFunctionMemo)
        {
            CodeFuncDao codeFuncDao = new CodeFuncDao();

            if (codeFuncDao.chkFuncName("", cFunctionName) != null)
            {
                var jsonData = new { success = false, err = "功能名稱:”功能名稱”已存在,請重新輸入!" };
                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }

            CODE_FUNC func = new CODE_FUNC();

            func.SYS_CD         = "TREASURY";
            func.PARENT_FUNC_ID = cParentFunctionID;
            func.FUNC_NAME      = cFunctionName;
            func.FUNC_LEVEL     = 2;
            func.FUNC_MEMO      = vFunctionMemo;
            func.FUNC_URL       = vFunctionUrl;
            func.FUNC_ORDER     = iSortBy;
            func.IS_DISABLED    = cFlag;
            func.CREATE_UID     = Session["UserID"].ToString();

            string strConn = DbUtil.GetDBTreasuryConnStr();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                SqlTransaction transaction = conn.BeginTransaction("Transaction");

                try
                {
                    func = codeFuncDao.insert(func, conn, transaction);

                    Log log = new Log();
                    log.CFUNCTION = "功能維護作業-新增";
                    log.CACTION   = "A";
                    log.CCONTENT  = codeFuncDao.funcLogContent(func);
                    LogDao.Insert(log, Session["UserID"].ToString());

                    transaction.Commit();

                    var jsonData = new { success = true, id = func.FUNC_ID.Trim() };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    logger.Error("[execInsert]其它錯誤:" + e.ToString());
                    var jsonData = new { success = false, err = "其它錯誤,請洽系統管理員!!" };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
            }
        }
Beispiel #2
0
        public JsonResult execModify(String cFunctionId, String cFunctionName, int iSortBy, String cFlag, String vFunctionUrl, String vFunctionMemo)
        {
            CodeFuncDao codeFuncDao = new CodeFuncDao();

            if (codeFuncDao.chkFuncName(cFunctionId, cFunctionName) != null)
            {
                var jsonData = new { success = false, err = "功能名稱:”功能名稱”已存在,請重新輸入!" };
                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }

            FuncMgrDetailModel funcO = codeFuncDao.qryByKey(cFunctionId);

            CODE_FUNC func = new CODE_FUNC();

            func.SYS_CD         = "TREASURY";
            func.FUNC_ID        = cFunctionId;
            func.PARENT_FUNC_ID = funcO.cParentFunctionID;
            func.FUNC_NAME      = StringUtil.toString(cFunctionName);
            func.FUNC_LEVEL     = funcO.iFunctionLevel;
            func.FUNC_MEMO      = StringUtil.toString(vFunctionMemo);
            func.FUNC_URL       = vFunctionUrl;
            func.FUNC_ORDER     = iSortBy;
            func.IS_DISABLED    = cFlag;
            func.CREATE_UID     = funcO.cCrtUserID;
            func.CREATE_DT      = DateUtil.stringToDatetime(funcO.cCrtDate);

            func.LAST_UPDATE_UID = Session["UserID"].ToString();
            func.LAST_UPDATE_DT  = DateTime.Now;


            string strConn = DbUtil.GetDBTreasuryConnStr();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                SqlTransaction transaction = conn.BeginTransaction("Transaction");

                try
                {
                    func = codeFuncDao.update(func, conn, transaction);


                    Log log = new Log();
                    log.CFUNCTION = "功能維護作業-修改";
                    log.CACTION   = "U";
                    log.CCONTENT  = codeFuncDao.funcLogContent(func);
                    LogDao.Insert(log, Session["UserID"].ToString());


                    transaction.Commit();

                    var jsonData = new { success = true, id = func.FUNC_ID.Trim() };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    logger.Error("[execModify]其它錯誤:" + e.ToString());

                    var jsonData = new { success = false, err = "其它錯誤,請洽系統管理員!!" };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
            }
        }