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; } }