示例#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();
            }
        }
示例#2
0
 public void SendClientDataToDb(int clientId, LbClient clientProfile)
 {
     try
     {
         StoreClientInfo(clientId, clientProfile);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#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);
        }
示例#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);
     }
 }
示例#5
0
 private void SaveClientData(LbClient clientData)
 {
     try
     {
         dbInterface.SendClientDataToDb(-1, clientData);
         isClientCreated = true;
     }
     catch (Exception exc)
     {
         string errMsg = ExceptionHandler.GetExceptionDetails(exc);
         ShowClientCreationError(errMsg);
     }
 }
示例#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);
        }
示例#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;
        }
示例#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();
        }
示例#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);
        }
示例#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);
        }