示例#1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (tbSearchName.Text.Length > 0)
                {
                    appDB.ContactSearchDataTable cdt = fmCurrent.AtMng.ContactSearch(tbSearchName.Text);
                    string filter = "";
                    if (ActiveOnly)
                    {
                        filter = "CurrentEmployee=1 or CurrentEmployee is null";
                    }
                    contactBindingSource.Filter     = filter;
                    contactBindingSource.DataSource = cdt;
                    contactBindingSource.DataMember = "";

                    switch (cbNameList.SelectedValue.ToString())
                    {
                    case "Search":
                        contactGridEX.Focus();
                        break;

                    case "MyAddressBook":
                    case "CurrentFileContacts":
                        fileContactGridEX.Focus();
                        break;

                    case "OwnerOffice":
                    case "LeadOffice":
                    case "MyOffice":
                    case "AllOffices":
                        OwnerGridEx.Focus();
                        break;
                    }
                    this.AcceptButton = null;
                }
            }
            catch (Exception x)
            {
                UIHelper.HandleUIException(x);
            }
        }
示例#2
0
        private void ddListSelectionMade()
        {
            switch (cbNameList.SelectedValue.ToString())
            {
            case "Search":
                IsSearch = true;

                pnlContact.Closed     = false;
                pnlFileContact.Closed = true;
                pnlOwner.Closed       = true;
                pnlLists.Closed       = true;

                contactBindingSource.DataSource = null;
                contactBindingSource.DataMember = "";
                tbSearchName.Focus();
                this.AcceptButton = btnSearch;

                break;

            case "MyAddressBook":
            case "CurrentFileContacts":
                IsSearch = false;

                pnlFileContact.Closed = false;
                pnlContact.Closed     = true;
                pnlOwner.Closed       = true;
                pnlLists.Closed       = true;
                string activeFilter3 = "";
                if (ActiveOnly)
                {
                    activeFilter3 = "Active=1";
                }
                if (PartiesOnly)
                {
                    if (ActiveOnly)
                    {
                        activeFilter3 += " and ";
                    }

                    activeFilter3 += "ContactClass='P'";
                }
                DataView dvFC;
                if (cbNameList.SelectedValue.ToString() == "CurrentFileContacts")
                {
                    //fmCurrent.GetFileContact().LoadByFileId(fmCurrent.CurrentFile.FileId);
                    dvFC = new DataView(fmCurrent.DB.FileContact, activeFilter3, "", DataViewRowState.CurrentRows);
                }
                else     //Address Book
                {
                    FileManager fm = fmCurrent.AtMng.GetFile(fmCurrent.AtMng.WorkingAsOfficer.MyFileId);
                    //fm.GetFileContact().LoadByFileId(fm.CurrentFile.FileId);
                    dvFC = new DataView(fm.DB.FileContact, activeFilter3, "", DataViewRowState.CurrentRows);
                }

                fileContactBindingSource.DataSource = dvFC;
                fileContactBindingSource.DataMember = "";
                fileContactGridEX.SetDataBinding(fileContactBindingSource, null);
                fileContactGridEX.Focus();
                this.AcceptButton = null;

                break;

            case "LawMateDistributionList":
                IsSearch = false;

                pnlFileContact.Closed = true;
                pnlContact.Closed     = true;
                pnlOwner.Closed       = true;
                pnlLists.Closed       = false;

                fmCurrent.AtMng.GetList().Load();

                listBindingSource.DataSource = fmCurrent.AtMng.DB;
                listBindingSource.DataMember = fmCurrent.AtMng.DB.List.TableName;
                listBindingSource.Filter     = "SyncExchange=True";
                listGridEX.SetDataBinding(listBindingSource, null);
                listGridEX.Focus();
                this.AcceptButton = null;
                break;

            case "OwnerOffice":
            case "LeadOffice":
            case "MyOffice":
            case "AllOffices":
                IsSearch = false;

                pnlFileContact.Closed = true;
                pnlContact.Closed     = true;
                pnlOwner.Closed       = false;
                pnlLists.Closed       = true;

                string activeFilter = "", activeFilter1 = "";
                if (ActiveOnly)
                {
                    activeFilter  = "CurrentEmployee=1";
                    activeFilter1 = "CurrentEmployee=1 and ";
                }

                switch (cbNameList.SelectedValue.ToString())
                {
                case "AllOffices":
                    if (!AllOfficesLoaded)
                    {
                        fmCurrent.AtMng.OfficeMng.GetOfficer().Load();
                        dvAllOffices     = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter, "", DataViewRowState.CurrentRows);
                        AllOfficesLoaded = true;
                    }
                    officerBindingSource.DataSource = dvAllOffices;
                    break;

                case "OwnerOffice":
                    if (!OwnerLoaded)
                    {
                        fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.CurrentFile.OwnerOfficeId);
                        dvOwner     = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.CurrentFile.OwnerOfficeId.ToString(), "", DataViewRowState.CurrentRows);
                        OwnerLoaded = true;
                    }
                    officerBindingSource.DataSource = dvOwner;
                    break;

                case "LeadOffice":
                    if (!LeadLoaded)
                    {
                        fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.CurrentFile.LeadOfficeId);
                        dvLead     = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.CurrentFile.LeadOfficeId.ToString(), "", DataViewRowState.CurrentRows);
                        LeadLoaded = true;
                    }
                    officerBindingSource.DataSource = dvLead;
                    break;

                case "MyOffice":
                    if (!MyOfficeLoaded)
                    {
                        fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.AtMng.OfficeLoggedOn.OfficeId);
                        dvMyOffice     = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.AtMng.OfficeLoggedOn.OfficeId.ToString(), "", DataViewRowState.CurrentRows);
                        MyOfficeLoaded = true;
                    }
                    officerBindingSource.DataSource = dvMyOffice;
                    break;
                }
                OwnerGridEx.Focus();
                this.AcceptButton = null;

                break;

            case "Outlook":
                IsSearch = false;
                Redemption.MAPIUtils mapiUtil = DocumentBE.MAPIUtils();
                try
                {
                    Redemption.SafeRecipients recips = mapiUtil.AddressBook(missing, missing, 3, true, missing, missing, missing, missing, missing);
                    if (recips != null)
                    {
                        for (int i = 1; i <= recips.Count; i++)
                        {
                            Redemption.SafeRecipient recip = recips.Item(i);

                            if (recip.Type == 1)
                            {
                                ucRecipientTextBoxTo.Add(recip.AddressEntry.SMTPAddress, recip.Name);
                            }
                            else if (recip.Type == 2)
                            {
                                ucRecipientTextBoxCc.Add(recip.AddressEntry.SMTPAddress, recip.Name);
                            }
                        }
                    }
                }
                catch (Exception x)
                {
                    UIHelper.HandleUIException(x);
                }
                mapiUtil.Cleanup();
                break;
            }

            lblTypeName.Visible  = IsSearch;
            tbSearchName.Visible = IsSearch;
            btnSearch.Visible    = IsSearch;
        }