Example #1
0
        //开户
        private void button1_Click(object sender, EventArgs e)
        {
            Int64 num=Int64.Parse(textBox1.Text);
            string pwd = textBox2.Text;
            float balance = float.Parse(textBox3.Text);
            string type="";
            if (radioButton1.Checked) type = "world";
            if (radioButton2.Checked) type = "music";
            if (radioButton3.Checked) type = "travel";

            string name = textBox4.Text;
            string address = textBox5.Text;

            Int32 charge=0;
            if (radioButton4.Checked) charge = 10;
            if (radioButton5.Checked) charge = 20;
            if (radioButton6.Checked) charge = 30;

            //封装mobile类
            Mobile mobile = new Mobile();
            mobile.Mobilenumber = num;
            mobile.DateTimeOfMakeCard = DateTime.Now;
            mobile.LastTimePayFor = DateTime.Now;
            mobile.Mobiletype = type;
            mobile.Balance = balance;
            mobile.State = "on";
            mobile.Password = pwd;

            //封装customer类
            Customer customer = new Customer();
            customer.Name = name;
            customer.Address = address;

            //封装Charge类
            ChargeDao chargedao = new ChargeDao();
            Int32 chargeid = chargedao.getId("monthlypay", charge);
            if (chargeid == -1) { MessageBox.Show("保存Charge失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
            Test.Model.Rule rule = new Test.Model.Rule();
            rule.Chargeid = chargeid;
            rule.Mobilenumber = num;

            MainDao dao = new MainDao();
            string message=dao.save(mobile, customer,rule);
            MessageBox.Show(message, message, MessageBoxButtons.OK, MessageBoxIcon.None);
        }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     ChargeDao chargedao = new ChargeDao();
     MessageBox.Show(chargedao.getId("monthlypay",20).ToString());
 }
Example #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Int64 num = Int64.Parse(textBox6.Text);
            string name;
            Int32 chargepermonth;
            if (checkBox1.Checked)
            {
                name = "gprs";
                chargepermonth = 10;
            }
            else if (checkBox2.Checked)
            {
                name = "music";
                chargepermonth = 2;
            }
            else
            {

                MessageBox.Show("请选择要开通的业务类型", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            ChargeDao chargedao = new ChargeDao();
            Int32 chargeid = chargedao.getId(name, chargepermonth, 2);
            Test.Model.Rule rule = new Test.Model.Rule();
            rule.Chargeid = chargeid;
            rule.Mobilenumber = num;
            RuleDao ruleDao = new RuleDao();
            //首先判断是否已经开通了该业务
            if (!ruleDao.check(num,chargeid)) { MessageBox.Show("你已经开通同该业务,无需重复操作", "wrong", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }
            MobileDao mobileDao = new MobileDao();
            //然后判断用户的余额是否足够
            if (!mobileDao.checkBalance(num,chargepermonth)) { MessageBox.Show("你的余额不足,无法开通该业务", "wrong", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }

            ruleDao.save(rule);
            //进行扣费
            mobileDao.koufei(num,chargepermonth);
            MessageBox.Show("新业务开通成功,从即日起每个月进行相关扣费");
        }