Beispiel #1
0
        public List <SelectContactModel> GetContactsOfPartyForSelection(int partyID)
        {
            List <SelectContactModel> contacts = new List <SelectContactModel>();

            try
            {
                ServiceMASTERS _serice = new ServiceMASTERS(_dbContext);

                List <Tbl_MP_Master_PartyContact_Detail> dbList = _dbContext.Tbl_MP_Master_PartyContact_Detail.Where(xx => xx.FK_PartyID == (int?)partyID).ToList();
                foreach (Tbl_MP_Master_PartyContact_Detail item in dbList)
                {
                    SelectContactModel model = new SelectContactModel();
                    model.Selected  = false;
                    model.ContactID = item.PK_PartyContactDetails;

                    model.Description1 = string.Format("{0}   {1}\n{2}", item.ContactPersoneName, item.EmailID, item.Address);
                    model.Description2 = string.Empty;
                    if (item.TelephoneNo.Trim() != string.Empty)
                    {
                        model.Description2 += string.Format("Phone: {0} {1}\n", item.TelephoneNo, item.AltTelephoneNo);
                    }
                    if (item.MobileNo.Trim() != string.Empty)
                    {
                        model.Description2 += string.Format("Mobile: {0} {1}\n", item.MobileNo, item.AltMobileNo);
                    }
                    if (item.FaxNo.Trim() != string.Empty)
                    {
                        model.Description2 += string.Format("FAX: {0}", item.FaxNo);
                    }


                    contacts.Add(model);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceContacts::GetContactsOfPartyForSelection", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(contacts);
        }
Beispiel #2
0
        public void ScatterData()
        {
            try
            {
                model = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.SelectedLeadID);
                if (model != null)
                {
                    txtLeadNumber.Text = model.LeadNo;
                    dtLeadDate.Value   = model.LeadDate;

                    txtLeadRequirements.Text   = model.LeadRequirement;
                    txtGeneratedBy.Text        = ServiceEmployee.GetEmployeeNameByID((int)model.FK_LeadGeneratedBy);
                    cboAssignedTo.SelectedItem = ((List <SelectListItem>)cboAssignedTo.DataSource).Where(x => x.ID == model.FK_LeadAssignTo).FirstOrDefault();

                    cboSalesLeadStatus.SelectedItem = ((List <SelectListItem>)cboSalesLeadStatus.DataSource).Where(x => x.ID == model.FK_Status).FirstOrDefault();
                    if (model.FK_Status == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadStatusClose].DEFAULT_VALUE)
                    {
                        txtReasonLost.Text             = model.ReasonClose;
                        tabPageLeadCloseReason.Visible = true;
                    }

                    cboCompanies.SelectedItem = ((List <SelectListItem>)cboCompanies.DataSource).Where(x => x.ID == model.FK_PartyID).FirstOrDefault();
                    //scatter lead contacts
                    this.SelectedPartyID = ((SelectListItem)cboCompanies.SelectedItem).ID;
                    PopulateContactsGrid();
                    List <SelectContactModel> lstContacts = _UNIT.SalesLeadService.GetContactsForLeadID(this.SelectedLeadID);
                    if (lstContacts != null)
                    {
                        foreach (SelectContactModel contact in (List <SelectContactModel>)gridContacts.DataSource)
                        {
                            SelectContactModel found = lstContacts.Where(x => x.ContactID == contact.ContactID).FirstOrDefault();
                            if (found != null)
                            {
                                contact.Selected = true;
                            }
                        }
                    }

                    cboLeadSources.SelectedItem = ((List <SelectListItem>)cboLeadSources.DataSource).Where(x => x.ID == model.FK_LeadSource).FirstOrDefault();
                    if (model.FK_LeadSource == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
                    {
                        cboAgencies.SelectedItem = ((List <SelectListItem>)cboAgencies.DataSource).Where(x => x.ID == model.FK_AgentID).FirstOrDefault();
                        cboAgencies.Enabled      = btnAddAgency.Enabled = true;
                    }
                    else
                    {
                        cboAgencies.Enabled = btnAddAgency.Enabled = false;
                    }

                    if (model.EstimatedValue != null)
                    {
                        txtEstimatedValue.Text   = string.Format("{0:0.00}", model.EstimatedValue);
                        cboCurrency.SelectedItem = ((List <SelectListItem>)cboCurrency.DataSource).Where(x => x.ID == model.FK_EstimatedCurrency).FirstOrDefault();
                    }
                    else
                    {
                        txtEstimatedValue.Text = string.Empty;
                    }

                    cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == model.FK_ProjectType).FirstOrDefault();

                    txtLeadRequirements.Text = model.LeadRequirement;
                }
                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "frmSalesLead::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }