⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmapply.cs

📁 一个即时通信工具
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
using Model;

namespace MyQQ
{
    public partial class frmApply : Form
    {
        public frmApply()
        {
            InitializeComponent();
        }

        private void CheckInput()
        {
            
            if (string.IsNullOrEmpty(txtNickName.Text.Trim()))
                throw new Exception("昵称不能为空,请重新输入!");
           
            int iAge=0;
            if (string.IsNullOrEmpty(txtAge.Text))
                throw new Exception("年龄不能为空,请重新输入!");
            else
                if (!int.TryParse(txtAge.Text, out iAge))
                    throw new Exception("年龄必须是数字!");

            if (string.IsNullOrEmpty(txtPassword.Text))
                throw new Exception("密码不能为空,请重新输入!");

            if (txtPassword.Text != txtPassword2.Text)
                throw new Exception("您两次输入的密码不一致,请重新输入!");

        }

        public UsersInfo ObjectEntity
        {
            get
            {
                UsersInfo obj = new UsersInfo();
                obj.LoginPwd = txtPassword.Text;
                obj.FriendshipPolicy = new FriendshipPolicyInfo(1);
                obj.NickName = txtNickName.Text.Trim();
                obj.Sex = rdbMale.Checked ? "男" : "女";
                obj.Age = int.Parse(txtAge.Text);
                obj.Name = txtName.Text.Trim();
                obj.Star = new StarInfo(int.Parse(cboStar.SelectedValue.ToString()));
                obj.BloodType = new BloodTypeInfo(int.Parse(cboBloodType.SelectedValue.ToString()));
                obj.LoginPwd = txtPassword.Text;
                return obj;
            }
        }

        private void BindComboBox()
        {
            this.cboBloodType.DataSource = BloodType.SelectAll();
            this.cboBloodType.DisplayMember = "BloodType";
            this.cboBloodType.ValueMember = "Id";

            this.cboStar.DataSource = Star.SelectAll();
            this.cboStar.DisplayMember = "Star";
            this.cboStar.ValueMember = "Id";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                CheckInput();
                object obj = Users.Register(this.ObjectEntity);
                if (obj != null)
                    MessageBox.Show("注册成功!您的申请的号是:" + obj.ToString());
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }


        private void frmApply_Load(object sender, EventArgs e)
        {
            BindComboBox();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -