Beispiel #1
0
        private void LaunchClientDoc(string docType)
        {
            try
            {
                ClientForm myForm = new ClientForm();
                myForm.ShowDialog();
                XLMain.Client selectedClient = myForm.selectedClient;
                if (selectedClient != null)
                {
                    string crmId = selectedClient.crmID;
                    XLDocument.openTemplate(docType);
                    XLDocument.UpdateParameter("CRMid", crmId);
                    XLDocument.UpdateParameter("DocType", docType);

                    //this appears to work in 3.5 notwithstanding the reference to Globals
                    xlTaskPane1              = new XLTaskPane();
                    CustomxlTaskPane         = Globals.ThisAddIn.CustomTaskPanes.Add(xlTaskPane1, "XLant Document Handler", Globals.ThisAddIn.Application.ActiveWindow);
                    CustomxlTaskPane.Visible = true;
                    CustomxlTaskPane.Width   = 350;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to launch document");
                XLtools.LogException("LaunchClientDoc", docType + " - " + e.ToString());
            }
        }
Beispiel #2
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            XLDocument.Header header = new XLDocument.Header();
            string            office = (string)OfficeDDL.SelectedValue;
            string            footer = (string)DeptDDL.SelectedValue;

            header = XLDocument.MapHeaderFooter(office, footer);
            if (header != null)
            {
                XLDocument.DeployHeader(header);
                XLDocument.UpdateParameter("HeaderDeployed", "true");
            }
            this.Close();
        }
        private void SenderDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //Collect the changed record
                XLMain.EntityCouplet tempSend = (XLMain.EntityCouplet)SenderDDL.SelectedItem;
                //Convert the entity couplet to a full blown user now we know which one we want
                if (tempSend.crmID != "")
                {
                    XLMain.Staff send = XLMain.Staff.FetchStaff(tempSend.crmID);
                    DeploySignature(client, send, AddresseeTB.Text);
                    XLDocument.UpdateParameter("Sender", send.username);

                    //Build reference
                    string ourRef = OurRef(client, send, user);
                    XLDocument.UpdateBookmark("OurRef", ourRef, 0);
                }
                else
                {
                    XLMain.Staff send = new XLMain.Staff();
                    send.crmID    = "";
                    send.name     = tempSend.name;
                    send.initials = "";
                    DeploySignature(client, send, AddresseeTB.Text);
                    XLDocument.UpdateParameter("Sender", "");

                    //Build reference
                    string ourRef = OurRef(client, send, user);
                    XLDocument.UpdateBookmark("OurRef", ourRef, 0);

                    //For Milsted Langdon remove for and on behalf
                    if (tempSend.name == "Milsted Langdon LLP")
                    {
                        if (FAOBCheck.Checked)
                        {
                            FAOBCheck.Checked = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to change sender");
                XLtools.LogException("TaskPane-SenderDDL", ex.ToString());
            }
        }
Beispiel #4
0
 private void ClientAddressBtn_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ClientForm myForm = new ClientForm();
         myForm.ShowDialog();
         XLMain.Client client = myForm.selectedClient;
         //Add the name and address at the cursor location
         string str = "";
         if (client.addresses.Count > 0)
         {
             if (client.salutations.Count > 0)
             {
                 str += client.salutations[0].addressee + Environment.NewLine;
                 if (client.name != client.salutations[0].addressee)
                 {
                     str += client.name + Environment.NewLine;
                 }
             }
             else
             {
                 str += client.name + Environment.NewLine;
             }
             str += client.addresses[0].addressBlock;
             XLDocument.InsertText(str);
             //Add any parameters we can for later indexing
             string fileStore = XLVirtualCabinet.FileStore(client.office, client.department);
             XLDocument.UpdateParameter("CRMid", client.crmID);
             XLDocument.UpdateParameter("Cabinet", fileStore);
             XLDocument.UpdateParameter("ClientStr", client.clientcode + " - " + client.name);
             //insert the status text box;
             //XLDocument.AddStatusBox();
             //XLDocument.ChangeStatus("Draft");
         }
         else
         {
             MessageBox.Show(client.name + " does not have an address in the system.");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to client address");
         XLtools.LogException("ClientAddressBtn", ex.ToString());
     }
 }
Beispiel #5
0
        private void button2_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                //get current user
                XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName);
                //Build string and add to document
                string str = user.name + ";";
                str += user.grade + ";";
                str += DateTime.Now.ToString("d MMMM yyyy");
                XLDocument.InsertText(str.Replace(";", Environment.NewLine));

                //insert into document properties with added field
                str += ";" + user.name;
                for (int i = 0; i < 10; i++)
                {
                    string param = "Sign" + i;
                    string s     = XLDocument.ReadParameter(param);
                    if (s == "")
                    {
                        XLDocument.UpdateParameter(param, str);
                        break;
                    }
                    if (i == 10)
                    {
                        MessageBox.Show("Signature fields full");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to add signature");
                XLtools.LogException("AddSignature", ex.ToString());
            }
        }
        public static bool AddSignatureMetaData(XLMain.Staff user, XLMain.Staff sig)
        {
            try
            {
                //Add the meta data
                //Build string and add to document
                string str = user.name + ";";
                str += user.grade + ";";
                str += DateTime.Now.ToString("d MMMM yyyy");
                str += ";" + sig.name;
                //insert into document properties

                for (int i = 0; i < 10; i++)
                {
                    string param = "Sign" + i;
                    string s     = XLDocument.ReadParameter(param);
                    if (String.IsNullOrEmpty(s))
                    {
                        XLDocument.UpdateParameter(param, str);
                        break;
                    }
                    if (i == 10)
                    {
                        MessageBox.Show("Signature fields full");
                        break;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to add signature metadata");
                XLtools.LogException("AddSignature", ex.ToString());
                return(false);
            }
        }
        public XLTaskPane()
        {
            try
            {
                InitializeComponent();
                string str = XLDocument.ReadParameter("CRMid");
                docType = XLDocument.ReadParameter("DocType");

                client = XLMain.Client.FetchClient(str);
                //ClientIDLabel.Text = client.crmID;

                user  = XLMain.Staff.StaffFromUser(Environment.UserName);
                users = XLtools.StaffList(user, client, false, true);

                SenderDDL.DataSource    = users;
                SenderDDL.DisplayMember = "name";
                SenderDDL.ValueMember   = "crmID";
                SenderDDL.SelectedItem  = user;
                sender = user;
                XLDocument.UpdateParameter("Sender", sender.username);

                if (client != null)
                {
                    //set basic client info
                    string clientStr = client.clientcode + " - " + client.name;
                    ClientLbl.Text = clientStr;
                    SubjectTB.Text = client.name;
                    string fileStore = XLVirtualCabinet.FileStore(client.manager.office, client.department);
                    XLDocument.UpdateParameter("Cabinet", fileStore);
                    XLDocument.UpdateParameter("ClientStr", clientStr);

                    //Deal with salutations
                    if (client.salutations != null)
                    {
                        SalDDL.DataSource    = client.salutations;
                        SalDDL.DisplayMember = "Salutation";
                        SalDDL.ValueMember   = "Addressee";
                        sal = (XLMain.Salutation)SalDDL.SelectedItem;
                        if (sal != null)
                        {
                            AddresseeTB.Text  = sal.addressee;
                            SalutationTb.Text = sal.salutation;
                        }
                    }

                    //Add the appropriate header
                    XLDocument.Header clientHeader = XLDocument.MapHeader(client.office, client.department);


                    //Set up depending on whether it is insolvency or not
                    if (client.department == "INS")
                    {
                        //Deal with when calling ddl
                        WhencallingDDL.DataSource    = users;
                        WhencallingDDL.DisplayMember = "name";
                        WhencallingDDL.ValueMember   = "crmID";
                        WhenCallingCheck.Checked     = true;
                        SubjectTB.Text = XLInsol.GetSubject(client.crmID);
                    }
                    else
                    {
                        FAOBCheck.Checked        = true;
                        PandCCheck.Checked       = true;
                        WhenCallingCheck.Checked = false;
                    }

                    //Deal with addresses or fax no as appropriate
                    if (docType == "Letter")
                    {
                        if (client.addresses != null)
                        {
                            allAddresses               = client.addresses;
                            addressesDDL.DataSource    = allAddresses;
                            addressesDDL.DisplayMember = "address1";
                            addressesDDL.ValueMember   = "addressBlock";
                            add = (XLMain.Address)addressesDDL.SelectedItem;
                            if (add != null)
                            {
                                if (client.IsIndividual)
                                {
                                    addTB.Text = add.addressBlock;
                                }
                                else
                                {
                                    addTB.Text = client.name + Environment.NewLine + add.addressBlock;
                                }
                            }
                        }
                        if (clientHeader != null)
                        {
                            try
                            {
                                XLDocument.DeployHeader(clientHeader);
                            }
                            catch
                            {
                                MessageBox.Show("Unable to map header automatically." + Environment.NewLine + "Please run the Header/Footer menu.");
                            }
                        }
                    }
                    else if (docType == "Fax")
                    {
                        XLMain.Number fax = XLMain.Number.GetNumber(client.crmID, "Fax");
                        if (fax != null)
                        {
                            FaxTB.Text = fax.number;
                        }
                        if (clientHeader != null)
                        {
                            try
                            {
                                XLDocument.DeployHeader(clientHeader);
                            }
                            catch
                            {
                                MessageBox.Show("Unable to map header automatically." + Environment.NewLine + "Please run the Header/Footer menu.");
                            }
                        }
                    }

                    //set status
                    XLDocument.ChangeStatus("Draft");

                    //Alter fields dependant on doc type;
                    SetVisibility(docType);

                    if (client.department == "INS")
                    {
                        WhencallingDDL.Visible = true;
                        IPSContactBtn.Visible  = true;
                    }

                    //Update bookmarks dependant on doc type
                    UpdateBookmarks(docType);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open taskpane");
                XLtools.LogException("TaskPane", ex.ToString());
            }
        }