1068 lines
49 KiB
C#
1068 lines
49 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using GZTW.AyaNova.BLL;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.Text;
|
|
using Infragistics.Win.UltraWinGrid;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace AyaNova.PlugIn.QBI
|
|
{
|
|
/// <summary>
|
|
/// Summary description for MainForm.
|
|
/// </summary>
|
|
public class MainForm : System.Windows.Forms.Form
|
|
{
|
|
private Infragistics.Win.UltraWinStatusBar.UltraStatusBar statusBar;
|
|
private System.Windows.Forms.Panel MainForm_Fill_Panel;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MainForm_Toolbars_Dock_Area_Left;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MainForm_Toolbars_Dock_Area_Right;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MainForm_Toolbars_Dock_Area_Top;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MainForm_Toolbars_Dock_Area_Bottom;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
|
|
private Infragistics.Win.UltraWinGrid.UltraGrid grid;
|
|
private System.Data.DataSet dsInvoices;
|
|
private System.Data.DataTable Invoices;
|
|
private System.Data.DataColumn Client;
|
|
private System.Data.DataColumn WorkingID;
|
|
private System.Data.DataColumn Linked;
|
|
private System.Data.DataColumn ClientID;
|
|
private System.Data.DataTable Workorders;
|
|
private System.Data.DataColumn InvoiceWorkingID;
|
|
private System.Data.DataColumn WorkorderID;
|
|
private System.Data.DataColumn wostatus;
|
|
private System.Data.DataColumn ServiceNumber;
|
|
private System.Data.DataColumn ServiceDate;
|
|
private System.Data.DataColumn Project;
|
|
private System.Data.DataColumn StatusARGB;
|
|
private Infragistics.Win.Misc.UltraLabel lblStatus;
|
|
private System.Data.DataColumn dataColumn1;
|
|
private System.ComponentModel.IContainer components;
|
|
|
|
public MainForm()
|
|
{
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
|
|
//
|
|
// TODO: Add any constructor code after InitializeComponent call
|
|
//
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up any resources being used.
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if (components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
base.Dispose( disposing );
|
|
}
|
|
|
|
#region Windows Form Designer generated code
|
|
/// <summary>
|
|
/// Required method for Designer support - do not modify
|
|
/// the contents of this method with the code editor.
|
|
/// </summary>
|
|
private void InitializeComponent()
|
|
{
|
|
this.components = new System.ComponentModel.Container();
|
|
Infragistics.Win.UltraWinStatusBar.UltraStatusPanel ultraStatusPanel1 = new Infragistics.Win.UltraWinStatusBar.UltraStatusPanel();
|
|
Infragistics.Win.UltraWinStatusBar.UltraStatusPanel ultraStatusPanel2 = new Infragistics.Win.UltraWinStatusBar.UltraStatusPanel();
|
|
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("QBI");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Invoices");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Tools");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool3 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Help");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Exit");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Exit");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool4 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Tools");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Preferences");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Map and import");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceText");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool23 = new Infragistics.Win.UltraWinToolbars.ButtonTool("QBREFRESH");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Preferences");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool5 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Help");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool7 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Contents");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool8 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Technical support");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool10 = new Infragistics.Win.UltraWinToolbars.ButtonTool("About");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool11 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Contents");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool12 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Technical support");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool14 = new Infragistics.Win.UltraWinToolbars.ButtonTool("About");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool15 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Map and import");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool6 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Invoices");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool7 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Invoice");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool17 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Fix problems");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool21 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Refresh invoices");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool18 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Fix problems");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool19 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceConsolidatedWorkorders");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool20 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceText");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool22 = new Infragistics.Win.UltraWinToolbars.ButtonTool("QBREFRESH");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool24 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Refresh invoices");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool26 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceOnePerWO");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool8 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("Invoice");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool29 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceConsolidatedWorkorders");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool31 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceOnePerWO");
|
|
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance13 = new Infragistics.Win.Appearance();
|
|
this.statusBar = new Infragistics.Win.UltraWinStatusBar.UltraStatusBar();
|
|
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
|
|
this.grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
|
|
this.MainForm_Fill_Panel = new System.Windows.Forms.Panel();
|
|
this.lblStatus = new Infragistics.Win.Misc.UltraLabel();
|
|
this._MainForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MainForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MainForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MainForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this.dsInvoices = new System.Data.DataSet();
|
|
this.Invoices = new System.Data.DataTable();
|
|
this.Client = new System.Data.DataColumn();
|
|
this.WorkingID = new System.Data.DataColumn();
|
|
this.Linked = new System.Data.DataColumn();
|
|
this.ClientID = new System.Data.DataColumn();
|
|
this.Workorders = new System.Data.DataTable();
|
|
this.InvoiceWorkingID = new System.Data.DataColumn();
|
|
this.WorkorderID = new System.Data.DataColumn();
|
|
this.wostatus = new System.Data.DataColumn();
|
|
this.ServiceNumber = new System.Data.DataColumn();
|
|
this.ServiceDate = new System.Data.DataColumn();
|
|
this.Project = new System.Data.DataColumn();
|
|
this.StatusARGB = new System.Data.DataColumn();
|
|
this.dataColumn1 = new System.Data.DataColumn();
|
|
((System.ComponentModel.ISupportInitialize)(this.statusBar)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit();
|
|
this.MainForm_Fill_Panel.SuspendLayout();
|
|
((System.ComponentModel.ISupportInitialize)(this.dsInvoices)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.Invoices)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.Workorders)).BeginInit();
|
|
this.SuspendLayout();
|
|
//
|
|
// statusBar
|
|
//
|
|
this.statusBar.BorderStyle = Infragistics.Win.UIElementBorderStyle.None;
|
|
this.statusBar.BorderStylePanel = Infragistics.Win.UIElementBorderStyle.Inset;
|
|
this.statusBar.Location = new System.Drawing.Point(0, 535);
|
|
this.statusBar.Name = "statusBar";
|
|
ultraStatusPanel1.SizingMode = Infragistics.Win.UltraWinStatusBar.PanelSizingMode.Spring;
|
|
ultraStatusPanel2.SizingMode = Infragistics.Win.UltraWinStatusBar.PanelSizingMode.Spring;
|
|
this.statusBar.Panels.AddRange(new Infragistics.Win.UltraWinStatusBar.UltraStatusPanel[] {
|
|
ultraStatusPanel1,
|
|
ultraStatusPanel2});
|
|
this.statusBar.Size = new System.Drawing.Size(605, 19);
|
|
this.statusBar.TabIndex = 6;
|
|
//
|
|
// tbManager
|
|
//
|
|
this.tbManager.DesignerFlags = 1;
|
|
this.tbManager.DockWithinContainer = this;
|
|
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
|
|
this.tbManager.ShowFullMenusDelay = 500;
|
|
ultraToolbar1.DockedColumn = 0;
|
|
ultraToolbar1.DockedRow = 0;
|
|
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
popupMenuTool1,
|
|
popupMenuTool2,
|
|
popupMenuTool3,
|
|
buttonTool1});
|
|
ultraToolbar1.Settings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
|
|
ultraToolbar1.Settings.AllowDockBottom = Infragistics.Win.DefaultableBoolean.True;
|
|
ultraToolbar1.Settings.AllowDockLeft = Infragistics.Win.DefaultableBoolean.True;
|
|
ultraToolbar1.Settings.AllowDockRight = Infragistics.Win.DefaultableBoolean.True;
|
|
ultraToolbar1.Settings.AllowDockTop = Infragistics.Win.DefaultableBoolean.True;
|
|
ultraToolbar1.Settings.AllowFloating = Infragistics.Win.DefaultableBoolean.True;
|
|
ultraToolbar1.Settings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
|
|
ultraToolbar1.Text = "QBI";
|
|
this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
|
|
ultraToolbar1});
|
|
buttonTool2.SharedPropsInternal.Caption = "E&xit";
|
|
buttonTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
|
popupMenuTool4.SharedPropsInternal.Caption = "&Tools";
|
|
popupMenuTool4.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
|
popupMenuTool4.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool3,
|
|
buttonTool4,
|
|
buttonTool5,
|
|
buttonTool23});
|
|
buttonTool6.SharedPropsInternal.Caption = "&Preferences";
|
|
popupMenuTool5.SharedPropsInternal.Caption = "&Help";
|
|
popupMenuTool5.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
|
popupMenuTool5.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool7,
|
|
buttonTool8,
|
|
buttonTool10});
|
|
buttonTool11.SharedPropsInternal.Caption = "&Online manual";
|
|
buttonTool11.SharedPropsInternal.Shortcut = System.Windows.Forms.Shortcut.F1;
|
|
buttonTool12.SharedPropsInternal.Caption = "Technical &support";
|
|
buttonTool14.SharedPropsInternal.Caption = "&About";
|
|
buttonTool15.SharedPropsInternal.Caption = "&Map and import";
|
|
popupMenuTool6.SharedPropsInternal.Caption = "Invoices";
|
|
popupMenuTool6.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
popupMenuTool7,
|
|
buttonTool17,
|
|
buttonTool21});
|
|
buttonTool18.SharedPropsInternal.Caption = "&Fix problems";
|
|
buttonTool19.SharedPropsInternal.Caption = "&Multiple workorders per invoice";
|
|
buttonTool20.SharedPropsInternal.Caption = "&Invoice descriptive text template";
|
|
buttonTool22.SharedPropsInternal.Caption = "Refresh QuickBooks connection";
|
|
buttonTool22.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
|
buttonTool24.SharedPropsInternal.Caption = "&Refresh invoices";
|
|
buttonTool26.SharedPropsInternal.Caption = "&One workorder per invoice";
|
|
popupMenuTool8.SharedPropsInternal.Caption = "&Invoice selected items to QuickBooks...";
|
|
popupMenuTool8.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool29,
|
|
buttonTool31});
|
|
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool2,
|
|
popupMenuTool4,
|
|
buttonTool6,
|
|
popupMenuTool5,
|
|
buttonTool11,
|
|
buttonTool12,
|
|
buttonTool14,
|
|
buttonTool15,
|
|
popupMenuTool6,
|
|
buttonTool18,
|
|
buttonTool19,
|
|
buttonTool20,
|
|
buttonTool22,
|
|
buttonTool24,
|
|
buttonTool26,
|
|
popupMenuTool8});
|
|
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
|
|
//
|
|
// grid
|
|
//
|
|
this.tbManager.SetContextMenuUltra(this.grid, "Invoices");
|
|
appearance1.BackColor = System.Drawing.SystemColors.Window;
|
|
appearance1.BorderColor = System.Drawing.SystemColors.InactiveCaption;
|
|
this.grid.DisplayLayout.Appearance = appearance1;
|
|
this.grid.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
|
|
this.grid.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
|
|
appearance2.BackColor = System.Drawing.SystemColors.ActiveBorder;
|
|
appearance2.BackColor2 = System.Drawing.SystemColors.ControlDark;
|
|
appearance2.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
|
|
appearance2.BorderColor = System.Drawing.SystemColors.Window;
|
|
this.grid.DisplayLayout.GroupByBox.Appearance = appearance2;
|
|
appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
|
|
this.grid.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
|
|
this.grid.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
|
|
this.grid.DisplayLayout.GroupByBox.Hidden = true;
|
|
appearance4.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
|
appearance4.BackColor2 = System.Drawing.SystemColors.Control;
|
|
appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
|
|
appearance4.ForeColor = System.Drawing.SystemColors.GrayText;
|
|
this.grid.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
|
|
this.grid.DisplayLayout.MaxColScrollRegions = 1;
|
|
this.grid.DisplayLayout.MaxRowScrollRegions = 1;
|
|
appearance5.BackColor = System.Drawing.SystemColors.Window;
|
|
appearance5.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this.grid.DisplayLayout.Override.ActiveCellAppearance = appearance5;
|
|
appearance6.BackColor = System.Drawing.SystemColors.Highlight;
|
|
appearance6.ForeColor = System.Drawing.SystemColors.HighlightText;
|
|
this.grid.DisplayLayout.Override.ActiveRowAppearance = appearance6;
|
|
this.grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
|
|
this.grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
|
|
this.grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
|
|
this.grid.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
|
|
this.grid.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
|
|
appearance7.BackColor = System.Drawing.SystemColors.Window;
|
|
this.grid.DisplayLayout.Override.CardAreaAppearance = appearance7;
|
|
appearance8.BorderColor = System.Drawing.Color.Silver;
|
|
appearance8.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
|
|
this.grid.DisplayLayout.Override.CellAppearance = appearance8;
|
|
this.grid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
|
|
this.grid.DisplayLayout.Override.CellPadding = 0;
|
|
appearance9.BackColor = System.Drawing.SystemColors.Control;
|
|
appearance9.BackColor2 = System.Drawing.SystemColors.ControlDark;
|
|
appearance9.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
|
|
appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
|
|
appearance9.BorderColor = System.Drawing.SystemColors.Window;
|
|
this.grid.DisplayLayout.Override.GroupByRowAppearance = appearance9;
|
|
appearance10.TextHAlignAsString = "Left";
|
|
this.grid.DisplayLayout.Override.HeaderAppearance = appearance10;
|
|
this.grid.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
|
|
this.grid.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
|
|
appearance11.BackColor = System.Drawing.SystemColors.Window;
|
|
appearance11.BorderColor = System.Drawing.Color.Silver;
|
|
this.grid.DisplayLayout.Override.RowAppearance = appearance11;
|
|
this.grid.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
|
|
this.grid.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None;
|
|
this.grid.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
|
|
this.grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Extended;
|
|
appearance12.BackColor = System.Drawing.SystemColors.ControlLight;
|
|
this.grid.DisplayLayout.Override.TemplateAddRowAppearance = appearance12;
|
|
this.grid.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
|
|
this.grid.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
|
|
this.grid.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.grid.Location = new System.Drawing.Point(0, 0);
|
|
this.grid.Name = "grid";
|
|
this.grid.Size = new System.Drawing.Size(605, 479);
|
|
this.grid.TabIndex = 0;
|
|
this.grid.Text = "ultraGrid1";
|
|
this.grid.Visible = false;
|
|
this.grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.grid_InitializeRow);
|
|
this.grid.MouseUp += new System.Windows.Forms.MouseEventHandler(this.grid_MouseUp);
|
|
//
|
|
// MainForm_Fill_Panel
|
|
//
|
|
this.MainForm_Fill_Panel.Controls.Add(this.grid);
|
|
this.MainForm_Fill_Panel.Controls.Add(this.lblStatus);
|
|
this.MainForm_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
|
|
this.MainForm_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.MainForm_Fill_Panel.Location = new System.Drawing.Point(0, 56);
|
|
this.MainForm_Fill_Panel.Name = "MainForm_Fill_Panel";
|
|
this.MainForm_Fill_Panel.Size = new System.Drawing.Size(605, 479);
|
|
this.MainForm_Fill_Panel.TabIndex = 1;
|
|
//
|
|
// lblStatus
|
|
//
|
|
appearance13.BackColor = System.Drawing.SystemColors.Window;
|
|
appearance13.FontData.BoldAsString = "False";
|
|
appearance13.FontData.SizeInPoints = 11F;
|
|
appearance13.ForeColor = System.Drawing.SystemColors.WindowText;
|
|
this.lblStatus.Appearance = appearance13;
|
|
this.lblStatus.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.lblStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
this.lblStatus.Location = new System.Drawing.Point(0, 0);
|
|
this.lblStatus.Name = "lblStatus";
|
|
this.lblStatus.Size = new System.Drawing.Size(605, 479);
|
|
this.lblStatus.TabIndex = 1;
|
|
//
|
|
// _MainForm_Toolbars_Dock_Area_Left
|
|
//
|
|
this._MainForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MainForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MainForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
|
this._MainForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MainForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 56);
|
|
this._MainForm_Toolbars_Dock_Area_Left.Name = "_MainForm_Toolbars_Dock_Area_Left";
|
|
this._MainForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 479);
|
|
this._MainForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MainForm_Toolbars_Dock_Area_Right
|
|
//
|
|
this._MainForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MainForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MainForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
|
this._MainForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MainForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(605, 56);
|
|
this._MainForm_Toolbars_Dock_Area_Right.Name = "_MainForm_Toolbars_Dock_Area_Right";
|
|
this._MainForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 479);
|
|
this._MainForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MainForm_Toolbars_Dock_Area_Top
|
|
//
|
|
this._MainForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MainForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MainForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
|
this._MainForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MainForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
|
this._MainForm_Toolbars_Dock_Area_Top.Name = "_MainForm_Toolbars_Dock_Area_Top";
|
|
this._MainForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(605, 56);
|
|
this._MainForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MainForm_Toolbars_Dock_Area_Bottom
|
|
//
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 535);
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.Name = "_MainForm_Toolbars_Dock_Area_Bottom";
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(605, 0);
|
|
this._MainForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
|
|
//
|
|
// dsInvoices
|
|
//
|
|
this.dsInvoices.DataSetName = "Invoices";
|
|
this.dsInvoices.Locale = new System.Globalization.CultureInfo("en-US");
|
|
this.dsInvoices.Relations.AddRange(new System.Data.DataRelation[] {
|
|
new System.Data.DataRelation("Relation1", "Invoices", "Workorders", new string[] {
|
|
"WorkingID"}, new string[] {
|
|
"InvoiceWorkingID"}, false)});
|
|
this.dsInvoices.Tables.AddRange(new System.Data.DataTable[] {
|
|
this.Invoices,
|
|
this.Workorders});
|
|
//
|
|
// Invoices
|
|
//
|
|
this.Invoices.Columns.AddRange(new System.Data.DataColumn[] {
|
|
this.Client,
|
|
this.WorkingID,
|
|
this.Linked,
|
|
this.ClientID});
|
|
this.Invoices.Constraints.AddRange(new System.Data.Constraint[] {
|
|
new System.Data.UniqueConstraint("Constraint1", new string[] {
|
|
"WorkingID"}, true)});
|
|
this.Invoices.PrimaryKey = new System.Data.DataColumn[] {
|
|
this.WorkingID};
|
|
this.Invoices.TableName = "Invoices";
|
|
//
|
|
// Client
|
|
//
|
|
this.Client.ColumnName = "Client";
|
|
//
|
|
// WorkingID
|
|
//
|
|
this.WorkingID.AllowDBNull = false;
|
|
this.WorkingID.AutoIncrement = true;
|
|
this.WorkingID.Caption = "WorkingID";
|
|
this.WorkingID.ColumnName = "WorkingID";
|
|
this.WorkingID.DataType = typeof(int);
|
|
this.WorkingID.ReadOnly = true;
|
|
//
|
|
// Linked
|
|
//
|
|
this.Linked.Caption = "Linked";
|
|
this.Linked.ColumnName = "Linked";
|
|
this.Linked.DataType = typeof(bool);
|
|
this.Linked.DefaultValue = false;
|
|
//
|
|
// ClientID
|
|
//
|
|
this.ClientID.Caption = "ClientID";
|
|
this.ClientID.ColumnName = "ClientID";
|
|
this.ClientID.DataType = typeof(System.Guid);
|
|
//
|
|
// Workorders
|
|
//
|
|
this.Workorders.Columns.AddRange(new System.Data.DataColumn[] {
|
|
this.InvoiceWorkingID,
|
|
this.WorkorderID,
|
|
this.wostatus,
|
|
this.ServiceNumber,
|
|
this.ServiceDate,
|
|
this.Project,
|
|
this.StatusARGB,
|
|
this.dataColumn1});
|
|
this.Workorders.Constraints.AddRange(new System.Data.Constraint[] {
|
|
new System.Data.UniqueConstraint("Constraint1", new string[] {
|
|
"WorkorderID"}, true),
|
|
new System.Data.ForeignKeyConstraint("Relation1", "Invoices", new string[] {
|
|
"WorkingID"}, new string[] {
|
|
"InvoiceWorkingID"}, System.Data.AcceptRejectRule.None, System.Data.Rule.None, System.Data.Rule.None)});
|
|
this.Workorders.PrimaryKey = new System.Data.DataColumn[] {
|
|
this.WorkorderID};
|
|
this.Workorders.TableName = "Workorders";
|
|
//
|
|
// InvoiceWorkingID
|
|
//
|
|
this.InvoiceWorkingID.Caption = "InvoiceWorkingID";
|
|
this.InvoiceWorkingID.ColumnName = "InvoiceWorkingID";
|
|
this.InvoiceWorkingID.DataType = typeof(int);
|
|
//
|
|
// WorkorderID
|
|
//
|
|
this.WorkorderID.AllowDBNull = false;
|
|
this.WorkorderID.Caption = "WorkorderID";
|
|
this.WorkorderID.ColumnName = "WorkorderID";
|
|
this.WorkorderID.DataType = typeof(System.Guid);
|
|
//
|
|
// wostatus
|
|
//
|
|
this.wostatus.Caption = "Status";
|
|
this.wostatus.ColumnName = "Status";
|
|
//
|
|
// ServiceNumber
|
|
//
|
|
this.ServiceNumber.Caption = "ServiceNumber";
|
|
this.ServiceNumber.ColumnName = "ServiceNumber";
|
|
this.ServiceNumber.DataType = typeof(int);
|
|
//
|
|
// ServiceDate
|
|
//
|
|
this.ServiceDate.Caption = "ServiceDate";
|
|
this.ServiceDate.ColumnName = "ServiceDate";
|
|
this.ServiceDate.DataType = typeof(object);
|
|
//
|
|
// Project
|
|
//
|
|
this.Project.Caption = "Project";
|
|
this.Project.ColumnName = "Project";
|
|
//
|
|
// StatusARGB
|
|
//
|
|
this.StatusARGB.Caption = "StatusARGB";
|
|
this.StatusARGB.ColumnName = "StatusARGB";
|
|
this.StatusARGB.DataType = typeof(int);
|
|
//
|
|
// dataColumn1
|
|
//
|
|
this.dataColumn1.ColumnName = "Linked";
|
|
this.dataColumn1.DataType = typeof(bool);
|
|
this.dataColumn1.DefaultValue = false;
|
|
//
|
|
// MainForm
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.ClientSize = new System.Drawing.Size(605, 554);
|
|
this.Controls.Add(this.MainForm_Fill_Panel);
|
|
this.Controls.Add(this._MainForm_Toolbars_Dock_Area_Left);
|
|
this.Controls.Add(this._MainForm_Toolbars_Dock_Area_Right);
|
|
this.Controls.Add(this._MainForm_Toolbars_Dock_Area_Bottom);
|
|
this.Controls.Add(this.statusBar);
|
|
this.Controls.Add(this._MainForm_Toolbars_Dock_Area_Top);
|
|
this.Name = "MainForm";
|
|
this.Text = "AyaNova QBI";
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
|
|
this.Load += new System.EventHandler(this.MainForm_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.statusBar)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
|
|
this.MainForm_Fill_Panel.ResumeLayout(false);
|
|
((System.ComponentModel.ISupportInitialize)(this.dsInvoices)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.Invoices)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.Workorders)).EndInit();
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//************************************************************
|
|
|
|
#region Form load / close
|
|
|
|
private void MainForm_Load(object sender, System.EventArgs e)
|
|
{
|
|
Util.bMainWindowOpen = true;
|
|
////Case 671
|
|
//AyaBizUtils.AllowAutomaticMRUOnUpdate = false;
|
|
|
|
////Case 6 and case 597
|
|
//AyaBizUtils.AllowAutomaticClosedWorkorderStatus = false;
|
|
//if(!DoPFC())
|
|
//{
|
|
// this.Close();
|
|
// return;
|
|
//}
|
|
|
|
this.Icon = Resource.QBI16icon;
|
|
|
|
this.Text="AyaNova QBI - " + Util.QCompanyName;
|
|
|
|
|
|
InitializeGrid();
|
|
|
|
//See if there are *any* data mappings, if not then we will prompt the user to start that process
|
|
if (Util.QBI.Maps.Count == 0)
|
|
{
|
|
//show message about mapping
|
|
MessageBox.Show(
|
|
"AyaNova QBI now needs you to map data between QuickBooks and AyaNova.",
|
|
"Setup mapping", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
Map m = new Map();
|
|
if (m.ShowDialog() == DialogResult.Abort)
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
//Display billable workorders
|
|
InitInvoices();
|
|
|
|
|
|
this.Visible = true;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
Util.bMainWindowOpen = false;
|
|
string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
grid.DisplayLayout.Save(currentAssemblyDirectoryName+"\\MainGrid.lyt");
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Toolbar commands
|
|
private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
|
|
//MessageBox.Show("DEBUG: TOOL CLICKED KEY = " + e.Tool.Key);
|
|
|
|
switch (e.Tool.Key)
|
|
{
|
|
|
|
case "Exit": // ButtonTool
|
|
this.Close();
|
|
break;
|
|
case "InvoiceConsolidatedWorkorders": // ButtonTool
|
|
InvoiceSelected(false);
|
|
break;
|
|
case "InvoiceOnePerWO": //case 1604
|
|
InvoiceSelected(true);
|
|
break;
|
|
case "Fix problems": // ButtonTool
|
|
FixInvoiceProblems d = new FixInvoiceProblems();
|
|
d.MisMatches=_MisMatches;
|
|
d.PartPriceOverrides=_PartPriceOverrides;
|
|
d.ShowDialog();
|
|
if(d.ChangesMade)
|
|
InitInvoices();
|
|
d.Dispose();
|
|
break;
|
|
|
|
case "Map and import": // ButtonTool
|
|
Map m=new Map();
|
|
if (m.ShowDialog() == DialogResult.Abort)
|
|
this.Close();
|
|
else
|
|
{
|
|
m.Dispose();
|
|
this.InitInvoices();
|
|
}
|
|
break;
|
|
|
|
case "InvoiceText": // ButtonTool
|
|
InvoiceTemplateBuilder b = new InvoiceTemplateBuilder(Util.QDat);
|
|
b.ShowDialog();
|
|
|
|
if(Util.QDat.IsDirty )
|
|
{
|
|
|
|
//Case 299
|
|
Util.QBI.AIObject = Util.QDat.XMLData;
|
|
//Util.QBI.AIObject = Util.QDat;
|
|
|
|
Util.QBI=(Integration)Util.QBI.Save();
|
|
Util.QDat.IsDirty=false;
|
|
|
|
}
|
|
b.Dispose();
|
|
break;
|
|
|
|
case "Preferences": // ButtonTool
|
|
Util.ValidateSettings(true);
|
|
InitInvoices();
|
|
break;
|
|
|
|
case "Contents": //
|
|
//case 3649
|
|
Util.OpenWebURL("https://www.ayanova.com/QBI7webHelp/index.html");
|
|
break;
|
|
|
|
case "Technical support": // ButtonTool
|
|
Util.OpenWebURL("http://forum.ayanova.com");
|
|
break;
|
|
|
|
case "Check for updates": // ButtonTool
|
|
//case 3649
|
|
Util.OpenWebURL("https://www.ayanova.com/download.htm");
|
|
break;
|
|
|
|
case "About": // ButtonTool
|
|
{
|
|
Assembly a = Assembly.GetExecutingAssembly();
|
|
string sVersion = "AyaNova QBI version " + AyaBizUtils.DisplayVersion(a.GetName().Version) + "\r\n";
|
|
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
|
if (fileVersion.FileBuildPart > 0)
|
|
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")\r\n";
|
|
sVersion += "Copyright 2000-2020 Ground Zero Tech-Works Inc.\r\n";
|
|
MessageBox.Show(sVersion, "About");
|
|
}
|
|
break;
|
|
|
|
case "QBREFRESH": // ButtonTool
|
|
Util.PopulateQBListCache();
|
|
Util.PopulateAyaListCache();
|
|
break;
|
|
|
|
case "Refresh invoices": // ButtonTool
|
|
InitInvoices();
|
|
break;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Main workorder grid
|
|
|
|
/// <summary>
|
|
/// Adjusts main form display to either show a list of billable workorders
|
|
/// or a status indicating there are none and why
|
|
/// </summary>
|
|
private void SetState()
|
|
{
|
|
tbManager.Tools["Fix problems"].SharedProps.Enabled=(_MisMatches.Count>0);
|
|
if(grid.Rows.Count>0)
|
|
{
|
|
|
|
grid.Visible=true;
|
|
this.lblStatus.Visible=false;
|
|
}
|
|
else
|
|
{
|
|
StringBuilder sb=new StringBuilder();
|
|
sb.Append("No invoiceable work orders found in AyaNova\r\n\r\n");
|
|
sb.Append("A work order is invoiceable and will be listed here if it has:\r\n");
|
|
sb.Append(" - \"Service completed\" field checked\r\n");
|
|
sb.Append(" - \"Closed\" field is not checked\r\n");
|
|
sb.Append(" - \"Invoice number\" field empty\r\n");
|
|
if(Util.QDat.PreWOStatus!=Guid.Empty)
|
|
{
|
|
sb.Append(" - \"Status\" field set to: ");
|
|
sb.Append(NameFetcher.GetItem("aWorkorderStatus","aName",Util.QDat.PreWOStatus));
|
|
sb.Append("\r\n");
|
|
sb.Append(" (You can change this status under Tools->Preferences in the menu)");
|
|
|
|
}
|
|
this.lblStatus.Text=sb.ToString();
|
|
|
|
grid.Visible=false;
|
|
this.lblStatus.Visible=true;
|
|
}
|
|
}
|
|
|
|
private WorkorderServiceBillableList _wolist=null;
|
|
private ArrayList _MisMatches=new ArrayList();
|
|
private ArrayList _PartPriceOverrides=new ArrayList();
|
|
/// <summary>
|
|
/// Initialize invoices dataset
|
|
/// from scratch. If a previous
|
|
/// initialize was done, wipe it and
|
|
/// repopulate from scratch
|
|
/// </summary>
|
|
private void InitInvoices()
|
|
{
|
|
Waiting w=new Waiting();
|
|
w.Show();
|
|
w.Ops="Validating invoices...";
|
|
|
|
|
|
try
|
|
{
|
|
|
|
_MisMatches.Clear();
|
|
grid.BeginUpdate();
|
|
dsInvoices.Clear();
|
|
_wolist=WorkorderServiceBillableList.GetList(Util.QDat.PreWOStatus,true);
|
|
DataTable dtInvoice=dsInvoices.Tables["Invoices"];
|
|
DataTable dtWorkorder=dsInvoices.Tables["Workorders"];
|
|
foreach(WorkorderServiceBillableList.WorkorderServiceBillableListInfo i in _wolist)
|
|
{
|
|
bool bLinked=Util.ScanLinksOK(i.ID,_MisMatches,_PartPriceOverrides);
|
|
|
|
DataRow dri=InvoiceRowForClientID(i.ClientID);
|
|
w.Step="WO: " + i.ServiceNumber;
|
|
if(dri==null)
|
|
{
|
|
dri=dtInvoice.NewRow();
|
|
dri["Client"]=i.Client;
|
|
dri["ClientID"]=i.ClientID;
|
|
dtInvoice.Rows.Add(dri);
|
|
}
|
|
|
|
//If any one single workorder is linked
|
|
//then the invoice is flagged as linked because
|
|
//you can invoice out anything under it that is linked and the
|
|
//not linked items simply won't invoice
|
|
if(bLinked)
|
|
dri["Linked"]=true;
|
|
|
|
DataRow drw=dtWorkorder.NewRow();
|
|
drw["InvoiceWorkingID"]=(int)dri["WorkingID"];
|
|
drw["WorkorderID"]=i.ID;
|
|
drw["Status"]=i.Status;
|
|
drw["ServiceNumber"]=i.ServiceNumber;
|
|
drw["ServiceDate"]=i.ServiceDate;
|
|
drw["Project"]=i.Project;
|
|
drw["StatusARGB"]=i.StatusARGB;
|
|
|
|
drw["Linked"]=bLinked;
|
|
dtWorkorder.Rows.Add(drw);
|
|
|
|
|
|
|
|
}
|
|
|
|
grid.DisplayLayout.Rows.CollapseAll(false);
|
|
foreach(UltraGridRow r in grid.Rows)
|
|
{
|
|
foreach(UltraGridRow rr in r.ChildBands[0].Rows)
|
|
{
|
|
if((bool)rr.Cells["Linked"].Value==false)
|
|
r.Expanded=true;
|
|
}
|
|
|
|
}
|
|
grid.EndUpdate();
|
|
}
|
|
finally
|
|
{
|
|
w.Close();
|
|
}
|
|
|
|
SetState();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Helper for grouping workorders by client
|
|
/// </summary>
|
|
/// <param name="ClientID"></param>
|
|
/// <returns>null if not found else datarow containing invoice for client</returns>
|
|
private DataRow InvoiceRowForClientID(Guid ClientID)
|
|
{
|
|
foreach(DataRow r in dsInvoices.Tables["Invoices"].Rows)
|
|
{
|
|
if((Guid)r["ClientID"]==ClientID)
|
|
{
|
|
return r;
|
|
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeGrid()
|
|
{
|
|
grid.DataSource=dsInvoices;
|
|
string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
|
|
//Load the grid layout from file
|
|
if (System.IO.File.Exists(currentAssemblyDirectoryName + "\\MainGrid.lyt"))
|
|
grid.DisplayLayout.Load(currentAssemblyDirectoryName + "\\MainGrid.lyt");
|
|
grid.DisplayLayout.Bands[0].Columns["WorkingID"].Hidden=true;
|
|
grid.DisplayLayout.Bands[0].Columns["ClientID"].Hidden=true;
|
|
grid.DisplayLayout.Bands[0].Columns["Linked"].Hidden=true;
|
|
grid.DisplayLayout.Bands[0].Columns["Client"].Header.Caption="Invoice";
|
|
|
|
grid.DisplayLayout.Bands[1].Columns["InvoiceWorkingID"].Hidden=true;
|
|
grid.DisplayLayout.Bands[1].Columns["WorkorderID"].Hidden=true;
|
|
grid.DisplayLayout.Bands[1].Columns["StatusARGB"].Hidden=true;
|
|
grid.DisplayLayout.Bands[1].Columns["Linked"].Hidden=true;
|
|
}
|
|
|
|
private void grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
|
|
{
|
|
if(e.Row.Band.Index==0)
|
|
{
|
|
//Prepare invoice row
|
|
if((bool)e.Row.Cells["Linked"].Value == true)
|
|
{
|
|
e.Row.Cells["Client"].Appearance.Image = Util.AyaImage("OK16");//Util.Image("OK16.png");
|
|
}
|
|
else
|
|
{
|
|
e.Row.Cells["Client"].Appearance.Image = Util.AyaImage("Cancel16");//Util.Image("Cancel16.png");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//prepare workorder row
|
|
|
|
//if backcolor==0 that means no color was set
|
|
int nColor=(int)e.Row.Cells["StatusARGB"].Value;
|
|
if(nColor!=0)
|
|
{
|
|
e.Row.Cells["Status"].Appearance.BackColor=Color.FromArgb(nColor);
|
|
e.Row.Cells["Status"].Appearance.ForeColor=Util.InvertColor(Color.FromArgb(nColor));
|
|
|
|
}
|
|
|
|
//flag whether billable (linked) or not
|
|
if((bool)e.Row.Cells["Linked"].Value == true)
|
|
{
|
|
e.Row.Cells["ServiceNumber"].Appearance.Image = Util.AyaImage("OK16");
|
|
}
|
|
else
|
|
{
|
|
e.Row.Cells["ServiceNumber"].Appearance.Image = Util.AyaImage("Cancel16");
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region right clicky stuff
|
|
private void grid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
|
{
|
|
//Here's the plan:
|
|
//if mouse is right clicked anywhere on a row
|
|
//checks to see if that row is already selected, if it is
|
|
//then nothing is done
|
|
|
|
//If it isn't however, then the row is selected thus
|
|
//unselecting any prior selected row(s)
|
|
|
|
//Also this should not prevent the popup menu from displaying
|
|
//or perhaps this should drive the popup menu *to* display instead
|
|
//of relying on the context menu setting for the grid
|
|
if( e.Button == MouseButtons.Right)
|
|
{
|
|
Infragistics.Win.UIElement element = grid.DisplayLayout.UIElement.ElementFromPoint(new System.Drawing.Point(e.X, e.Y));
|
|
//determine if a row was clicked on
|
|
if (element != null)
|
|
{
|
|
Type selectedType = element.GetContext().GetType();
|
|
|
|
if (selectedType == typeof(UltraGridRow))
|
|
{
|
|
//Get the row clicked on and see if it's already selected...
|
|
|
|
UltraGridRow r=(UltraGridRow)element.SelectableItem;
|
|
if (r != null && r.Selected) //Case 334
|
|
return;
|
|
else
|
|
{
|
|
//Clear any other selections and select this row
|
|
grid.Selected.Rows.Clear();
|
|
r.Activate();
|
|
r.Selected=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Invoice
|
|
|
|
/// <summary>
|
|
/// Invoice selected items
|
|
/// </summary>
|
|
private void InvoiceSelected(bool bOneWoPerInvoice)
|
|
{
|
|
//An array list to hold the guid's of workorders being invoiced
|
|
ArrayList al=new ArrayList();
|
|
this.Refresh();
|
|
Cursor.Current=Cursors.WaitCursor;
|
|
ArrayList alErrors=new ArrayList();
|
|
Waiting w=new Waiting();
|
|
w.Show();
|
|
w.Ops="Invoicing to QuickBooks...";
|
|
|
|
//work through selected items top to bottom
|
|
foreach(UltraGridRow r in grid.Selected.Rows)
|
|
{
|
|
//clear the workorder list
|
|
al.Clear();
|
|
|
|
//One lone workorder to be invoiced?
|
|
if(r.Band.Index==1)
|
|
{
|
|
//it's a child so see if it's parent is selected and if so then ignore it
|
|
//as it will be invoiced with the parent or more likely already has been
|
|
if(r.ParentRow.Selected)
|
|
continue;
|
|
|
|
//It's a stand alone single workorder selected to be invoiced on it's own
|
|
//with no parent invoice row selected, so invoice it out now
|
|
|
|
// but check to see if it's all linked first:
|
|
if((bool)r.Cells["Linked"].Value==false)
|
|
continue;
|
|
|
|
al.Add((Guid)r.Cells["WorkorderID"].Value);
|
|
w.Step="Invoicing single workorder ";
|
|
Util.Invoice(al,alErrors);
|
|
continue;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//A group of workorders to be invoiced?
|
|
if(r.Band.Index==0 && r.Selected)
|
|
{
|
|
foreach(UltraGridRow rchild in r.ChildBands[0].Rows)
|
|
{
|
|
if((bool)rchild.Cells["Linked"].Value==true)
|
|
{
|
|
al.Add((Guid)rchild.Cells["WorkorderID"].Value);
|
|
//case 1604
|
|
if (bOneWoPerInvoice)
|
|
{
|
|
//then invoice it out now
|
|
w.Step = "Invoicing single workorder ";
|
|
Util.Invoice(al, alErrors);
|
|
//and clear al workorders list
|
|
al.Clear();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if(al.Count>0)
|
|
{
|
|
w.Step="Invoicing " + al.Count.ToString() + ((al.Count>1) ? " Workorders" : " Workorder");
|
|
Util.Invoice(al,alErrors);
|
|
}
|
|
|
|
}
|
|
}
|
|
}//end of foreach loop
|
|
|
|
w.Close();
|
|
|
|
//display errors if any
|
|
if(alErrors.Count!=0)
|
|
{
|
|
|
|
StringBuilder sb=new StringBuilder();
|
|
sb.Append("Invoicing completed with some errors:\r\n\r\n");
|
|
foreach(object o in alErrors)
|
|
{
|
|
sb.Append((string)o);
|
|
sb.Append("\r\n************\r\n");
|
|
|
|
}
|
|
|
|
CopyableMessageBox cb=new CopyableMessageBox(sb.ToString());
|
|
cb.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
//refresh display
|
|
InitInvoices();
|
|
}
|
|
#endregion
|
|
|
|
|
|
//*************************************************************
|
|
}
|
|
}
|