Dashboard Customization mass update Date on Grid

Hello!

I have a Dashboard with an UBAQ field. I want the users to review the results and click a button to stamp today’s date on each row.

I read some posts and this is as far as I got. This code compiles successfully, but I get an object error while pressing the button and running the code.

Could someone go thru the code and give me a suggestion to fix this? I don’t know if I needed to initialize the DataView, but I did.

Thanks,

// **************************************************
// Custom code for MainController
// Created: 4/20/2020 7:39:09 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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
{
	public void InitializeCustomCode()
	{
		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		EpiDataView JobAsmCustom = ((EpiDataView)
		    (this.oTrans.EpiDataViews["V_OMS_Release_Jobs_1ViewListPanel1"]));
	}

	public void DestroyCustomCode()
	{
		this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		EpiDataView JobAsmCustom = null;	
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		EpiDataView JobAsmCustom = ((EpiDataView)
		    (this.oTrans.EpiDataViews["V_OMS_Release_Jobs_1ViewListPanel1"]));
    	                
	        foreach(DataRowView row in JobAsmCustom.dataView)
	        {
	               row["JobAsmbl_Date02"] = DateTime.Now;
	        }
	
	}

	
}

This is a panel and not an EpiDataView I believe.

Thank you, that solved part of the Puzzle. Now It lets me execute the code and stamp the date on the lines. For some reason it is not pasting on the first Row. Any ideas what I’m missing?

Thanks,

I just found that I actually need to select another line and then the Date will show up on the first line after I clicked the button. Is there any way around this? I’m not sure if I need extra code to stamp the Data on a line that is selected.

Thanks again.

That is strange. Try adding oTrans.NotifyAll() at the end of your button click code.

That did not worked. I found that if you click on the panel, outside the lines, it does update the field. is there a way to do this by code? I don’t know if the right term is changing the focus to the panel instead of the line.

Thanks for looking into this.

I’m just missing a very simple thing, hopefully someone can assist. So I manage to run the code, and it stamps the date on each row. At the end it changes the focus to the grid.

What I’m missing is a code that simulates a “tab” keystroke or a command that moves to the next row/line in the Grid. Is there also a code that simulates pressing the “save” icon from the toolbar to update the data to the server?

Thanks


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

	    EpiDataView edvV_OMS_Release_Jobs_1View1 = ((EpiDataView)(this.oTrans.EpiDataViews["V_OMS_Release_Jobs_1View1"]));
		EpiUltraGrid eugV_OMS_Release_Jobs_1View1 = (EpiUltraGrid)csm.GetNativeControlReference("0297fc5c-4168-456b-a1c8-ef89b3805159");
	    	                
		foreach(DataRowView row in edvV_OMS_Release_Jobs_1View1.dataView)
		
        {
	        row["JobAsmbl_Date02"] = DateTime.Now;
        }

		eugV_OMS_Release_Jobs_1View1.Focus();

	}

I managed to “tab” and move to the next line on the grid by simulating a keystroke using SendKeys.Send("{TAB}"), Then if I manually click Save all the lines are saved correctly.

I still want the code to save automatically at the end. If I add oTrans.Update (); to the last line, it executes the save comand while it is still moving to the next line.

Is there any code that instead of SendKeys.Send("{TAB}"); that will make sure I’m on the next line before saving?

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

	    EpiDataView edvV_OMS_Release_Jobs_1View1 = ((EpiDataView)(this.oTrans.EpiDataViews["V_OMS_Release_Jobs_1View1"]));
		EpiUltraGrid eugV_OMS_Release_Jobs_1View1 = (EpiUltraGrid)csm.GetNativeControlReference("0297fc5c-4168-456b-a1c8-ef89b3805159");
	    	                
		foreach(DataRowView row in edvV_OMS_Release_Jobs_1View1.dataView)
		
        {
	        row["JobAsmbl_Date02"] = DateTime.Now;
        }

		eugV_OMS_Release_Jobs_1View1.Focus();

		SendKeys.Send("{TAB}");

		//oTrans.Update ();

		//MessageBox.Show ("Message Goes Here");

		
	}

Could you simply add a BeginEdit/EndEdit and then save at the end?

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
	EpiDataView edvV_OMS_Release_Jobs_1View1 = oTrans.Factory("V_OMS_Release_Jobs_1View1");	    	                
	foreach(DataRowView row in edvV_OMS_Release_Jobs_1View1.dataView)
	{
		row.BeginEdit();
		row["JobAsmbl_Date02"] = DateTime.Now;
		row.EndEdit();
	}
	oTrans.Update();
	
}

Thank you! works great!!