//开户 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); }
public async Task ShouldCancelSaveTask() { var provider = EntityManagerProviderFactory.CreateTestEntityManagerProvider(); var unitOfWork = new UnitOfWork<Customer>(provider); var em = provider.Manager; var customer = new Customer { CustomerID = Guid.NewGuid(), CompanyName = "Foo" }; em.AddEntity(customer); em.Saving += (sender, args) => args.Cancel = true; Assert.IsTrue(em.HasChanges()); await unitOfWork.CommitAsync() .ContinueWith(task => Assert.IsTrue(task.IsCanceled, "Should be cancelled")); }
public void DeleteCustomer(Customer customer) { customer.EntityAspect.Delete(); }
public void AddCustomer(Customer customer) { Manager.AddEntity(customer); }