Esempio n. 1
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            if (txtNumber.Text.Trim() == "")
            {
                epNumber.SetError(txtNumber, "请输入会员卡号");
                return;
            }
            else
            {
                if (vipBLL.IsExistVip(txtNumber.Text.Trim()))
                {
                    epNumber.SetError(txtNumber, "该卡号已注册");
                    return;
                }
                else
                {
                    epNumber.SetError(txtNumber, "");
                }
            }
            if (cmbLevel.SelectedValue == null)
            {
                epLevel.SetError(cmbLevel, "请选择会员等级");
                return;
            }
            else
            {
                epLevel.SetError(cmbLevel, "");
            }
            if (txtName.Text.Trim() == "")
            {
                epName.SetError(txtName, "请输入会员名称");
                return;
            }
            else
            {
                epName.SetError(txtName, "");
            }
            if (cmbSex.SelectedItem == null)
            {
                epSex.SetError(cmbSex, "请选择会员性别");
                return;
            }
            else
            {
                epSex.SetError(cmbSex, "");
            }
            if (txtPWD.Text.Trim() == "")
            {
                epPWD.SetError(txtPWD, "请输入会员密码");
                return;
            }
            else
            {
                if (txtPWD.Text.Length < 6)
                {
                    epPWD.SetError(txtPWD, "密码长度不得低于六位数");
                    return;
                }
                else
                {
                    epPWD.SetError(txtPWD, "");
                }
            }

            if (txtPWDConfirm.Text.Trim() == "")
            {
                epPWD2.SetError(txtPWDConfirm, "请再次输入会员密码");
                return;
            }
            else
            {
                if (txtPWD.Text.Trim() != txtPWDConfirm.Text.Trim())
                {
                    epPWD2.SetError(txtPWDConfirm, "两次输入的密码不一致");
                    return;
                }
                else
                {
                    epPWD2.SetError(txtPWDConfirm, "");
                }
            }

            if (txtPhone.Text.Trim() == "")
            {
                epPhone.SetError(txtPhone, "请输入会员电话");
                return;
            }
            else
            {
                if (!CheckPhone(txtPhone.Text.Trim()))
                {
                    epPhone.SetError(txtPhone, "联系电话输入错误");
                    return;
                }
                else
                {
                    epPhone.SetError(txtPhone, "");
                }
            }

            if (txtCard.Text.Trim() == "")
            {
                epCard.SetError(txtCard, "请输入会员身份证号");
                return;
            }
            else
            {
                if (!CheckCidInfo(txtCard.Text.Trim()))
                {
                    epCard.SetError(txtCard, "身份证输入错误");
                    return;
                }
                else
                {
                    epCard.SetError(txtCard, "");
                }
            }

            if (txtAddress.Text.Trim() == "")
            {
                epAddress.SetError(txtAddress, "请输入会员地址");
                return;
            }
            else
            {
                epAddress.SetError(txtAddress, "");
            }
            double a = 0;

            if (double.TryParse(txtMoney.Text, out a))
            {
                money = double.Parse(txtMoney.Text.Trim());
                if (money < 0)
                {
                    epAddress.SetError(txtMoney, "请输入正确的金额");
                    return;
                }
                if (money > 500)
                {
                    MessageBox.Show("充值金额不得操作500元");
                    return;
                }
                epAddress.SetError(txtMoney, "");
            }
            else
            {
                epAddress.SetError(txtMoney, "请输入正确的金额");
                return;
            }
            if (txtMark.Text.Length <= 0)
            {
                vipModel.Mark = "";
            }
            else
            {
                vipModel.Mark = txtMark.Text.ToString().Trim();
            }
            DialogResult result = MessageBox.Show("充值" + txtMoney.Text + "元?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            vipModel.VipNumber  = txtNumber.Text.Trim();
            vipModel.VipName    = txtName.Text.Trim();
            vipModel.VipLevelId = Convert.ToInt32(cmbLevel.SelectedValue);
            vipModel.VipSex     = cmbSex.SelectedItem.ToString() == "男" ? true : false;
            vipModel.VipPWD     = txtPWD.Text.Trim();
            vipModel.VipPhone   = txtPhone.Text.Trim();
            vipModel.VipCard    = txtCard.Text.Trim();
            string   cid      = txtCard.Text.Trim();
            DateTime birthDay = DateTime.Parse(cid.Substring(6, 4) + "-" + cid.Substring(10, 2) + "-" + cid.Substring(12, 2));

            vipModel.VipBirthDay = birthDay;
            vipModel.VipAddress  = txtAddress.Text.Trim();
            vipModel.VipPhoto    = image;
            vipModel.DpId        = StaticData.departLocal.DpId;
            vipModel.UserId      = StaticData.userLocal.UserId;
            logInfo.UserId       = StaticData.userLocal.UserId;
            logInfo.Content      = "添加会员,名称为‘" + txtName.Text;
            logInfo.LogTime      = DateTime.Now;
            logInfo.DpId         = StaticData.departLocal.DpId;
            btnEnter.Enabled     = false;
            progressBar1.Visible = true;
            backgroundWorker1.RunWorkerAsync();
        }