private void Merge3Btn_Click(object sender, RibbonControlEventArgs e) { XLForms.StaffSelectForm staffForm = new XLForms.StaffSelectForm(); staffForm.ShowDialog(); Document currentDoc = XLDocument.GetCurrentDoc(); long startPosition = currentDoc.Content.Start; long endPosition = currentDoc.Content.End; string templateXML = XLDocument.CopyRangeToWordXML(currentDoc.Range()); List <XLMain.FPIClient> clients = XLMain.FPIClient.GetFPIClients(staffForm.selectedStaff.crmID, "where direct_debit = 0 and Last_year = 1"); if (clients.Count > 0) { XLDocument.MergeFPIData(clients.OrderBy(c => c.office).ToList(), templateXML); } else { MessageBox.Show("No clients founds to merge."); } clients = XLMain.FPIClient.GetFPIClients(staffForm.selectedStaff.crmID, "where direct_debit = 0 and Last_year = 1", false); if (clients.Count > 0) { XLDocument.MergeFPIData(clients.OrderBy(c => c.office).ToList(), templateXML); } else { MessageBox.Show("No foreign clients founds to merge."); } }
private void ApproveBtn_Click(object sender, RibbonControlEventArgs e) { try { Microsoft.Office.Interop.Word._Application app = Globals.ThisAddIn.Application; XLDocument.ChangeStatus("Approved"); XLMain.Client client = null; string fileID = XLDocument.GetFileID(); if (String.IsNullOrEmpty(fileID)) { return; } if (XLDocument.ReadParameter("CRMid") != null) { client = XLMain.Client.FetchClient(XLDocument.ReadParameter("CRMid")); } else { //if the document param doesn't exist get the index data from VC client = XLVirtualCabinet.GetClientFromIndex(fileID); } XLMain.Staff writer = new XLMain.Staff(); string writerID = XLDocument.ReadParameter("Sender"); if (writerID == "") { writer = XLMain.Staff.StaffFromUser(Environment.UserName); } else { writer = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender")); } StaffSelectForm myForm = new XLForms.StaffSelectForm(client, writer); myForm.ShowDialog(); XLMain.EntityCouplet staff = myForm.selectedStaff; if (myForm.DialogResult == DialogResult.OK) { if (staff == null) { //make blank if no staff selected staff.name = ""; } string commandfileloc = ""; if (XLDocument.ReadBookmark("Date") == "") { commandfileloc = XLVirtualCabinet.Reindex(fileID, staff.name, XLDocument.ReadParameter("VCStatus")); } else { string docDate = XLDocument.ReadBookmark("Date"); commandfileloc = XLVirtualCabinet.Reindex(fileID, staff.name, XLDocument.ReadParameter("VCStatus"), docDate); } XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true); if (result.ExitCode != 0) { MessageBox.Show("Reindex failed please complete manually"); } else { app.ActiveDocument.Save(); app.ActiveWindow.Close(); } } } catch (Exception ex) { MessageBox.Show("Unable to approve document"); XLtools.LogException("ApproveBtn", ex.ToString()); } }