Exemplo n.º 1
0
        /// <summary>
        /// Get all protection of menu entry
        /// </summary>
        /// <returns>Menu entry dataset</returns>
        public DataSet GetAllProtection()
        {
            var     dsSysMenuEntry = new Sys_Menu_EntryDS();
            DataSet dstData        = dsSysMenuEntry.GetAllProtection();

            return(dstData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update data table
        /// </summary>
        public void UpdateDataTable(DataTable pdtbData)
        {
            const string METHOD_NAME = THIS + ".Delete()";

            try
            {
                using (var trans = new TransactionScope())
                {
                    var dsMenuEntry = new Sys_Menu_EntryDS();
                    dsMenuEntry.UpdateDataTable(pdtbData);
                    trans.Complete();
                }
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    if (ex.Number == ErrorCode.SQLDUPLICATE_UNIQUE_KEYCODE)
                    {
                        throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                    }
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// We need to check this menu is already have transaction or not.
        /// If have transaction, unable to delete.
        /// If have no transaction, delete it
        /// </summary>
        public void Delete(int menuId)
        {
            const string METHOD_NAME = THIS + ".Delete()";

            try
            {
                using (var trans = new TransactionScope())
                {
                    var dcPCS = new PCSDataContext(Utils.Instance.ConnectionString);

                    var menu      = dcPCS.Sys_Menu_Entries.SingleOrDefault(m => m.Menu_EntryID == menuId);
                    var objRights = dcPCS.Sys_Rights.SingleOrDefault(m => m.Menu_EntryID == menuId);

                    var dsMenuEntry = new Sys_Menu_EntryDS();
                    // we need to check this menu is already have transaction or not
                    int intNumOfTrans = 0;
                    if (menu.TableName != null)
                    {
                        if (menu.TableName.Trim() != string.Empty && menu.TransNoFieldName.Trim() != string.Empty)
                        {
                            intNumOfTrans = dsMenuEntry.GetAllTransactions(menu);
                        }
                    }
                    // if have transaction, unable to delete
                    if (intNumOfTrans > 0)
                    {
                        throw new PCSBOException(ErrorCode.MESSAGE_COULD_NOT_DELETE_MENU, METHOD_NAME, new Exception());
                    }
                    // update button caption
                    var subMenus = dcPCS.Sys_Menu_Entries.Where(
                        m => m.Parent_Shortcut == menu.Shortcut && m.Button_Caption > menu.Button_Caption).OrderBy(
                        m => m.Button_Caption).ToList();
                    subMenus.ForEach(m => m.Button_Caption = m.Button_Caption - 1);

                    // if have no transction, delete it
                    if (objRights != null)
                    {
                        dcPCS.Sys_Rights.DeleteOnSubmit(objRights);
                    }
                    dcPCS.Sys_Menu_Entries.DeleteOnSubmit(menu);

                    // submit changes
                    dcPCS.SubmitChanges();
                    trans.Complete();
                }
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    if (ex.Number == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
                    {
                        throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                    }
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get all menu items with image fields
        /// </summary>
        /// <param name="pobjCulture">Current culture</param>
        /// <returns>ArrayList object</returns>
        /// <author> Duong NA - Sep 23, 2005</author>
        public ArrayList GetAllMenusWithImageFields(CultureInfo pobjCulture)
        {
            var dsSys_Menu_Entry = new Sys_Menu_EntryDS();

            return(dsSys_Menu_Entry.GetAllMenusWithImageFields(pobjCulture));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get all menu items with image fields by specific user
        /// </summary>
        /// <param name="pobjCulture">Current culture</param>
        /// <param name="pstrUserName">User name</param>
        /// <returns>ArrayList object</returns>
        /// <author> Duong NA - Sep 23, 2005</author>
        public List <Sys_Menu_Entry> GetAllMenusWithImageFields(CultureInfo pobjCulture, string pstrUserName)
        {
            var dsSys_Menu_Entry = new Sys_Menu_EntryDS();

            return(dsSys_Menu_Entry.GetAllMenusWithImageFields(pobjCulture, pstrUserName));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get all menu items in current culture of a specified user
        /// </summary>
        /// <param name="pobjCulture">Current culture</param>
        /// <param name="pstrUserName">Current user</param>
        /// <returns></returns>
        /// <author> Tuan DM - Jan 14, 2005</author>
        public ArrayList GetAllMenus(CultureInfo pobjCulture, string pstrUserName)
        {
            var dsSys_Menu_Entry = new Sys_Menu_EntryDS();

            return(dsSys_Menu_Entry.GetAllMenus(pobjCulture, pstrUserName));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get menu by its short cut
        /// </summary>
        /// <param name="pstrShortCut">Shortcut of menu</param>
        /// <returns>SysMenu</returns>
        public object GetMenuByShortCut(string pstrShortCut)
        {
            var dsMenuEntry = new Sys_Menu_EntryDS();

            return(dsMenuEntry.GetMenuByShortCut(pstrShortCut));
        }