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.PTI { /// /// Summary description for MainForm. /// 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(); Icon = Resource.PTI16icon; } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// 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("PTI"); 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 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 buttonTool9 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Check for updates"); 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 buttonTool13 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Check for updates"); 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.ButtonTool buttonTool16 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Invoice selected items to Peachtree"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool17 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Fix problems"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool18 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Fix problems"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool19 = new Infragistics.Win.UltraWinToolbars.ButtonTool("Invoice selected items to Peachtree"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool20 = new Infragistics.Win.UltraWinToolbars.ButtonTool("InvoiceText"); 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 = "PTI"; 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}); 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, buttonTool9, buttonTool10}); buttonTool11.SharedPropsInternal.Caption = "&Online manual"; buttonTool11.SharedPropsInternal.Shortcut = System.Windows.Forms.Shortcut.F1; buttonTool12.SharedPropsInternal.Caption = "Technical &support"; buttonTool13.SharedPropsInternal.Caption = "Check for &updates"; buttonTool14.SharedPropsInternal.Caption = "&About"; buttonTool15.SharedPropsInternal.Caption = "&Map and import"; popupMenuTool6.SharedPropsInternal.Caption = "Invoices"; popupMenuTool6.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool16, buttonTool17}); buttonTool18.SharedPropsInternal.Caption = "&Fix problems"; buttonTool19.SharedPropsInternal.Caption = "Invoice selected items to &Peachtree"; buttonTool20.SharedPropsInternal.Caption = "&Invoice descriptive text template"; this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool2, popupMenuTool4, buttonTool6, popupMenuTool5, buttonTool11, buttonTool12, buttonTool13, buttonTool14, buttonTool15, popupMenuTool6, buttonTool18, buttonTool19, buttonTool20}); 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.EditAndSelectText; 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, 509); 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, 26); this.MainForm_Fill_Panel.Name = "MainForm_Fill_Panel"; this.MainForm_Fill_Panel.Size = new System.Drawing.Size(605, 509); 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, 509); 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, 26); this._MainForm_Toolbars_Dock_Area_Left.Name = "_MainForm_Toolbars_Dock_Area_Left"; this._MainForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 509); 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, 26); this._MainForm_Toolbars_Dock_Area_Right.Name = "_MainForm_Toolbars_Dock_Area_Right"; this._MainForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 509); 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, 26); 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.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "AyaNova PTI"; 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 /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new MainForm()); } // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) //************************************************************ #region Form load / close private void MainForm_Load(object sender, System.EventArgs e) { this.Icon = Resource.PTI16icon; this.Text = "AyaNova PTI - " + Util.PTCompany; InitializeGrid(); //See if there are *any* data mappings, if not then we will prompt the user to start that process if (Util.PTI.Maps.Count == 0) { //show message about mapping MessageBox.Show( "AyaNova PTI now needs you to map data between Peachtree and AyaNova.", "Setup mapping", MessageBoxButtons.OK, MessageBoxIcon.Information); Map m = new Map(); m.ShowDialog(); } //Display billable workorders InitInvoices(); this.Visible = true; } /// /// /// /// /// private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); grid.DisplayLayout.Save(currentAssemblyDirectoryName + "\\MainGrid.lyt"); if (Util.ErrorFree == false) { MessageBox.Show("Due to a previous error importing or exporting,\r\n" + "the temporary files used by AyaNova PTI have been kept for diagnostic purposes.\r\n" + "If you require technical support you may be asked for one or more of these files\r\n" + "they are located at: " + Util.TempFilePath + " and follow the naming pattern of PT*.xml\r\n\r\n" + "These files will be deleted automatically the next time you run and close PTI\r\n" + "without errors.", "Diagnostic information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string[] s = Directory.GetFiles(Util.TempFilePath, "PT*.xml"); foreach (string sfile in s) System.IO.File.Delete(sfile); } } #endregion #region Toolbar commands private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Exit": // ButtonTool this.Close(); break; case "Invoice selected items to Peachtree": // ButtonTool InvoiceSelected(); 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(); m.ShowDialog(); m.Dispose(); this.InitInvoices(); break; case "InvoiceText": // ButtonTool InvoiceTemplateBuilder b = new InvoiceTemplateBuilder(Util.PDat); b.ShowDialog(); if(Util.PDat.IsDirty ) { //Case 299 Util.PTI.AIObject = Util.PDat.XMLData; //Util.PTI.AIObject = Util.QDat; Util.PTI=(Integration)Util.PTI.Save(); Util.PDat.IsDirty=false; } b.Dispose(); break; case "Preferences": // ButtonTool Util.ValidateSettings(true); InitInvoices(); break; case "Contents": // Util.OpenWebURL("https://www.ayanova.com/PTI7webHelp/index.html");//case 3649 break; case "Technical support": // ButtonTool Util.OpenWebURL("http://forum.ayanova.com"); break; case "Check for updates": // ButtonTool Util.OpenWebURL("https://www.ayanova.com/download.htm"); break; case "About": // ButtonTool { Assembly a = Assembly.GetExecutingAssembly(); string sVersion = "AyaNova PTI 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-2022 Ground Zero Tech-Works Inc.\r\n"; MessageBox.Show(sVersion, "About"); } break; } } #endregion #region Main workorder grid /// /// Adjusts main form display to either show a list of billable workorders /// or a status indicating there are none and why /// 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.PDat.PreWOStatus!=Guid.Empty) { sb.Append(" - \"Status\" field set to: "); sb.Append(NameFetcher.GetItem("aWorkorderStatus","aName",Util.PDat.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(); /// /// Initialize invoices dataset /// from scratch. If a previous /// initialize was done, wipe it and /// repopulate from scratch /// private void InitInvoices() { Waiting w=new Waiting(); w.Show(); w.Ops="Validating invoices..."; try { _MisMatches.Clear(); grid.BeginUpdate(); dsInvoices.Clear(); _wolist=WorkorderServiceBillableList.GetList(Util.PDat.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(); } /// /// Helper for grouping workorders by client /// /// /// null if not found else datarow containing invoice for client 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; //Load the grid layout from file string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 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"); } else { e.Row.Cells["Client"].Appearance.Image = Util.AyaImage("Cancel16"); } } 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 /// /// Invoice selected items /// private void InvoiceSelected() { //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 Peachtree..."; //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); } } 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 //************************************************************* } }