/// <summary>
        /// This method returns all bank accounts for a particular user
        /// </summary>
        /// <param name="accType">accType</param>
        /// <param name="userID">userID</param>
        /// <returns></returns>
        public List <BankAccountInformation> GetAllBankInfosForUser(LoginAccountType accType, int userID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var bankRepo            = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork);
                    var clientBO            = new ClientBO();
                    var introducingBrokerBO = new IntroducingBrokerBO();

                    ObjectSet <BankAccountInformation> bankAccountInformationObjSet =
                        ((CurrentDeskClientsEntities)bankRepo.Repository.UnitOfWork.Context).BankAccountInformations;

                    //Live
                    if (accType == LoginAccountType.LiveAccount)
                    {
                        var clientInformation = clientBO.GetClientInformation(userID);
                        return(bankAccountInformationObjSet.Where(clnt => clnt.FK_ClientID == clientInformation.PK_ClientID).ToList());
                    }
                    //Partner
                    else
                    {
                        var partnerInformation = introducingBrokerBO.GetClientInformation(userID);
                        return(bankAccountInformationObjSet.Where(part => part.FK_IntroducingBrokerID == partnerInformation.PK_IntroducingBrokerID).ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
예제 #2
0
        public void search(object sender, TextChangedEventArgs e)
        {
            if (searchBox.Text != "" && searchBox.Text.Length > 1)
            {
                string str = searchBox.Text;
                ObservableCollection <ClientBO> clts = new ObservableCollection <ClientBO>(_vm.Clients);
                int len = clts.Count;
                ObservableCollection <ClientBO> clts2 = new ObservableCollection <ClientBO>();

                for (int i = 0; i < len; i++)
                {
                    var item = clts[i];

                    if ((item.ToString().Contains(str)))
                    {
                        ClientBO a = item as ClientBO;
                        clts2.Add(a);
                    }
                }
                lvClients.ItemsSource = clts2;
                lvClients.UpdateLayout();
            }
            else
            {
                lvClients.ItemsSource = _vm.Clients;
                lvClients.UpdateLayout();
            }
            e.Handled = true;
        }
예제 #3
0
        private void btnEditPerson_Click(object sender, RoutedEventArgs e)
        {
            if (lvPersons.SelectedItem != null)
            {
                PersonBO bo = lvPersons.SelectedItem as PersonBO;
                if (bo == null)
                {
                    bo = lvPersons.Items.CurrentItem as PersonBO;
                }

                if (cBoxClients.SelectedItem != null || cBoxPositionTypes.SelectedItem != null)
                {
                    ClientBO cbo = cBoxClients.SelectedItem as ClientBO;
                    add(bo.Id, firstName.Text, lastName.Text, date.SelectedDate, cbo._id, (cBoxPositionTypes.SelectedItem as PositionTypeBO).Id);
                }
                else
                {
                    ClientBO cbo = cBoxClients.SelectionBoxItem as ClientBO;
                    add(bo.Id, firstName.Text, lastName.Text, date.SelectedDate, cbo._id, (cBoxPositionTypes.SelectedItem as PositionTypeBO).Id);
                }
                lvPersons.ItemsSource = _vm.Persons;
                searchBox.Text        = "";
                lvPersons.UpdateLayout();
                e.Handled = true;
            }
        }
예제 #4
0
        protected void RadGridClient_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is ClientBO)
                {
                    ClientBO objClient = (ClientBO)item.DataItem;

                    Literal litDistributor = (Literal)item.FindControl("litDistributor");
                    litDistributor.Text = objClient.objDistributor.Name;

                    Literal litFOCPenalty = (Literal)item.FindControl("litFOCPenalty");
                    litFOCPenalty.Text = objClient.FOCPenalty ? "Yes" : "No";

                    HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                    linkEdit.Attributes.Add("qid", objClient.ID.ToString());
                    linkEdit.Attributes.Add("did", objClient.Distributor.ToString());
                    linkEdit.Attributes.Add("foc", objClient.FOCPenalty ? "Yes" : "No");

                    HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete");
                    linkDelete.Attributes.Add("qid", objClient.ID.ToString());
                    linkDelete.Visible = !(objClient.JobNamesWhereThisIsClient.Any());
                }
            }
        }
예제 #5
0
 private void btnAddPerson_Click(object sender, RoutedEventArgs e)
 {
     if (!(firstName.Text.Equals("") || lastName.Text.Equals("") || date.Text.Equals("") || cBoxClients.Text.Equals("") || cBoxPositionTypes.SelectedItem == null))
     {
         DateTime dt = new DateTime(1900, 1, 1);
         try
         {
             dt = DateTime.Parse(date.SelectedDate.ToString());
         }
         catch
         {
         }
         ClientBO       cbo = cBoxClients.SelectedItem as ClientBO;
         PositionTypeBO pTo = cBoxPositionTypes.SelectedItem as PositionTypeBO;
         PersonBO       bo  = new PersonBO(0, firstName.Text, lastName.Text, dt, cbo._id, pTo.Id);
         if (bo.Age < 16)
         {
             MessageBoxResult result = MessageBox.Show("The age of the person is less than 16, aborting add", "Warning", MessageBoxButton.OK);
             return;
         }
         bo.AddOrUpdate();
         searchBox.Text        = "";
         lvPersons.ItemsSource = _vm.Persons;
         lvPersons.UpdateLayout();
     }
     else
     {
         MessageBoxResult result = MessageBox.Show("Add a valid Date, Name, Lastname, Client", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
예제 #6
0
        public ClientBO GetClient(string id)
        {
            ClientBO client = new ClientBO();

            try { client.PersonalInfo = GetPersonById(id); }
            catch (MissingMemberException ex) { throw ex; }
            client.ClientRequests = GetGuestRequests(x => x.ClientId == id);
            return(client);
        }
예제 #7
0
        public void TestLisClientAsync()
        {
            ApplicationSeeder.Seed();

            var bo = new ClientBO();

            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count > 0);
        }
 private void AddPerson_OpenClientWin(string obj)
 {
     MaterialDesignThemes.Wpf.DialogHost.CloseDialogCommand.Execute(null, null);
     client = bl.GetClient(obj);
     ClientInfo.DataContext = client;
     requests = new ObservableCollection <GuestRequestBO>(client.ClientRequests); // making the list request of the guest
     ListRequest.DataContext = requests;
     clientLogin.Visibility  = Visibility.Collapsed;
     clientWindow.Visibility = Visibility.Visible;
 }
예제 #9
0
 private void lvClients_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lvClients.SelectedItem != null)
     {
         ClientBO a = lvClients.SelectedItem as ClientBO;
         txtName.Text         = a.Name;
         txtBusinessNo.Text   = a.BusinessNo;
         lvOffers.ItemsSource = _vm.GetClientOffers((lvClients.SelectedItem as ClientBO).Id); lvOffers.UpdateLayout();
     }
     e.Handled = true;
 }
예제 #10
0
        /// <summary>
        /// This method validates user during login
        /// </summary>
        /// <param name="userName">userName</param>
        /// <param name="password">password</param>
        /// <param name="userID">userID</param>
        /// <param name="userType">userType</param>
        /// <param name="accountType">accountType</param>
        /// <param name="accountCode">accountCode</param>
        /// <param name="userDisplayName">userDisplayName</param>
        /// <returns></returns>
        public bool ValidateUser(string userName, string password, int organizationID, ref int userID, ref int userType,
                                 ref int accountType, ref int accountCode, ref string userDisplayName)
        {
            var currentDeskSecurity = new CurrentDeskSecurity();

            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userRepo =
                        new UserRepository(new EFRepository <User>(), unitOfWork);

                    ObjectSet <User> userObjSet =
                        ((CurrentDeskClientsEntities)userRepo.Repository.UnitOfWork.Context).Users;

                    //Get The Selected client and check for the
                    //organization and than assign its Properties.
                    var selectedUsers =
                        userObjSet.Where(usr => usr.UserEmailID == userName && usr.FK_OrganizationID == organizationID).FirstOrDefault();

                    if (selectedUsers != null)
                    {
                        if (currentDeskSecurity.GetPassDecrypted(selectedUsers.Password) == password)
                        {
                            userID   = selectedUsers.PK_UserID;
                            userType = (int)selectedUsers.FK_UserTypeID;

                            if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_LIVE)
                            {
                                var clientBO = new ClientBO();
                                return(clientBO.GetClientAccountInformation(selectedUsers.PK_UserID, ref accountType, ref accountCode, ref userDisplayName));
                            }
                            else if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_PARTNER)
                            {
                                var introducingBrokerBO = new IntroducingBrokerBO();
                                return(introducingBrokerBO.GetClientAccountInformation(selectedUsers.PK_UserID, ref accountType, ref accountCode, ref userDisplayName));
                            }
                            else if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_ADMIN)
                            {
                                accountCode = Constants.K_ACCTCODE_SUPERADMIN;
                                return(true);
                            }
                        }
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
예제 #11
0
        public void AddClient(ClientBO client)
        {
            try { AddPerson(client.PersonalInfo); }
            catch (DuplicateKeyException ex) { throw ex; }

            foreach (GuestRequestBO item in client.ClientRequests)
            {
                try { AddRequest(item); }
                catch (DuplicateKeyException duplicateEx) { throw duplicateEx; }
                catch (FormatException formatEx) { throw formatEx; }
            }
        }
예제 #12
0
 private void edit_Click(object sender, RoutedEventArgs e)
 {
     if (lvClients.SelectedItem != null)
     {
         ClientBO bo = lvClients.SelectedItem as ClientBO;
         add(bo.Id, txtName.Text, txtBusinessNo.Text);
         lvClients.ItemsSource = _vm.Clients;
         searchBox.Text        = "";
         lvClients.UpdateLayout();
         e.Handled = true;
     }
 }
예제 #13
0
 private BusinessManager()
 {
     this.montlyClientBO = new ClientBO();
     this.collaboratorBO = new CollaboratorBO();
     this.localManagerBO = new LocalManagerBO();
     this.globalManagerBO = new GlobalManagerBO();
     this.parkingBO = new ParkingBO();
     this.parkingSpaceBO = new ParkingSpaceBO();
     this.priceBO = new PriceBO();
     this.addressBO = new AddressBO();
     this.tagBO = new TagBO();
     this.plateBO = new PlateBO();
     this.usageRecordsBO = new UsageRecordBO();
 }
예제 #14
0
        public void TestCreateAndListClientAsync()
        {
            ApplicationSeeder.Seed();

            var bo        = new ClientBO();
            var foreignBO = new ProfileBO();

            var client = new Client(foreignBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.CreateAsync(client).Result;
            var resGet    = bo.ReadAsync(client.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
예제 #15
0
        public void TestCreateAndListComment()
        {
            ApplicationSeeder.Seed();

            var bo        = new CommentBO();
            var foreignBO = new ClientBO();

            var comment = new Comment("Tou só a testar", foreignBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.Create(comment);
            var resGet    = bo.Read(comment.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
예제 #16
0
        public void TestCreateAndListJobAsync()
        {
            ApplicationSeeder.Seed();

            var bo              = new JobBO();
            var foreignBO       = new ServiceBO();
            var foreignClientBO = new ClientBO();

            var job = new Job("Setúbal N4 1323", DateTime.Now.Date.AddDays(2), DateTime.Now.Date.AddDays(2).AddMinutes(180), 23.99, "Scheduled", 0, false, foreignBO.ListUndeleted().Result.First().Id, foreignClientBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.CreateAsync(job).Result;
            var resGet    = bo.ReadAsync(job.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
예제 #17
0
        public void TestDeleteClientAsync()
        {
            ApplicationSeeder.Seed();

            var bo = new ClientBO();

            var resList = bo.ListAsync().Result;
            var total   = resList.Result.Count;

            var resDelete = bo.Delete(resList.Result.First().Id);

            var list = bo.ListUndeletedAsync().Result;

            Assert.IsTrue(resDelete.Success && resList.Success && list.Result.Count == (total - 1));
        }
예제 #18
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            {
                int companyId = int.Parse(hdnSelectedCompanyID.Value.Trim());

                if (companyId > 0)
                {
                    try
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            CompanyBO objCompany = new CompanyBO(this.ObjContext);
                            objCompany.ID = companyId;
                            objCompany.GetObject();

                            List <UserBO> lstUsers = objCompany.UsersWhereThisIsCompany;
                            foreach (UserBO user in lstUsers)
                            {
                                UserBO objUser = new UserBO(this.ObjContext);
                                objUser.ID = user.ID;
                                objUser.GetObject();
                                objUser.Delete();
                            }

                            List <ClientBO> lstClient = objCompany.ClientsWhereThisIsDistributor;
                            foreach (ClientBO client in lstClient)
                            {
                                ClientBO objClient = new ClientBO(this.ObjContext);
                                objClient.ID = client.ID;
                                objClient.GetAllObject();
                                objClient.Delete();
                            }


                            objCompany.Delete();

                            this.ObjContext.SaveChanges();
                            ts.Complete();
                            this.PopulateDataGrid();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
예제 #19
0
        public static ObservableCollection <ClientBO> GetAllClients()
        {
            List <ClientBO> clts    = new List <ClientBO>();
            var             clients = new List <Client>();

            using (ElibriumEntities db = new ElibriumEntities())
            {
                if (db.Client.Count() > 0)
                {
                    clients = db.Client.ToList();
                    foreach (var client in clients)
                    {
                        ClientBO clt = new ClientBO(client);
                        clts.Add(clt);
                    }
                }
            }
            return(new ObservableCollection <ClientBO>(clts));
        }
예제 #20
0
        public void TestUpdateClientAsync()
        {
            ApplicationSeeder.Seed();

            var bo        = new ClientBO();
            var foreignBO = new ProfileBO();

            var resList = bo.ListAsync().Result;

            var item = resList.Result.FirstOrDefault();

            item.ProfileId = foreignBO.ListUndeleted().Result.Last().Id;

            var resUpdate = bo.UpdateAsync(item).Result;

            var list = bo.ListUndeletedAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().ProfileId == foreignBO.ListUndeleted().Result.Last().Id);
        }
예제 #21
0
        private void ProcessForm(int clientID, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    ClientBO objClient = new ClientBO(this.ObjContext);

                    if (clientID > 0)
                    {
                        objClient.ID = clientID;
                        objClient.GetObject();

                        objClient.Distributor = int.Parse(ddlDistributor.SelectedValue);
                        objClient.Name        = this.txtClientName.Text;
                        objClient.Description = this.txtDescription.Text;
                        objClient.FOCPenalty  = (this.chkFocPenalty.Checked) ? true : false;

                        if (isDelete)
                        {
                            objClient.Delete();
                        }
                    }
                    else
                    {
                        objClient.Distributor = int.Parse(ddlDistributor.SelectedValue);
                        objClient.Name        = this.txtClientName.Text;
                        objClient.Description = this.txtDescription.Text;
                        objClient.FOCPenalty  = this.chkFocPenalty.Checked;
                        objClient.Add();
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
        }
        private void LogIn_But(object sender, RoutedEventArgs e)
        {
            PersonBO temp = null;

            try
            {
                temp = bl.GetPersonByMail(UserMail.Text);
                if (Password.Password == temp.Password)
                {
                    client = bl.GetClient(temp.Id);
                    ClientInfo.DataContext = client;
                    requests = new ObservableCollection <GuestRequestBO>(client.ClientRequests); // making the list request of the guest
                    ListRequest.DataContext = requests;
                    clientLogin.Visibility  = Visibility.Collapsed;
                    clientWindow.Visibility = Visibility.Visible;
                }
                ErorrInput.Visibility = Visibility.Visible;
            }
            catch (MissingMemberException ex)
            {
                ErorrInput.Visibility = Visibility.Visible;
            }
        }
예제 #23
0
        /// <summary>
        /// This method returns all clients of broker with name and account number
        /// </summary>
        /// <param name="organizationID">organizationID</param>
        /// <param name="accountNumberPosition">accountNumberPosition</param>
        /// <returns></returns>
        public List <BrokerClients> GetAllClientsOfBroker(int organizationID, int accountNumberPosition)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    List <BrokerClients> lstAllClients       = new List <BrokerClients>();
                    ClientBO             clientBO            = new ClientBO();
                    IntroducingBrokerBO  introducingBrokerBO = new IntroducingBrokerBO();

                    var userRepo =
                        new UserRepository(new EFRepository <User>(), unitOfWork);

                    ObjectSet <User> userObjSet =
                        ((CurrentDeskClientsEntities)userRepo.Repository.UnitOfWork.Context).Users;

                    //Get all live and partner clients
                    var allClients = userObjSet.Where(usr => usr.FK_OrganizationID == organizationID && (usr.FK_UserTypeID == Constants.K_BROKER_LIVE || usr.FK_UserTypeID == Constants.K_BROKER_PARTNER)).ToList();

                    //Get live and partner clients names with a/c numbers
                    var liveClients    = clientBO.GetClientNames(allClients, accountNumberPosition);
                    var partnerClients = introducingBrokerBO.GetPartnerNames(allClients, accountNumberPosition);

                    //Merger both and add to list
                    lstAllClients.AddRange(liveClients);
                    lstAllClients.AddRange(partnerClients);

                    //Return list of clients
                    return(lstAllClients);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This method adds new bank account for Live user
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="bankAccountInformation">bankAccountInformation</param>
        /// <returns></returns>
        public bool AddNewLiveBankAccountInformation(int userID, BankAccountInformation bankAccountInformation)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var bankRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork);
                    var clientBO = new ClientBO();

                    var clientInformation = clientBO.GetClientInformation(userID);
                    bankAccountInformation.FK_ClientID = clientInformation.PK_ClientID;

                    bankRepo.Add(bankAccountInformation);
                    bankRepo.Save();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
예제 #25
0
        private void PopulateDataGrid()
        {
            {
                // Hide Controls
                this.dvEmptyContent.Visible   = false;
                this.dvDataContent.Visible    = false;
                this.dvNoSearchResult.Visible = false;

                // Search text
                string searchText = this.txtSearch.Text.ToLower().Trim();

                // Populate Items
                ClientBO objClient = new ClientBO();

                if (LoggedUser.IsDirectSalesPerson)
                {
                    objClient.Distributor = this.Distributor.ID;
                }
                else if (LoggedUserRoleName == UserRole.DistributorAdministrator || LoggedUserRoleName == UserRole.DistributorCoordinator)
                {
                    objClient.Distributor = this.LoggedCompany.ID;
                }

                List <ClientBO> lstClients;
                if ((searchText != string.Empty) && (searchText != "search"))
                {
                    lstClients = (from o in objClient.SearchObjects().ToList()
                                  where o.Name.ToLower().Contains(searchText) ||
                                  (o.Description != null ? o.Description.ToLower().Contains(searchText) : false)
                                  select o).ToList();
                }
                else
                {
                    lstClients = objClient.SearchObjects().ToList();
                }

                if (lstClients.Count > 0)
                {
                    this.RadGridClient.AllowPaging = (lstClients.Count > this.RadGridClient.PageSize);
                    this.RadGridClient.DataSource  = lstClients;
                    this.RadGridClient.DataBind();
                    Session["ClientDetails"] = lstClients;

                    this.dvDataContent.Visible = true;
                }
                else if ((searchText != string.Empty && searchText != "search"))
                {
                    this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                    this.dvDataContent.Visible    = true;
                    this.dvNoSearchResult.Visible = true;
                }
                else
                {
                    this.dvEmptyContent.Visible = true;
                    this.btnAddClient.Visible   = false;
                }

                this.RadGridClient.Visible = (lstClients.Count > 0);
            }
        }
예제 #26
0
        private void add(int id, string firstName, string lastName)
        {
            ClientBO bo = new ClientBO(id, firstName, lastName);

            bo.AddOrUpdate();
        }
예제 #27
0
 public ClientsController(ClientBO bo)
 {
     _bo = bo;
 }
예제 #28
0
        /// <summary>
        /// Populate the controls.
        /// </summary>
        private void PopulateControls()
        {
            ViewState["isPopulate"] = false;
            //Header Text
            this.litHeaderText.Text = ((this.QueryID > 0) ? "Edit " : "New ") + this.ActivePage.Heading;

            // Popup Header Text
            this.lblPopupHeaderText.Text = "New Client Type";

            // Populate IsDestributors
            //this.ddlCompany.Items.Add(new ListItem("Select Distributor", "0"));
            //CompanyBO objCompany = new CompanyBO();
            //objCompany.IsDistributor = true;

            //List<CompanyBO> lstCompany = new List<CompanyBO>();
            //lstCompany = (from o in objCompany.SearchObjects().OrderBy(m => m.Name).AsQueryable().ToList<CompanyBO>()
            //              where o.IsDistributor == true
            //              select o).ToList();
            //foreach (CompanyBO company in lstCompany)
            //{
            //    this.ddlCompany.Items.Add(new ListItem(company.Name, company.ID.ToString()));
            //}

            //Populate Clients
            this.ddlClient.Items.Add(new ListItem("Select Client", "0"));

            ClientBO objClient = new ClientBO();

            if (LoggedUser.IsDirectSalesPerson)
            {
                objClient.Distributor = DistributorID;
            }
            else if (LoggedUserRoleName == UserRole.DistributorAdministrator || LoggedUserRoleName == UserRole.DistributorCoordinator)
            {
                objClient.Distributor = LoggedCompany.ID;
            }

            List <ClientBO> lstClient = (from o in objClient.SearchObjects().OrderBy(m => m.Name).AsQueryable().ToList <ClientBO>()
                                         select o).ToList();

            foreach (ClientBO client in lstClient)
            {
                this.ddlClient.Items.Add(new ListItem(client.Name, client.ID.ToString()));
            }

            // Populate CountryBO
            this.ddlCountry.Items.Add(new ListItem("Select Your Country"));
            List <CountryBO> lstCountry = (new CountryBO()).GetAllObject().AsQueryable().OrderBy("ShortName").ToList();

            foreach (CountryBO country in lstCountry)
            {
                this.ddlCountry.Items.Add(new ListItem(country.ShortName, country.ID.ToString()));
            }

            // If QueryId is grater than zero, edit mode.
            if (this.QueryID > 0)
            {
                JobNameBO objJobName = new JobNameBO(this.ObjContext);
                objJobName.ID = this.QueryID;
                objJobName.GetObject();

                this.ddlClient.SelectedValue = objJobName.Client.ToString();
                this.txtName.Text            = objJobName.Name;
                this.txtAddress1.Text        = objJobName.Address;
                this.txtCity.Text            = objJobName.City;
                this.txtState.Text           = objJobName.State;
                this.txtPostalCode.Text      = objJobName.PostalCode;
                if (!string.IsNullOrEmpty(objJobName.Country))
                {
                    this.ddlCountry.Items.FindByText(objJobName.Country).Selected = true; //.SelectedItem.Text = objJobName.Country;
                }
                this.txtPhoneNo1.Text     = objJobName.Phone;
                this.txtEmailAddress.Text = objJobName.Email;
            }
            else
            {
                this.ddlCountry.Items.FindByValue("14").Selected = true;
            }
        }