private LibraryProxy(DBFactoryEnums factoryEnums) { ILibraryFactory libraryFactory; switch (factoryEnums) { case DBFactoryEnums.MsAccess: libraryFactory = new Ms_Access.LibraryFactory(); break; case DBFactoryEnums.MsAccessPassword: libraryFactory = new MsAccessPassword.LibraryFactory(); break; case DBFactoryEnums.MDBPassword: libraryFactory = new MDBPassword.LibraryFactory(); break; case DBFactoryEnums.MySql: libraryFactory = new MySql.LibraryFactory(); break; case DBFactoryEnums.MsSQLServerExpress: libraryFactory = new MsSQLServerExpress.LibraryFactory(); break; default: throw new NotImplementedException(); } AccountMehod = libraryFactory.CreateAccount(); BookMethod = libraryFactory.CreateBook(); BorrowMehod = libraryFactory.CreateBorrow(); }
private void btnGuest_Click(object sender, EventArgs e) { DBFactoryEnums db = (DBFactoryEnums)cboDbOption.SelectedIndex + 1; LibraryProxy library = LibraryProxy.GetInstance(db); library.GuestAccount(); GoToMain(); }
public static LibraryProxy GetInstance(DBFactoryEnums db) { if (libraryProxy == null || DbFactory != db) { DbFactory = db; libraryProxy = new LibraryProxy(db); } return(libraryProxy); }
private void btnLogIn_Click(object sender, EventArgs e) { DBFactoryEnums db = (DBFactoryEnums)cboDbOption.SelectedIndex + 1; LibraryProxy library = LibraryProxy.GetInstance(db); if (!library.Login(txtUsername.Text.Trim(), txtPassword.Text)) { MessageBox.Show("Please Insert Username and Password"); } if (library.account.AccountLevel >= AccountLevelEnums.Patron) { MessageBox.Show("Login success."); GoToMain(); } }