This commit is contained in:
2022-07-03 22:39:17 +00:00
parent 0e8e85dd50
commit adf8912e7a
6 changed files with 351 additions and 31 deletions

View File

@@ -111,6 +111,12 @@
<Compile Include="Map.Designer.cs"> <Compile Include="Map.Designer.cs">
<DependentUpon>Map.cs</DependentUpon> <DependentUpon>Map.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MapSelectAyaNovaItem.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MapSelectAyaNovaItem.Designer.cs">
<DependentUpon>MapSelectAyaNovaItem.cs</DependentUpon>
</Compile>
<Compile Include="MapSelectQBItem.cs"> <Compile Include="MapSelectQBItem.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -211,6 +217,9 @@
<EmbeddedResource Include="Map.resx"> <EmbeddedResource Include="Map.resx">
<DependentUpon>Map.cs</DependentUpon> <DependentUpon>Map.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="MapSelectAyaNovaItem.resx">
<DependentUpon>MapSelectAyaNovaItem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MapSelectQBItem.resx"> <EmbeddedResource Include="MapSelectQBItem.resx">
<DependentUpon>MapSelectQBItem.cs</DependentUpon> <DependentUpon>MapSelectQBItem.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@@ -77,6 +77,7 @@ namespace AyaNovaQBI
if (IsAyaGrid) if (IsAyaGrid)
{ {
#region AyaGrid
//we have selection now get qb item //we have selection now get qb item
MapSelectQBItem s = new MapSelectQBItem(); MapSelectQBItem s = new MapSelectQBItem();
@@ -165,18 +166,61 @@ namespace AyaNovaQBI
} }
} }
#endregion AyaGrid
}
else
{
#region QB GRID
//################
//QB GRID
//
if (gridQB.SelectedRows.Count > 1)
{
MessageBox.Show("You can not link more than one QuickBooks\r\n" +
"object to a single AyaNova object", "Not supported", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var QBItemName = gridQB.SelectedRows[0].Cells[0].Value.ToString();
var QBItemId = gridQB.SelectedRows[0].Cells[1].Value.ToString();
MapSelectAyaNovaItem s = new MapSelectAyaNovaItem();
s.Items = _aya;
if (s.ShowDialog() == DialogResult.Cancel)
return;
var AyaId = s.SelectedItemId;
s.Dispose();
//This way is a one to one mapping so only one iteration and two potential things to do, add or change link
//Is it already present?
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == AyaId && z.AType == _Type);
if (m != null)
{
m.IntegrationItemId = QBItemId;
m.IntegrationItemName = QBItemName;
m.LastSync = System.DateTime.Now;
SaveIntegration = true;
}
else
{
//not already present, so add it
m = new IntegrationItem { AType = _Type, IntegrationItemName = QBItemName, IntegrationItemId = QBItemId, LastSync = System.DateTime.Now, ObjectId = AyaId };
util.QBIntegration.Items.Add(m);
SaveIntegration = true;
}
#endregion qb grid
}
if (SaveIntegration) if (SaveIntegration)
{ {
await util.SaveIntegrationObject(); await util.SaveIntegrationObject();
Initialize(); Initialize();
} }
//#################################
}
else
{
}
} }
@@ -548,30 +592,5 @@ namespace AyaNovaQBI
/*
* Simplified, no drag and drop just pick and choose with clicks
* A menu to select the ayanova object type which then populates the ayanova items grid of that type showing:
A single grid showing all ayanova items of the selected type with their name in the first column and a second column showing what they are mapped to in qb item name, easy peasy, no drag and drop
User can select one or more items
when one or more are selected
a menu item appears saying "MAP Selected items" when they select they can pick a qb item of the type they want and accept in a popup dialog which also shows how many ayanova items are selected
a menyu tiem apepars saying UNMAP selected items when they select it it removes the mapping after confirmation dialog from all selected items
//public static List<InvoiceableItem> GetInvoiceableItems()
//{
// var random = new Random();
// var l = new List<InvoiceableItem>();
// for (int i = 1; i < random.Next(25, 100); i++)
// l.Add(new InvoiceableItem { Customer = $"Customer {random.Next(1, 5)}", Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("g"), ServiceNumber = (40 + i).ToString(), Status = $"Waiting to be invoiced", StatusColor = "FF00FFAA", WorkorderId = 4 });
// return l.OrderBy(x => x.Customer)
// .ThenBy(x => x.ServiceNumber)
// .ThenBy(x => x.ServiceDate)
// .ToList();
//}
*/
} }
} }

View File

@@ -0,0 +1,106 @@
namespace AyaNovaQBI
{
partial class MapSelectAyaNovaItem
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.cbItems = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(656, 108);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 19;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(19, 107);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 18;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// cbItems
//
this.cbItems.Dock = System.Windows.Forms.DockStyle.Top;
this.cbItems.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbItems.FormattingEnabled = true;
this.cbItems.Location = new System.Drawing.Point(16, 29);
this.cbItems.Name = "cbItems";
this.cbItems.Size = new System.Drawing.Size(715, 21);
this.cbItems.TabIndex = 17;
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(715, 13);
this.label1.TabIndex = 16;
this.label1.Text = "Link selected QuickBooks item to:";
//
// MapSelectAyaNovaItem
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(747, 150);
this.ControlBox = false;
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.cbItems);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "MapSelectAyaNovaItem";
this.Padding = new System.Windows.Forms.Padding(16);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "AyaNova items";
this.Load += new System.EventHandler(this.MapSelectAyaNovaItem_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.ComboBox cbItems;
private System.Windows.Forms.Label label1;
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AyaNovaQBI
{
public partial class MapSelectAyaNovaItem : Form
{
public MapSelectAyaNovaItem()
{
InitializeComponent();
}
public string SelectedItemName
{
get
{
return ((DataRowView)cbItems.SelectedItem).Row[0].ToString();
}
}
public long SelectedItemId
{
get
{
return (long)((DataRowView)cbItems.SelectedItem).Row[1];
}
}
public DataTable Items { get; set; }
private void MapSelectAyaNovaItem_Load(object sender, EventArgs e)
{
cbItems.DataSource = Items;
cbItems.DisplayMember = "name";
cbItems.ValueMember = "id";
btnCancel.Text = util.AyaTranslations["Cancel"];
btnOK.Text = util.AyaTranslations["OK"];
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -88,10 +88,12 @@
// //
// MapSelectQBItem // MapSelectQBItem
// //
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(747, 150); this.ClientSize = new System.Drawing.Size(747, 150);
this.ControlBox = false;
this.Controls.Add(this.ckNothing); this.Controls.Add(this.ckNothing);
this.Controls.Add(this.btnOK); this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
@@ -100,6 +102,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "MapSelectQBItem"; this.Name = "MapSelectQBItem";
this.Padding = new System.Windows.Forms.Padding(16); this.Padding = new System.Windows.Forms.Padding(16);
this.ShowIcon = false;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.Text = "QB Items"; this.Text = "QB Items";
this.Load += new System.EventHandler(this.MapSelectQBItem_Load); this.Load += new System.EventHandler(this.MapSelectQBItem_Load);