private void btnUOW_Click(object sender, EventArgs e) { IUow uow = FactoryDAL <IUow> .Create("EFUow"); try { CustomerBase cust1 = new CustomerBase(); cust1.CustomerType = "Lead"; cust1.CustomerName = "Cust1"; cust1.BillDate = Convert.ToDateTime(txtBillingDate.Text); IRepository <CustomerBase> dal1 = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text); dal1.SetUnitOfWork(uow); dal1.Add(cust1); CustomerBase cust2 = new CustomerBase(); cust2.CustomerType = "Lead"; cust2.CustomerName = "Cust2"; cust2.BillDate = Convert.ToDateTime(txtBillingDate.Text); cust2.Address = "111111111111111111111111111111111111111111111111111111111111111"; IRepository <CustomerBase> dal2 = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text); dal2.SetUnitOfWork(uow); dal2.Add(cust2); uow.Commit(); } catch (Exception ex) { uow.RollBack(); MessageBox.Show(ex.Message); } }
private void FrmCustomer_Load(object sender, EventArgs e) { DalLayer.Items.Add("ADODal"); DalLayer.Items.Add("EFDal"); DalLayer.SelectedIndex = 0; Idal = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text); ClearCustomer(); LoadGrid(); }
private void DalLayer_SelectedIndexChanged(object sender, EventArgs e) { Idal = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text); LoadGrid(); }