public Boolean createFunctionCode(string func_code, string func_name)
        {
            UASFNC funcCode = new UASFNC();

            funcCode.FUNC_CODE = func_code;
            funcCode.FUNC_NAME = func_name;
            return(createFunctionCode(funcCode));
        }
Esempio n. 2
0
        private void FuncCodeDataGridView_Click(object sender, EventArgs e)
        {
            UASFNC selectFuncCode = getSelectedRowToTextBox();

            if (selectFuncCode == null)
            {
                return;
            }
            fillFuncCodeDataToTextBox(selectFuncCode.FUNC_CODE, selectFuncCode.FUNC_NAME);
        }
 /// <summary>
 /// Updates the user.
 /// </summary>
 /// <param name="conn">The connection.</param>
 /// <param name="funcCode">The function code.</param>
 public void updateUser(DBConnection_EF conn, UASFNC funcCode)
 {
     try
     {
         conn.SaveChanges();
     }
     catch (Exception ex)
     {
         logger.Warn(ex);
         throw;
     }
 }
 /// <summary>
 /// Creates the function code.
 /// </summary>
 /// <param name="conn">The connection.</param>
 /// <param name="funcCode">The function code.</param>
 public void createFunctionCode(DBConnection_EF conn, UASFNC funcCode)
 {
     try
     {
         conn.UASFNC.Add(funcCode);
         conn.SaveChanges();
     }
     catch (Exception ex)
     {
         logger.Warn(ex);
         throw;
     }
 }
        public Boolean updateFunctionCodeByCode(string func_code, string func_name)
        {
            DBConnection_EF conn = null;

            try
            {
                conn = DBConnection_EF.GetContext();
                conn.BeginTransaction();

                UASFNC funcCode = functionCodeDao.getFunctionCode(conn, true, func_code);
                funcCode.FUNC_NAME = func_name;
                functionCodeDao.updateUser(conn, funcCode);

                conn.Commit();
            }
            catch (Exception ex)
            {
                logger.Warn("Update Failed From UASFNC [func_code:{0}]", func_code, ex);
                if (conn != null)
                {
                    try
                    {
                        conn.Rollback();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Rollback Failed.", exception);
                    }
                }
                return(false);
            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.Close();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Close Connection Failed.", exception);
                    }
                }
            }
            return(true);
        }
        /// <summary>
        /// Gets the function code.
        /// </summary>
        /// <param name="conn">The connection.</param>
        /// <param name="readLock">The read lock.</param>
        /// <param name="func_code">The func_code.</param>
        /// <returns>FunctionCode.</returns>
        public UASFNC getFunctionCode(DBConnection_EF conn, Boolean readLock, string func_code)
        {
            UASFNC funcCode = null;

            try
            {
                var query = from fun_code in conn.UASFNC
                            where fun_code.FUNC_CODE == func_code.Trim()
                            select fun_code;
                funcCode = query.SingleOrDefault();
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
                throw;
            }
            return(funcCode);
        }
Esempio n. 7
0
        private UASFNC getSelectedRowToTextBox()
        {
            int selectedRowCnt = FuncCodeDataGridView.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCnt <= 0)
            {
                return(null);
            }
            int selectedIndex = FuncCodeDataGridView.SelectedRows[0].Index;

            if (funcCodeDataList.Count <= selectedIndex)
            {
                return(null);
            }
            UASFNC selectFuncCode = funcCodeDataList[selectedIndex];

            return(selectFuncCode);
        }
        public Boolean createFunctionCode(UASFNC functionCode)
        {
            DBConnection_EF conn = null;

            try
            {
                conn = DBConnection_EF.GetContext();
                conn.BeginTransaction();
                functionCodeDao.createFunctionCode(conn, functionCode);
                conn.Commit();
            }
            catch (Exception ex)
            {
                logger.Warn("Insert Failed to UASFNC [Func_Code:{0}]", functionCode.FUNC_CODE, ex);
                if (conn != null)
                {
                    try
                    {
                        conn.Rollback();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Rollback Failed.", exception);
                    }
                }
                return(false);
            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.Close();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Close Connection Failed.", exception);
                    }
                }
            }
            return(true);
        }
        /// <summary>
        /// Gets the select function code list.
        /// </summary>
        /// <returns>List&lt;FunctionCode&gt;.</returns>
        public List <UASFNC> getSelectFunctionCodeList()
        {
            List <UASFNC> selectFuncCodeList = new List <UASFNC>();

            foreach (DataGridViewRow dr in FuncCodeDataGridView.Rows)
            {
                if (dr.Cells["ck"].Value != null && (bool)dr.Cells["ck"].Value)
                {
                    int selectIndex = dr.Index;
                    if (selectIndex < 0 || selectIndex >= funcCodeDataList.Count)
                    {
                        continue;
                    }
                    UASFNC selFunc = funcCodeDataList[selectIndex];
                    selectFuncCodeList.Add(selFunc);
                }
            }
            return(selectFuncCodeList);
        }
        /// <summary>
        /// Deletes the function code by code.
        /// </summary>
        /// <param name="conn">The connection.</param>
        /// <param name="func_code">The func_code.</param>
        public void deleteFunctionCodeByCode(DBConnection_EF conn, string func_code)
        {
            UASFNC funcCode = null;

            try
            {
                var query = from fun_code in conn.UASFNC
                            where fun_code.FUNC_CODE == func_code.Trim()
                            select fun_code;
                funcCode = query.SingleOrDefault();

                conn.UASFNC.Remove(funcCode);
                conn.SaveChanges();
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
                throw;
            }
        }
Esempio n. 11
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            if (!BCUtility.doLogin(this, bcApp, BCAppConstants.FUNC_USER_MANAGEMENT))
            {
                return;
            }
            UASFNC selectFuncCode = getSelectedRowToTextBox();

            if (selectFuncCode == null)
            {
                return;
            }
            if (BCFUtility.isMatche(BCAppConstants.FUNC_USER_MANAGEMENT, selectFuncCode.FUNC_CODE))
            {
                return;
            }
            var confirmResult = MessageBox.Show(this, "Are you sure to delete this item ?",
                                                "Confirm Delete!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult != DialogResult.Yes)
            {
                return;
            }

            Boolean deleteSuccess =
                bcApp.SCApplication.UserBLL.deleteFunctionCodeByCode(selectFuncCode.FUNC_CODE);

            if (deleteSuccess)
            {
                //MessageBox.Show(this, BCApplication.getMessageString("DELETE_SUCCESS"));
                BCUtility.showMsgBox_Info(this, BCApplication.getMessageString("DELETE_SUCCESS"));
                Refresh();
            }
            else
            {
                //MessageBox.Show(this, BCApplication.getMessageString("DELETE_FAILED"));
                BCUtility.showMsgBox_Info(this, BCApplication.getMessageString("DELETE_FAILED"));
            }
        }