UltraGrid Column Key - DynamicQuery Fun

The Project:

Create a form that lists current laser table operations. This form also needs a way to log the operations as complete once they’re nested. (Laser Table reports by quantity only)

Work So Far:

Used Job Adjustment screen as a cookie cutter template. Hid all tabs except 2. The labor adjustment tab, referred to as “Op Logger”, and a second tab to keep a list of jobs on. The laser guy enters his job number at the top. This loads job info into the form. He then goes to the Op Logger tab, selects his Assembly and Operation numbers. Clicks “Get Costs” to get data from a query based on standard times and costs and places it into an ultragrid for display.

The Problem:

I created another button and want it to copy the data from the ultragrid into the EpiNumericEditors. Maybe we can even combine this function within the “Get Costs” button, to run the dynamicquery and paste the data with just one click… Anyway, I’ve tried

neLaborQty.Text = this.ugcosts.DisplayLayout.Bands[0].Columns["Run Qty"].ToString();

and

neLaborQty.Text = ugcosts.Rows[0].Cells["Run Qty"].Text;

and

neLaborQty.Value = ugcosts.Rows[0].Cells["Run Qty"].Value;

Here’s pictures of what I’m trying to accomplish.


The list works fine.

The “Get Costs” button works fine.

The"Copy Costs" button fails.
image

The Emoployee Name appears because I’m pushing plain text to it, not getting from another control or from a query.

Below is the code as it is right now.

// **************************************************
// Custom code for JobAdjustmentForm
// Created: 5/10/2019 9:35:55 AM
// **************************************************

using System;
using System.Reflection;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	Infragistics.Win.UltraWinDock.UltraDockManager dock;

	EpiTextBox tbJobNum;
	EpiTextBox tbEmployeeNum;
	EpiNumericEditor neLaborQty;
	EpiNumericEditor neLaborHrs;
	EpiNumericEditor neBurdenHrs;
	EpiNumericEditor neLaborCost;
	EpiNumericEditor neBurdenCost;
	Erp.UI.Controls.Combos.JobAsmSearchCombo cboAsmSeq;
	Erp.UI.Controls.Combos.JobOperSearchCombo cboOper;


	public void ugupdatecosts()
	{	
			DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
			dqa.BOConnect();		
			QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("Laser_Op_Details");
			qeds.ExecutionParameter.Clear();

			qeds.ExecutionParameter.AddExecutionParameterRow("JobNum", tbJobNum.Text, "nvarchar", false, Guid.NewGuid(), "A");
			qeds.ExecutionParameter.AddExecutionParameterRow("AssemblySeq", cboAsmSeq.Text, "int", false, Guid.NewGuid(), "A");
			qeds.ExecutionParameter.AddExecutionParameterRow("OprSeq", cboOper.Text, "int", false, Guid.NewGuid(), "A");

			dqa.ExecuteByID("Laser_Op_Details", qeds);

			ugcosts.DataSource = dqa.QueryResults.Tables["Results"];
	}

	public void ugupdatelist()
	{

		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();		
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("Laser_JobList");
		qeds.ExecutionParameter.Clear();
		dqa.ExecuteByID("Laser_JobList");
		uglaser.DataSource = dqa.QueryResults.Tables["Results"];

	}

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		Object obj = typeof(Erp.UI.App.JobAdjustmentEntry.JobAdjustmentForm).InvokeMember("baseDockManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, JobAdjustmentForm, null);
        dock =  (Infragistics.Win.UltraWinDock.UltraDockManager)obj;                  
        dock.DockAreas[0].Panes[0].Closed = true;

		tbJobNum = (Ice.Lib.Framework.EpiTextBox)csm.GetNativeControlReference("3641fc21-c767-4d05-ad24-e203b81d5c9d");
		cboAsmSeq = (Erp.UI.Controls.Combos.JobAsmSearchCombo)csm.GetNativeControlReference("14a7d417-59c4-4aa3-876d-e3b5b508ee2b");
		cboOper = (Erp.UI.Controls.Combos.JobOperSearchCombo)csm.GetNativeControlReference("edfe956b-51d3-4100-b04a-bf09c63d7219");
		tbEmployeeNum = (Ice.Lib.Framework.EpiTextBox)csm.GetNativeControlReference("8a264b4b-1119-46b1-9491-226529cb9b13");
		neLaborQty = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference("26255153-54c1-4fe1-a4f2-97f9d4c4c72c");
		neLaborHrs = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference("d88e956d-66bb-4274-a99d-4a2a807ac705");
		neBurdenHrs = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference("fc8dfa3e-e125-4fa2-b931-80f431559982");
		neLaborCost = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference("1fce4c41-2091-4b18-88ae-0f1f959d79a4");
		neBurdenCost = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference("fa2d6fe9-5c6a-4d59-a176-8e3b6d268c66");

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		this.btncosts.Click += new System.EventHandler(this.btncosts_Click);
		this.btncopy.Click += new System.EventHandler(this.btncopy_Click);

		// End Wizard Added Custom Method Calls

	ugupdatelist();

	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		this.btncosts.Click -= new System.EventHandler(this.btncosts_Click);
		this.btncopy.Click -= new System.EventHandler(this.btncopy_Click);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	
	ugupdatelist();
	
	}

	private void btncosts_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	
	ugupdatecosts();	
	
	
	}

	private void btncopy_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **

	ugupdatecosts();
	
	tbEmployeeNum.Text = "jdack";
	neLaborQty.Value = ugcosts.Rows[0].Cells["Run Qty"].Value;
	neLaborHrs.Value = ugcosts.Rows[0].Cells["Lab_Bur_Hrs"].Value;
	neBurdenHrs.Value = ugcosts.Rows[0].Cells["Lab_Bur_Hrs"].Value;
	neLaborCost.Value = ugcosts.Rows[0].Cells["Lab_Cost"].Value;
	neBurdenCost.Value = ugcosts.Rows[0].Cells["Bur_Cost"].Value;

	}
}

Appreciate any help, hints or tips! Thank you!

1 Like

I don’t think the actual field name is ‘Run Qty’. If you are pulling it from the dynamic query dataset then it is more likely something like JobHead_RunQty. You can look at teh columns in thfor the grid in customization mode and see its name.

I tried using JobHead_ProdQty, still no luck. However, I was able to get it working by using the index rather than field name\key.

neLaborQty.Value = ugcosts.Rows[0].Cells[5].Value;
neLaborHrs.Value = ugcosts.Rows[0].Cells[7].Value;
neBurdenHrs.Value = ugcosts.Rows[0].Cells[7].Value;
neLaborCost.Value = ugcosts.Rows[0].Cells[8].Value;
neBurdenCost.Value = ugcosts.Rows[0].Cells[9].Value;

This should work for me since I’m only retrieving one row of data. Love answering my own problems only moments after posting… lol. Thank you though!