Button Click - Stamp Date & User

I am not an expert here, maybe another person will chime in.

But what I am doing in the code below (or at least what I believe I am doing… might be incorrect) is grabbing the current data row for the job operation data view (which is whatever data row you currently have displayed on the UI as I understand it…) and then I am using a button click event to insert the current user ID and the time in that field. I know RMA processing button brings in the person’s full name, but that would take a little extra code and I didn’t do that.

First image shows creating the button

Then create the click event.

image

Then navigate to script editor and insert a reference to using Ice.Core; at the top. This will allow you to pull current session userID as I understand it.

// **************************************************
// Custom code for JobEntryForm
// Created: 6/23/2021 11:53:13 AM
// **************************************************

extern alias Erp_Contracts_BO_Project;
extern alias Erp_Contracts_BO_Part;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
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;
> using Ice.Core;

Then under your click event you can put the following code to insert the datestamp and user ID:

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


	/*If the comment is blank don't add a new line before the stamp, otherwise add a new line.*/	
	
	
	EpiDataView edvJobOper = ((EpiDataView)(this.oTrans.EpiDataViews["JobOper"]));
	System.Data.DataRow row = edvJobOper.CurrentDataRow;
	if(row["SchedComment"].ToString() == "")
	{
		row.BeginEdit();
		row["SchedComment"] = ((Session)oTrans.Session).UserID + " " + DateTime.Today + ":";
		row.EndEdit();
	}
	else  
	{
		row.BeginEdit();
		row["SchedComment"] =  row["SchedComment"] + Environment.NewLine + ((Session)oTrans.Session).UserID + " " + DateTime.Today + ":";
		row.EndEdit();
	}
	

	
	
}
4 Likes