public static AccountConsole TblToData(tbl_ContactDB tblContactDB) { if (tblContactDB == null) return null; AccountConsole console = new AccountConsole(); try { console.AccountID = tblContactDB.AccountID; console.FirstName = tblContactDB.FirstName; console.MiddleName = tblContactDB.MiddleName; console.LastName = tblContactDB.LastName; console.Address = tblContactDB.Address; console.City = tblContactDB.City; console.Province = tblContactDB.Province; console.ZipCode = (int)tblContactDB.ZipCode; console.TelephoneNumber = (int)tblContactDB.TelephoneNumber; console.MobileNumber = (int)tblContactDB.MobileNumber; console.Email = tblContactDB.Email; console.TimeSubmitted = (DateTime)tblContactDB.TimeSubmitted; } catch (Exception) { throw; } return console; }
public tbl_ContactDB CreateAccount(string FirstName, string MiddleName, string LastName, string Address, string City, string Province, int ZipCode, int TelephoneNumber, int MobileNumber, string Email) { AccountConsole account = new AccountConsole(); try { if (String.IsNullOrEmpty(FirstName)) throw new ApplicationException("First Name is Empty."); else if (String.IsNullOrEmpty(MiddleName)) throw new ApplicationException("Middle Name is Empty."); else if (String.IsNullOrEmpty(LastName)) throw new ApplicationException("Last Name is Empty."); else if (String.IsNullOrEmpty(Address)) throw new ApplicationException("Address is Empty."); else if (String.IsNullOrEmpty(MobileNumber.ToString())) throw new ApplicationException("Mobile Number is Empty."); else if (String.IsNullOrEmpty(Email)) throw new ApplicationException("Email Address is Empty."); else if (AccountEmailExists(Email)) throw new ApplicationException("Email Address Already Exist."); else if (MobileExist(MobileNumber)) throw new ApplicationException("Mobile Number Already Exist."); else if (NameExist(FirstName, MiddleName, LastName)) throw new ApplicationException("Name Already Exist."); else { tbl_ContactDB consoles = new tbl_ContactDB(); consoles.AccountID=(String.Format("{0:000}",generateID())); consoles.FirstName = FirstName; consoles.MiddleName = MiddleName; consoles.LastName = LastName; consoles.Address = Address; consoles.City = City; consoles.Province = Province; consoles.ZipCode = ZipCode; consoles.TelephoneNumber = TelephoneNumber; consoles.MobileNumber = MobileNumber; consoles.Email = Email; consoles.TimeSubmitted = DateTime.Now; db.tbl_ContactDBs.InsertOnSubmit(consoles); Update(); return consoles; } } catch (Exception) { throw; } }
public tbl_ContactDB DeleteAccount(string AccountID) { tbl_ContactDB account = new tbl_ContactDB(); try { account = db.tbl_ContactDBs.FirstOrDefault(c => c.AccountID.Equals(AccountID)); if (account != null) { db.tbl_ContactDBs.DeleteOnSubmit(account); Update(); } else return null; } catch { } return account; }
public tbl_ContactDB UpdateAccount(string AccountID, string FirstName, string MiddleName, string LastName, string Address, string City, string Province, int ZipCode, int TelephoneNumber, int MobileNumber, string Email) { tbl_ContactDB account = new tbl_ContactDB(); try { account = db.tbl_ContactDBs.FirstOrDefault(a => a.AccountID.Equals(AccountID)); if (account != null) { account.FirstName = FirstName; account.MiddleName = MiddleName; account.LastName=LastName; account.Address=Address; account.City=City; account.Province=Province; account.ZipCode=(int)ZipCode; account.TelephoneNumber=(int)TelephoneNumber; account.MobileNumber = (int)MobileNumber; account.Email = Email; Update(); } else throw new ApplicationException("I can't Find the AccountID."); } catch { } return account; }
public tbl_ContactDB GetUpdate(string AccountID) { tbl_ContactDB listContacts = new tbl_ContactDB(); try { listContacts = (from c in db.tbl_ContactDBs where c.AccountID == AccountID select c).SingleOrDefault(); if (listContacts == null) return null; } catch (Exception) { throw; } return listContacts; }