Exemple #1
0
        /// <summary>
        /// 绑定主菜单数据
        /// </summary>
        private void BindMainMenu()
        {
            ResetButton();

            //获取用户一级权限菜单
            int            icnt;
            List <EapMenu> list = Bll.GetBll().GetUserRight(pageno, pagesize, out icnt);

            if (list == null || list.Count == 0)
            {
                return;
            }

            //更新按钮总页数
            if (icnt % pagesize == 0)
            {
                pagecnt = icnt / pagesize;
            }
            else
            {
                pagecnt = (icnt / pagesize) + 1;
            }

            //设置按钮名称和tag
            for (int i = 0; i < list.Count; i++)
            {
                btn[i].Text    = list[i].MENU_NAME;
                btn[i].Tag     = list[i].MENU_ID;
                btn[i].Enabled = true;
            }

            //更新翻页按钮状态
            ResetPageButton();
        }
Exemple #2
0
        private void CheckIsForm()
        {
            //如果有窗体类名称则创建窗体
            EapMenu menu = Bll.GetBll().GetMenuById(menuid);

            if (menu.FORM_NAME != null)
            {
                try
                {
                    Assembly assembly = Assembly.LoadFile(Application.StartupPath + "\\" + menu.ASSEMBLY_NAME);
                    Type     t        = assembly.GetType(menu.FORM_NAME);

                    Form frm = (Form)Activator.CreateInstance(t);
                    frm.MdiParent   = this.MdiParent;
                    frm.WindowState = FormWindowState.Maximized;
                    frm.Show();
                }
                catch (Exception ex)
                {
                    Func.ShowMessage(MessageType.Error, ex.Message);
                }
            }
            else
            {
                prevbindmenuid = bindmenuid;
                bindmenuid     = menuid;
                pageno         = 1;
                BindSubMenu();
            }
        }
Exemple #3
0
        /// <summary>
        /// 比较本地文件和服务器文件清单
        /// </summary>
        /// <returns>true:文件不一致,需要更新;false:文件一致,不需要更新</returns>
        private static bool CompareFiles()
        {
            bool flag = false;

            List <EapFile> list = Bll.GetBll().GetAppFiles();

            //获取文件清单失败或者文件清单为空,为保证程序可运行,不做处理
            if (list == null || list.Count == 0)
            {
                return(false);
            }

            foreach (EapFile sub in list)
            {
                string path = Application.StartupPath + "\\" + sub.FILE_ID;

                //判断文件是否存在
                if (!File.Exists(path))
                {
                    flag = true;
                    break;
                }

                //比较文件
                if (sub.FILE_VERSION == null || sub.FILE_VERSION == string.Empty)
                {
                    //没有版本信息时,比较最后修改时间(Oracle数据库Date字段不包括毫秒)
                    FileInfo fi = new FileInfo(path);
                    if (Func.FormatDate(fi.LastWriteTime, false) + Func.FormatTime(fi.LastWriteTime, false, false)
                        != Func.FormatDate(sub.FILE_EDIT_TIME, false) + Func.FormatTime(sub.FILE_EDIT_TIME, false, false))
                    {
                        flag = true;
                        break;
                    }
                }
                else
                {
                    //比较版本
                    if (FileVersionInfo.GetVersionInfo(path).FileVersion != sub.FILE_VERSION)
                    {
                        flag = true;
                        break;
                    }
                }
            }

            return(flag);
        }
Exemple #4
0
        /// <summary>
        /// 下载并写入最新的配置文件和更新程序
        /// </summary>
        private static void Update()
        {
            List <EapFile> list = Bll.GetBll().GetUpdate();

            foreach (EapFile sub in list)
            {
                FileStream fs = new FileStream(Application.StartupPath + "\\" + sub.FILE_ID, FileMode.Create, FileAccess.Write);
                fs.Write(sub.FILE_DATA, 0, sub.FILE_DATA.Length);
                fs.Close();

                if (sub.FILE_ID == "Eap.config")
                {
                    File.SetLastWriteTime(Application.StartupPath + "\\" + sub.FILE_ID, sub.FILE_EDIT_TIME);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 绑定子菜单数据
        /// </summary>
        private void BindSubMenu()
        {
            //获取用户指定菜单的子菜单权限
            int            icnt;
            List <EapMenu> list = Bll.GetBll().GetUserSubMenuRight(bindmenuid, pageno, pagesize, out icnt);

            if (list == null)
            {
                return;
            }

            if (list.Count > 0)
            {
                //更新按钮总页数
                if (icnt % pagesize == 0)
                {
                    pagecnt = icnt / pagesize;
                }
                else
                {
                    pagecnt = (icnt / pagesize) + 1;
                }

                ResetButton();

                //设置按钮名称和tag
                for (int i = 0; i < list.Count; i++)
                {
                    btn[i].Text    = list[i].MENU_NAME;
                    btn[i].Tag     = list[i].MENU_ID;
                    btn[i].Enabled = true;
                }

                //更新翻页按钮状态
                ResetPageButton();
            }
            else
            {
                bindmenuid = prevbindmenuid;
                Func.ShowMessage(MessageType.Error, "绑定错误,没有找到子菜单数据");
            }
        }
Exemple #6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            EapUser user = getEapUser();

            if (user == null)
            {
                return;
            }

            if (Bll.GetBll().Login(user))
            {
                frmMain fm = new frmMain();
                fm.UserName = Config.GetConfig().user.USER_NAME;
                fm.Show();

                this.Hide();
            }
            else
            {
                txtUid.Focus();
            }
        }
Exemple #7
0
        private void frmMainMenu_Load(object sender, EventArgs e)
        {
            try
            {
                List <EapMenu> menus = Bll.GetBll().GetUserMenu(Config.GetConfig().user.USER_ID);
                if (null == menus)
                {
                    this.lblErrMsg.Text = "获取菜单失败!";
                }

                this.tlpLayout.SuspendLayout();
                var ctlMenu = new MenuEx((int)this.tlpLayout.Width, (int)(this.tlpLayout.Height * this.tlpLayout.RowStyles[1].Height / 100),
                                         menus, new EventHandler(OpenForm));
                ctlMenu.Dock   = DockStyle.Fill;
                ctlMenu.Anchor = AnchorStyles.Bottom;
                this.tlpLayout.Controls.Add(ctlMenu, 0, 1);
                this.tlpLayout.ResumeLayout();
            }
            catch (Exception ex)
            {
                this.lblErrMsg.Text = ex.Message;
            }
        }