private void StoreClientInfo(int clientId, LbClient clientProfile) { using (var context = new LBDataEntities()) { context.Connection.Open(); var query = context.tblClients.Where(x => x.ClientId == clientId); if (!query.Any()) { var entry = new tblClient(); entry.ClientName = clientProfile.ClientName; entry.ContactName = clientProfile.ContactName; entry.ContactEmail = clientProfile.ContactEmail; entry.ContactPhoneNumber = clientProfile.ContactPhoneNumber; entry.AccountOpenDate = clientProfile.AccountOpened; context.tblClients.AddObject(entry); } else { var entry = query.First(); entry.ClientName = clientProfile.ClientName; entry.ContactName = clientProfile.ContactName; entry.ContactEmail = clientProfile.ContactEmail; entry.ContactPhoneNumber = clientProfile.ContactPhoneNumber; entry.AccountOpenDate = clientProfile.AccountOpened; } context.SaveChanges(); } }
public void SendClientDataToDb(int clientId, LbClient clientProfile) { try { StoreClientInfo(clientId, clientProfile); } catch (Exception) { throw; } }
private LbClient RetrieveClientDataFromDisplay() { if (String.IsNullOrEmpty(this.tbClientNameFull.Text)) { return(null); } LbClient clientData = new LbClient(this.tbClientNameFull.Text, this.dtpAccountOpened.Value.Date, this.tbClientMainContact.Text, this.tbClientEmailContact.Text, this.tbClientContactNumber.Text); return(clientData); }
private void SaveClientData(int clientId, LbClient clientData) { try { dbInterface.SendClientDataToDb(clientId, clientData); } catch (Exception exc) { string errMsg = ExceptionHandler.GetExceptionDetails(exc); MessageBox.Show(dbInterface.ErrorMessage, "DB Storage Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SaveClientData(LbClient clientData) { try { dbInterface.SendClientDataToDb(-1, clientData); isClientCreated = true; } catch (Exception exc) { string errMsg = ExceptionHandler.GetExceptionDetails(exc); ShowClientCreationError(errMsg); } }
private void btnSaveClientDetails_Click(object sender, EventArgs e) { // TBD: Save any changes made to the client details to the DB. LbClient clientDataUpdated = RetrieveClientDataFromDisplay(); int clientId = Convert.ToInt32(this.nudClientId.Value); if (clientDataUpdated == null) { return; } SaveClientData(clientId, clientDataUpdated); }
private void UpdateClientDataDisplay(int clientId) { if (clientId < 0) { ResetViewerDisplay(); return; } LbClient clientData = dbInterface.GetClientProfile(clientId); this.nudClientId.Value = clientId; this.tbClientNameFull.Text = clientData.ClientName; this.tbClientMainContact.Text = clientData.ContactName; this.tbClientEmailContact.Text = clientData.ContactEmail; this.tbClientContactNumber.Text = clientData.ContactPhoneNumber; this.dtpAccountOpened.Value = clientData.AccountOpened; }
private void CreateNewClient(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.tbClientNameFull.Text)) { DisplayMessageBox("Client's name must be populated"); return; } LbClient clientDataNew = GetClientInfo(); SaveClientData(clientDataNew); if (!isClientCreated) { return; } ShowClientCreationSuccess(); ResetDisplay(); }
private LbClient QueryClientProfile(int clientId) { LbClient clientProfile = new LbClient(String.Empty, DateTime.Now); using (var context = new LBDataEntities()) { context.Connection.Open(); var query = context.tblClients.Where(x => x.ClientId == clientId); if (query != null && query.Any()) { var entry = query.First(); clientProfile.ClientName = entry.ClientName; clientProfile.ContactName = entry.ContactName; clientProfile.ContactEmail = entry.ContactEmail; clientProfile.ContactPhoneNumber = entry.ContactPhoneNumber; if (entry.AccountOpenDate.HasValue) { clientProfile.AccountOpened = entry.AccountOpenDate.Value; } } } return(clientProfile); }
private LbClient GetClientInfo() { LbClient clientDataNew = new LbClient(this.tbClientNameFull.Text, this.dtpAccountOpened.Value.Date, this.tbClientMainContact.Text, this.tbClientEmailContact.Text, this.tbClientContactNumber.Text); return(clientDataNew); }