This commit is contained in:
2022-07-02 00:48:21 +00:00
parent 453cb6a614
commit f4192f494f
3 changed files with 296 additions and 25 deletions

View File

@@ -28,8 +28,8 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.objectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.customersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -169,17 +169,17 @@
this.grid.AllowUserToAddRows = false;
this.grid.AllowUserToDeleteRows = false;
this.grid.AllowUserToResizeRows = false;
dataGridViewCellStyle17.BackColor = System.Drawing.Color.WhiteSmoke;
this.grid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle17;
dataGridViewCellStyle19.BackColor = System.Drawing.Color.WhiteSmoke;
this.grid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle19;
this.grid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle18.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.grid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle18;
dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle20.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle20.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle20.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle20.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle20.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.grid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle20;
this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.AyaName,
@@ -254,6 +254,7 @@
this.MainMenuStrip = this.menuStrip1;
this.Name = "Map";
this.Text = "Map";
this.Load += new System.EventHandler(this.Map_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();

View File

@@ -12,12 +12,280 @@ namespace AyaNovaQBI
{
public partial class Map : Form
{
private AyaType _Type = AyaType.Customer;
private DataTable _aya;
private DataTable _qb;
//private VendorTypes _currentVendorType = 0;
private viewtypes _currentView = viewtypes.All;
//private RateTypes _currentRateType = 0;
//private long _MostLikelyRateUnitChargeDescriptionID = 0;
private enum viewtypes
{
All,
Unlinked,
Linked
}
public Map()
{
InitializeComponent();
this.Icon = AyaNovaQBI.Properties.Resources.logo;
_aya = new DataTable("AyaNova");
_aya.Columns.Add("ayaid", typeof(long));
_aya.Columns.Add("qbid", typeof(string));
_aya.Columns.Add("AyaName", typeof(string));
_aya.Columns.Add("QBName", typeof(bool));
//Case 339
_aya.DefaultView.Sort = "AyaName asc";
_qb = new DataTable("QuickBooks");
_qb.Columns.Add("ID", typeof(string));
_qb.Columns.Add("Name", typeof(string));
_qb.Columns.Add("Linked", typeof(bool));
//Case 339
_qb.DefaultView.Sort = "Name asc";
grid.DataSource = _aya;
}
private void Map_Load(object sender, EventArgs e)
{
Initialize();
}
/// <summary>
/// Determine if row should be added to grid or now
/// based on current view preferences and if item is already
/// linked or not
/// </summary>
/// <param name="bLinked"></param>
/// <returns></returns>
private bool DisplayRow(bool bLinked)
{
switch (_currentView)
{
case viewtypes.All:
return true;
case viewtypes.Linked:
return bLinked;
case viewtypes.Unlinked:
return !bLinked;
}
return true;
}
private void Initialize()
{
//clear both lists
_aya.Rows.Clear();
_qb.Rows.Clear();
//Case 147
updateAyaNovaPricesToolStripMenuItem.Visible = false;
switch (_Type)
{
case AyaType.Customer:
#region client
foreach (var i in util.AyaClientList)
{
if (i.Active)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.Id == i.Id);
if (DisplayRow(bLinked))
{
var qbItem = util.QBIntegration.Items.FirstOrDefault(z => z.AType == _Type && z.Id == i.Id);
_aya.Rows.Add(new object[] { i.Id, qbItem.IntegrationItemId, i.Name, qbItem.IntegrationItemName });
}
}
}
//Fill QB table with QB Customers from prefetched table
foreach (DataRow dr in util.QBClients.Rows)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.IntegrationItemId == dr["ID"].ToString());
if (DisplayRow(bLinked))
_qb.Rows.Add(new object[] { dr["ID"].ToString(), dr["FullName"].ToString(), bLinked });
}
#endregion client
break;
case AyaType.Vendor:
#region Vendor
foreach (var i in util.AyaVendorList)
{
if (i.Active)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.Id == i.Id);
if (DisplayRow(bLinked))
{
var qbItem = util.QBIntegration.Items.FirstOrDefault(z => z.AType == _Type && z.Id == i.Id);
_aya.Rows.Add(new object[] { i.Id, qbItem.IntegrationItemId, i.Name, qbItem.IntegrationItemName });
}
}
}
//Fill QB table with QB Customers from prefetched table
foreach (DataRow dr in util.QBVendors.Rows)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.IntegrationItemId == dr["ID"].ToString());
if (DisplayRow(bLinked))
_qb.Rows.Add(new object[] { dr["ID"].ToString(), dr["FullName"].ToString(), bLinked });
}
#endregion Vendor
break;
case AyaType.ServiceRate:
#region Service rates
//_MostLikelyRateUnitChargeDescriptionID = 0;
foreach (var i in util.AyaServiceRateList)
{
if (i.Active)
{
// //Determine the most likely description for purposes
// //of importing a rate from QB later by picking the first one
// //in the existing rate list that is non-empty
// //typically this will just be hours and every rate will
// //probably use the same one or for travel "miles" or "km's" etc
// if(_MostLikelyRateUnitChargeDescriptionID==Guid.Empty && i.RateUnitChargeDescriptionID!=Guid.Empty)
// _MostLikelyRateUnitChargeDescriptionID=i.RateUnitChargeDescriptionID;
//After discussion we decided to not us any rate unit charge description
//so leaving the code in but defaulted to guid.empty for now.
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.Id == i.Id);
if (DisplayRow(bLinked))
{
var qbItem = util.QBIntegration.Items.FirstOrDefault(z => z.AType == _Type && z.Id == i.Id);
_aya.Rows.Add(new object[] { i.Id, qbItem.IntegrationItemId, i.Name, qbItem.IntegrationItemName });
}
}
}
//Fill QB table with QB items from prefetched table
foreach (DataRow dr in util.QBItems.Rows)
{
if ((util.qbitemtype)dr["Type"] == util.qbitemtype.Service || (util.qbitemtype)dr["Type"] == util.qbitemtype.OtherCharge)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.IntegrationItemId == dr["ID"].ToString());
if (DisplayRow(bLinked))
_qb.Rows.Add(new object[] { dr["ID"].ToString(), dr["FullName"].ToString(), bLinked });
}
}
#endregion Rate
break;
case AyaType.TravelRate:
#region TravelRate rates
//_MostLikelyRateUnitChargeDescriptionID = 0;
foreach (var i in util.AyaServiceRateList)
{
if (i.Active)
{
// //Determine the most likely description for purposes
// //of importing a rate from QB later by picking the first one
// //in the existing rate list that is non-empty
// //typically this will just be hours and every rate will
// //probably use the same one or for travel "miles" or "km's" etc
// if(_MostLikelyRateUnitChargeDescriptionID==Guid.Empty && i.RateUnitChargeDescriptionID!=Guid.Empty)
// _MostLikelyRateUnitChargeDescriptionID=i.RateUnitChargeDescriptionID;
//After discussion we decided to not us any rate unit charge description
//so leaving the code in but defaulted to guid.empty for now.
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.Id == i.Id);
if (DisplayRow(bLinked))
{
var qbItem = util.QBIntegration.Items.FirstOrDefault(z => z.AType == _Type && z.Id == i.Id);
_aya.Rows.Add(new object[] { i.Id, qbItem.IntegrationItemId, i.Name, qbItem.IntegrationItemName });
}
}
}
//Fill QB table with QB items from prefetched table
foreach (DataRow dr in util.QBItems.Rows)
{
if ((util.qbitemtype)dr["Type"] == util.qbitemtype.Service || (util.qbitemtype)dr["Type"] == util.qbitemtype.OtherCharge)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.IntegrationItemId == dr["ID"].ToString());
if (DisplayRow(bLinked))
_qb.Rows.Add(new object[] { dr["ID"].ToString(), dr["FullName"].ToString(), bLinked });
}
}
#endregion Rate
break;
case AyaType.Part:
#region Service parts
//case 632
//gridQB.DisplayLayout.Rows.TemplateAddRow.Hidden=true;
//Case 147
updateAyaNovaPricesToolStripMenuItem.Visible = true;
foreach (var i in util.AyaPartList)
{
if (i.Active)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.Id == i.Id);
if (DisplayRow(bLinked))
{
var qbItem = util.QBIntegration.Items.FirstOrDefault(z => z.AType == _Type && z.Id == i.Id);
_aya.Rows.Add(new object[] { i.Id, qbItem.IntegrationItemId, i.Name, qbItem.IntegrationItemName });
}
}
}
//Fill QB table with QB items from prefetched table
foreach (DataRow dr in util.QBItems.Rows)
{
if ((util.qbitemtype)dr["Type"] == util.qbitemtype.Inventory || (util.qbitemtype)dr["Type"] == util.qbitemtype.NonInventory || (util.qbitemtype)dr["Type"] == util.qbitemtype.Assembly)
{
bool bLinked = util.QBIntegration.Items.Any(z => z.AType == _Type && z.IntegrationItemId == dr["ID"].ToString());
if (DisplayRow(bLinked))
_qb.Rows.Add(new object[] { dr["ID"].ToString(), dr["FullName"].ToString(), bLinked });
}
}
#endregion Part
break;
}
}
private void showSubItemToolStripMenuItem_Click(object sender, EventArgs e)
{
// Set the current clicked item to item
@@ -67,6 +335,8 @@ 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:
@@ -76,7 +346,19 @@ namespace AyaNovaQBI
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

@@ -498,19 +498,7 @@ namespace AyaNovaQBI
Cancel = 2
}
//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();
//}
/*