Пример #1
0
        public static void Show(string message, MessageboxType type)
        {
            using (MessageBoxExt messageBox = new MessageBoxExt(message))
            {
                string title;
                switch (type)
                {
                case MessageboxType.Error:
                    title = "错误";
                    break;

                case MessageboxType.Info:
                    title = "提示";
                    break;

                default:
                    throw new ArgumentNullException();
                }

                messageBox.Text          = title;
                messageBox.StartPosition = FormStartPosition.CenterParent;
                if (messageBox.ShowDialog() == DialogResult.OK)
                {
                    return;
                }
            }
        }
Пример #2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = this.txtUserName.Text;
                if (string.IsNullOrEmpty(userName))
                {
                    throw new Exception(I18N.Get("请输入用户名"));
                }

                string userPwd = this.txtUserPwd.Text;
                if (string.IsNullOrEmpty(userPwd))
                {
                    throw new Exception(I18N.Get("请输入密码"));
                }

                UserInfo      userInfoService = new UserInfo();
                CustomMessage resouce         = userInfoService.Login(JsonConvert.SerializeObject(new
                {
                    userName,
                    userPwd
                })) as CustomMessage;

                if (resouce.Status != HttpStatus.OK)
                {
                    MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Error);
                }
            }
            catch (Exception objException)
            {
                MessageBoxExt.Show(objException.Message, MessageboxType.Error);
            }
        }
Пример #3
0
        private void BtnRegistered_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = this.txtRegistered_UserName.Text;
                if (string.IsNullOrEmpty(userName))
                {
                    throw new Exception(I18N.Get("请输入用户名"));
                }

                string userPwd = this.txtRegistered_UserPwd.Text;
                if (string.IsNullOrEmpty(userPwd))
                {
                    throw new Exception(I18N.Get("请输入密码"));
                }

                string userEmail = this.txtRegistered_Email.Text;
                if (string.IsNullOrEmpty(userPwd))
                {
                    throw new Exception(I18N.Get("请输入邮箱"));
                }
                if (!Regex.IsMatch(userEmail, @"^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$"))
                {
                    throw new Exception(I18N.Get("请输入正确的邮箱号"));
                }

                UserInfo      userInfoService = new UserInfo();
                CustomMessage resouce         = userInfoService.Register(JsonConvert.SerializeObject(new
                {
                    userName,
                    userPwd,
                    emailAddress = userEmail
                })) as CustomMessage;

                if (resouce.Status != HttpStatus.OK)
                {
                    MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Error);
                }
                else
                {
                    MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Info);
                }
            }
            catch (Exception objException)
            {
                MessageBoxExt.Show(objException.Message, MessageboxType.Error);
            }
        }