?? frmapply.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 + -