Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public void SendClientDataToDb(int clientId, LbClient clientProfile)
 {
     try
     {
         StoreClientInfo(clientId, clientProfile);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 private void SaveClientData(LbClient clientData)
 {
     try
     {
         dbInterface.SendClientDataToDb(-1, clientData);
         isClientCreated = true;
     }
     catch (Exception exc)
     {
         string errMsg = ExceptionHandler.GetExceptionDetails(exc);
         ShowClientCreationError(errMsg);
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }