コード例 #1
0
ファイル: CreateUser.cs プロジェクト: hanwest00/HXMail
        private void button1_Create_Click(object sender, EventArgs e)
        {
            if (!ValiInput())
            {
                return;
            }
            UserInfo userInfo = new UserInfo();

            userInfo.EmailAddress = textBox1.Text;
            userInfo.UserName     = textBox5.Text;
            userInfo.Password     = textBox2.Text;
            userInfo.PopAddress   = textBox4.Text;
            userInfo.SmtpAddress  = textBox3.Text;
            userInfo.PopPort      = int.Parse(textBox7.Text);
            userInfo.SmtpPort     = int.Parse(textBox6.Text);
            userInfo.CreateDate   = DateTime.Now;

            UserManage userMng = new UserManage();

            userMng.OnCreateUserErrorEvent += new UserManage.CreateUserErrorHandler((Exception ex) =>
            {
                Common.AppLog.SysLog(ex.ToString());
                MessageBox.Show(LanguageSelect.getResc("CreateUserError"));
            });

            userMng.OnCreatedUserEvent += new UserManage.CreatedUserHandler(() =>
            {
                Common.AppLog.SysLog(string.Format(LanguageSelect.getResc("SysUserCreate"), userInfo.EmailAddress));
            });

            switch (userMng.CreateUser(userInfo))
            {
            case 1: MessageBox.Show(LanguageSelect.getResc("CreateUserSuccess"));
                AppMain.currUser = userInfo;
                DownLoadMails f = new DownLoadMails();
                f.Show();
                f.Activate();
                this.Close();
                break;

            case 2: MessageBox.Show(LanguageSelect.getResc("RepeatUser"));
                break;
            }
        }