Beispiel #1
0
        /// <summary>
        /// 实例化窗体页面
        /// </summary>
        /// <param name="url"></param>
        /// <param name="isTop"></param>
        private void CreateForm(string url, int isTop)
        {
            //程序集的名称
            string assName = this.GetType().Assembly.GetName().Name;
            string frmName = url.Substring(url.LastIndexOf('.') + 1);

            if (!FormUtility.CheckOpenForm(frmName))
            {
                ObjectHandle t = Activator.CreateInstance(assName, assName + "." + url);
                Form         f = (Form)t.Unwrap();
                if (f.Name.Contains(MenuDesp.ModifyPwd.ToString()))//修改密码页面传值
                {
                    f.Tag = new FMPwdModel()
                    {
                        UName  = uName,
                        FLogin = this.fLogin,
                        FMain  = this
                    };
                }
                else
                {
                    f.Tag = uName;
                }
                if (isTop == 0)
                {
                    //内嵌到选项卡里
                    tcPages.AddTabFormPage(f);
                }
                else
                {
                    //顶级显示
                    f.StartPosition = FormStartPosition.CenterScreen;
                    f.WindowState   = FormWindowState.Normal;
                    f.ShowDialog();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //接收信息
            string userName = txtUName.Text.Trim();
            string userPwd  = txtUPwd.Text.Trim();

            //判断是否为空
            if (string.IsNullOrEmpty(userName))
            {
                MsgBoxHelper.MsgErrorShow("账号不能为空!");
                txtUName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(userPwd))
            {
                MsgBoxHelper.MsgErrorShow("密码不能为空!");
                txtUPwd.Focus();
                return;
            }
            Action act = () =>
            {
                //加密
                string enPwd = MD5Encrypt.Encrypt(userPwd);

                List <ViewUserRoleModel> urList = RequestStar.Login(userName, enPwd); //登录
                                                                                      //判断结果
                if (urList == null || urList.Count == 0)
                {
                    MsgBoxHelper.MsgErrorShow("账号或密码输入有误,请检查!");
                    return;
                }
                else
                {
                    //转到主页面
                    if (!FormUtility.CheckOpenForm("FrmMain"))
                    {
                        FrmMain fMain = new FrmMain();
                        //登录页面显示处理---隐藏,不能关闭
                        fMain.Tag = new LoginModel()
                        {
                            URList    = urList,
                            LoginForm = this
                        };
                        fMain.Show();
                    }
                    else
                    {
                        //更换登录者时发生(暂留,后面实现)
                        //FormUtility.ShowOpenForm("FrmMain");
                        foreach (Form frm in Application.OpenForms)
                        {
                            if (frm.Name == "FrmMain")
                            {
                                frm.Tag = new LoginModel()
                                {
                                    URList    = urList,
                                    LoginForm = this
                                };
                                frm.Show();
                                break;
                            }
                        }
                    }
                    this.Hide();
                }
            };

            act.TryCatch("登录系统出现异常");
        }