I am currently trying to develop in a UDEntry screen. I have the layout finished but I need to know how to save and load the dataview data to its corresponding UD table using its adapter.
I am using UD102Entry and using UD102Adapter. I want to click save once and have all the data save immediately. My current roadblock is saving and loading.
Is there something I missed?
What I currently have:
// **************************************************
// Custom code for UD102Form
// **************************************************
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;
using System.Drawing;
using System.Collections.Generic;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinToolbars;
public class Profiler
{
private List<string> sectionList = new List<string>();
private List<long> timestampList = new List<long>();
private Dictionary<string, long> profilingDict = new Dictionary<string, long>();
private string profilingSection = "";
public bool profilingEnabled = false;
public bool loggingEnabled = false;
public void startSection(string sectionName)
{
if (loggingEnabled) MessageBox.Show(sectionName);
if (profilingEnabled)
{
if (profilingSection.Length > 0) profilingSection += ".";
profilingSection += sectionName;
sectionList.Add(sectionName);
timestampList.Add(Convert.ToInt64(DateTime.Now.Ticks));
}
}
public void endSection()
{
if (profilingEnabled)
{
long nt = DateTime.Now.Ticks;
long t = Convert.ToInt64(timestampList.Remove(timestampList.Count - 1));
long n = nt - t;
if (profilingDict.ContainsKey(profilingSection)) profilingDict.Add(profilingSection, Convert.ToInt64(profilingDict[profilingSection]));
else profilingDict.Add(profilingSection, Convert.ToInt64(n));
}
}
public void startEndSection(string sectionName)
{
startSection(sectionName);
endSection();
}
public void endStartSection(string sectionName)
{
endSection();
startSection(sectionName);
}
public void clearProfiling()
{
profilingDict.Clear();
profilingSection = "";
sectionList.Clear();
}
}
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 **\
private Profiler profiler = new Profiler();
private Control mainPanel;
private Control epiTreeViewPanel;
private Infragistics.Win.UltraWinToolbars.ButtonTool DebugTool;
private EpiDataView edvBooking;
private DataTable dtBooking;
private EpiDataView edvLoadHeader;
private DataTable dtLoadHeader;
private UD102Adapter adapterUD102;
private int UD102FormWidth;
private int UD102FormHeight;
private int mainPanelWidth;
private int mainPanelHeight;
private int epiTreeViewPanelWidth;
private int epiTreeViewPanelHeight;
public void InitializeCustomCode()
{
this.profiler.profilingEnabled = false;
this.profiler.loggingEnabled = false;
create_dtBooking();
this.edvBooking = new EpiDataView();
this.edvBooking.dataView = this.dtBooking.DefaultView;
this.edvBooking.AddEnabled = true;
this.edvBooking.AddText = "New Booking";
if (!(this.oTrans.EpiDataViews.ContainsKey("edvBooking")))
{
this.oTrans.Add("edvBooking",this.edvBooking);
this.edvBooking.EpiViewNotification += new EpiViewNotification(this.edvBooking_EpiViewNotification);
this.dtBooking.ColumnChanged += new DataColumnChangeEventHandler(this.dtBooking_AfterFieldChange);
}
create_dtLoadHeader();
this.edvLoadHeader = new EpiDataView();
this.edvLoadHeader.dataView = this.dtLoadHeader.DefaultView;
if (!(this.oTrans.EpiDataViews.ContainsKey("edvLoadHeader")))
{
this.oTrans.Add("edvLoadHeader",this.edvLoadHeader);
}
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.UD102Form.Closing += new System.ComponentModel.CancelEventHandler(this.UD102Form_Closing);
this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
this.btnBooking.Click += new System.EventHandler(this.btnBooking_Click);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
this.mainPanel = csm.GetNativeControlReference("65ad0f2d-e5e4-4f95-b7cf-52342f6058f6");
this.epiTreeViewPanel = csm.GetNativeControlReference("e7aa22cd-8f48-40f0-8355-e0c096644cab");
this.adapterUD102 = new UD102Adapter(this.oTrans);
this.adapterUD102.BOConnect();
SetExtendedProperties();
UD102Form.Resize += new System.EventHandler(this.UD102Form_Resize);
}
public void DestroyCustomCode()
{
UD102Form.Resize -= new System.EventHandler(this.UD102Form_Resize);
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.edvBooking.EpiViewNotification -= new EpiViewNotification(this.edvBooking_EpiViewNotification);
this.dtBooking.ColumnChanged -= new DataColumnChangeEventHandler(this.dtBooking_AfterFieldChange);
this.UD102Form.Closing -= new System.ComponentModel.CancelEventHandler(this.UD102Form_Closing);
this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
this.btnBooking.Click -= new System.EventHandler(this.btnBooking_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
this.profiler.clearProfiling();
this.mainPanel = null;
this.epiTreeViewPanel = null;
this.edvBooking = null;
this.dtBooking = null;
this.edvLoadHeader = null;
this.dtLoadHeader = null;
this.adapterUD102 = null;
// End Custom Code Disposal
}
private void SetExtendedProperties()
{
// Begin Wizard Added EpiDataView Initialization
// End Wizard Added EpiDataView Initialization
// Begin Wizard Added Conditional Block
if (this.edvBooking.dataView.Table.Columns.Contains("EstFreight"))
{
this.edvBooking.dataView.Table.Columns["EstFreight"].ExtendedProperties["Format"] = ">>,>>>.99";
}
if (this.edvBooking.dataView.Table.Columns.Contains("EstForward"))
{
this.edvBooking.dataView.Table.Columns["EstForward"].ExtendedProperties["Format"] = ">>,>>>.99";
}
if (this.edvBooking.dataView.Table.Columns.Contains("EstDryage"))
{
this.edvBooking.dataView.Table.Columns["EstDryage"].ExtendedProperties["Format"] = ">>,>>>.99";
}
if (this.edvBooking.dataView.Table.Columns.Contains("ActFreight"))
{
this.edvBooking.dataView.Table.Columns["ActFreight"].ExtendedProperties["Format"] = ">>,>>>.99";
}
if (this.edvBooking.dataView.Table.Columns.Contains("ActForward"))
{
this.edvBooking.dataView.Table.Columns["ActForward"].ExtendedProperties["Format"] = ">>,>>>.99";
}
if (this.edvBooking.dataView.Table.Columns.Contains("ActDryage"))
{
this.edvBooking.dataView.Table.Columns["ActDryage"].ExtendedProperties["Format"] = ">>,>>>.99";
}
// End Wizard Added Conditional Block
this.eugLoads.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
this.eugLoads.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
this.eugLoadsPackPort.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
this.eugLoadsPackPort.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
this.eugLoadsAdditional.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
this.eugLoadsAdditional.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
this.lblPortLoad.TextAlign = ContentAlignment.MiddleCenter;
this.lblVia.TextAlign = ContentAlignment.MiddleCenter;
this.lblOnCarriage.TextAlign = ContentAlignment.MiddleCenter;
this.lblST.TextAlign = ContentAlignment.MiddleCenter;
this.lblPortDsch.TextAlign = ContentAlignment.MiddleCenter;
}
private void UD102Form_Load(object sender, EventArgs args)
{
profiler.startSection("UD102Form_Load");
// Actions Menu tools
this.baseToolbarsManager.Tools["EpiAddNewnewParent"].SharedProps.Enabled = false;
this.baseToolbarsManager.Tools["EpiAddNewnewParent"].SharedProps.Visible = false;
this.baseToolbarsManager.Tools["EpiAddNewnewChild"].SharedProps.Enabled = false;
this.baseToolbarsManager.Tools["EpiAddNewnewChild"].SharedProps.Visible = false;
this.DebugTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("DebugTool");
this.DebugTool.SharedProps.Caption = @"Toggle Debug";
this.DebugTool.SharedProps.Enabled = true;
this.DebugTool.SharedProps.Visible = true;
baseToolbarsManager.Tools.Add(this.DebugTool);
baseToolbarsManager.Tools["DebugTool"].SharedProps.Shortcut = (Shortcut)Shortcut.F11;
((Infragistics.Win.UltraWinToolbars.PopupMenuTool)baseToolbarsManager.Tools["ActionsMenu"]).Tools.Add(this.DebugTool);
this.DebugTool.SharedProps.Caption = @"Toggle Debug | State: " + (profiler.profilingEnabled ? @"On" : @"Off");
Infragistics.Win.UltraWinToolbars.ButtonTool RestoreDefaultScreenSizeTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("RestoreDefaultScreenSizeTool");
RestoreDefaultScreenSizeTool.SharedProps.Caption = @"Restore Default Screen Size";
RestoreDefaultScreenSizeTool.SharedProps.Enabled = true;
RestoreDefaultScreenSizeTool.SharedProps.Visible = true;
baseToolbarsManager.Tools.Add(RestoreDefaultScreenSizeTool);
baseToolbarsManager.Tools["RestoreDefaultScreenSizeTool"].SharedProps.Shortcut = (Shortcut)Shortcut.F5;
((Infragistics.Win.UltraWinToolbars.PopupMenuTool)baseToolbarsManager.Tools["ActionsMenu"]).Tools.Add(RestoreDefaultScreenSizeTool);
// move the form into the center of the user's screen
UD102Form.Location = new Point((Screen.PrimaryScreen.Bounds.Size.Width - UD102Form.Size.Width) / 2, (Screen.PrimaryScreen.Bounds.Size.Height - UD102Form.Size.Height) / 2);
saveDimensions();
profiler.endSection();
}
private void UD102Form_Closing(object sender, System.ComponentModel.CancelEventArgs args)
{
profiler.startSection("UD102Form_Closing");
resetDimensions();
profiler.endSection();
}
private void saveDimensions()
{
profiler.startSection("saveDimensions");
this.UD102FormWidth = UD102Form.Width;
this.UD102FormHeight = UD102Form.Height;
this.mainPanelWidth = this.mainPanel.Width;
this.mainPanelHeight = this.mainPanel.Height;
this.epiTreeViewPanelWidth = this.epiTreeViewPanel.Width;
this.epiTreeViewPanelHeight = this.epiTreeViewPanel.Height;
profiler.endSection();
}
private void resetDimensions()
{
profiler.startSection("resetDimensions");
UD102Form.Width = UD102Form.Width = 1050;
UD102Form.Height = UD102Form.Height = 600;
this.mainPanel.Width = this.mainPanelWidth;
this.mainPanel.Height = this.mainPanelHeight;
this.epiTreeViewPanel.Width = this.epiTreeViewPanelWidth;
this.epiTreeViewPanel.Height = this.epiTreeViewPanelHeight;
profiler.endSection();
}
private void UD102Form_Resize(object sender, EventArgs args)
{
profiler.startSection("UD102Form_Resize");
bool b = false;
if (b)
{
this.grpBooking1.Location = new Point(5, 50);
this.grpBooking1.Width = 789;
this.grpBooking1.Height = 180;
UD102Form.Width = this.epiTreeViewPanel.Width + 10 + grpBooking1.Width + 10;
}
profiler.endSection();
}
private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
profiler.startSection("baseToolbarsManager_ToolClick");
// MessageBox.Show(args.Tool.Key);
switch (args.Tool.Key)
{
case "DebugTool":
profiler.startSection("DebugTool");
profiler.profilingEnabled = !profiler.profilingEnabled;
profiler.loggingEnabled = !profiler.loggingEnabled;
this.DebugTool.SharedProps.Caption = @"Toggle Debug | State: " + (profiler.profilingEnabled ? @"On" : @"Off");
profiler.endSection();
break;
case "RestoreDefaultScreenSizeTool":
profiler.startSection("RestoreDefaultScreenSizeTool");
profiler.endSection();
break;
case "NewMenuTool":
case "EpiAddNewNew Booking":
profiler.startSection("EpiAddNewNew Booking");
clearScreen(); // ?
createNewBooking();
this.edvBooking.Notify(new EpiNotifyArgs(this.oTrans, 0, 0));
profiler.endSection();
break;
case "ClearTool":
profiler.startSection("ClearTool");
clearScreen();
profiler.endSection();
break;
case "SaveMenuTool":
case "SaveTool":
profiler.startSection("SaveMenuTool/SaveTool");
bool rowLoaded = this.dtBooking.Rows.Count > 0;
if (rowLoaded)
{
profiler.startSection("Trying to save booking.");
trySaveBooking();
profiler.endSection();
}
profiler.endSection();
break;
case "RefreshTool":
profiler.startSection("RefreshTool");
// MessageBox.Show("Refresh functionality does not work on this screen.");
oTrans.Refresh();
profiler.endSection();
break;
case "CustomizeTool":
profiler.startSection("CustomizeTool");
profiler.endSection();
break;
default:
break;
}
profiler.endSection();
}
private void createNewBooking()
{
DataRow newRow = this.dtBooking.NewRow();
newRow["EstFreight"] = 0m;
newRow["EstForward"] = 0m;
newRow["EstDryage"] = 0m;
newRow["ActFreight"] = 0m;
newRow["ActForward"] = 0m;
newRow["ActDryage"] = 0m;
this.dtBooking.Rows.Add(newRow);
}
private void trySaveBooking()
{
using (oTrans.PushDisposableStatusText(@"Saving booking details...", true))
{
try
{
MessageBox.Show("Test1: " + this.adapterUD102.UD102Data.UD102.Rows.Count);
// start fresh
this.adapterUD102.ClearData();
// get the booking number from screen
string bookingNum = Convert.ToString(this.edvBooking.dataView[this.edvBooking.Row]["Booking"]);
// search for existing records
string whereClause = @"Key1 = '" + bookingNum + @"'";
System.Collections.Hashtable whereClauses = new System.Collections.Hashtable(1);
whereClauses.Add("UD102", whereClause);
SearchOptions opts = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
DialogResult dlgResult = this.adapterUD102.InvokeSearch(opts);
MessageBox.Show("Test2: " + this.adapterUD102.UD102Data.UD102.Rows.Count);
if (this.adapterUD102.UD102Data.UD102.Rows.Count == 1)
{ // if a single booking record exists
MessageBox.Show("Top");
profiler.startSection("this.adapterUD102.UD102Data.UD102.Rows.Count == 1");
// start fresh
this.adapterUD102.UD102Data.Clear();
// get booking numbers exist
bool result = this.adapterUD102.GetByID(bookingNum, string.Empty, string.Empty, string.Empty, string.Empty);
MessageBox.Show("Test3: " + this.adapterUD102.UD102Data.UD102.Rows.Count);
if (this.adapterUD102.UD102Data.UD102.Rows.Count > 0)
{ // if records exist with booking number
profiler.startSection("this.adapterUD102.UD102Data.UD102.Rows.Count > 0");
profiler.startSection("Concatenating booking values into a tilda deliminated string.");
string booking = string.Empty;
foreach (DataColumn c in this.dtBooking.Columns)
{
booking += Convert.ToString(this.dtBooking.Rows[0][c.ColumnName]).Replace(Environment.NewLine, "`") + @"~"; // newline char is in the address column
}
profiler.endSection();
booking = booking.Remove(booking.Length - 2); // remove the last "~" + the extra for SysRowID
profiler.startSection("Editing UD102 adapter row[0] column[\"Character01\"].");
DataRow dr = this.adapterUD102.UD102Data.UD102.Rows[0];
dr.BeginEdit();
MessageBox.Show("Test4: " + dr["Character01"]);
MessageBox.Show("Test5: " + booking);
dr["Character01"] = booking;
dr.EndEdit();
profiler.endStartSection("Updating UD102 adapter");
result = adapterUD102.Update();
profiler.endSection();
profiler.endSection();
}
profiler.endSection();
}
else
{
MessageBox.Show("Bottom");
bool result = false;
System.EventArgs noArgs = new System.EventArgs();
// btnClearBooking_Click(this.oTrans, noArgs); // make sure the booking is cleared
string newBooking = string.Empty;
newBooking = bookingNum;
MessageBox.Show(newBooking);
this.adapterUD102.UD102Data.Clear();
result = this.adapterUD102.GetaNewUD102();
DataRow ud102Row = adapterUD102.UD102Data.UD102.Rows[0];
ud102Row.BeginEdit();
ud102Row["Key1"] = newBooking;
ud102Row.EndEdit();
result = this.adapterUD102.Update();
}
}
catch (System.Exception ex)
{
MessageBox.Show("Save Tool: " + ex.Message);
}
}
}
private void create_dtBooking()
{
profiler.startSection("create_dtBooking");
this.dtBooking = new DataTable();
this.dtBooking.Columns.Add("Booking",typeof(string));
this.dtBooking.Columns.Add("Forwarder",typeof(string));
this.dtBooking.Columns.Add("Steamship",typeof(string));
this.dtBooking.Columns.Add("Vessel",typeof(string));
this.dtBooking.Columns.Add("FreightLine",typeof(string));
this.dtBooking.Columns.Add("PointOfOrigin",typeof(string));
this.dtBooking.Columns.Add("SalesCompany",typeof(string));
this.dtBooking.Columns.Add("FreightTerms",typeof(string));
this.dtBooking.Columns.Add("EstDeparture",typeof(DateTime));
this.dtBooking.Columns.Add("EstArrival",typeof(DateTime));
this.dtBooking.Columns.Add("Voyage",typeof(string));
this.dtBooking.Columns.Add("Railroad",typeof(string));
this.dtBooking.Columns.Add("Containers",typeof(string));
this.dtBooking.Columns.Add("EstFreight",typeof(decimal));
this.dtBooking.Columns.Add("EstForward",typeof(decimal));
this.dtBooking.Columns.Add("EstDryage",typeof(decimal));
this.dtBooking.Columns.Add("ActFreight",typeof(decimal));
this.dtBooking.Columns.Add("ActForward",typeof(decimal));
this.dtBooking.Columns.Add("ActDryage",typeof(decimal));
this.dtBooking.Columns.Add("SoldToName",typeof(string));
this.dtBooking.Columns.Add("Country",typeof(string));
this.dtBooking.Columns.Add("PONumbers",typeof(string));
this.dtBooking.Columns.Add("MadeInUSA",typeof(string));
this.dtBooking.Columns.Add("Description",typeof(string));
this.dtBooking.Columns.Add("PortLoadCity",typeof(string));
this.dtBooking.Columns.Add("PortLoadState",typeof(string));
this.dtBooking.Columns.Add("ViaCity",typeof(string));
this.dtBooking.Columns.Add("ViaState",typeof(string));
this.dtBooking.Columns.Add("OnCity",typeof(string));
this.dtBooking.Columns.Add("OnCountry",typeof(string));
this.dtBooking.Columns.Add("STName",typeof(string));
this.dtBooking.Columns.Add("STAddress",typeof(string));
this.dtBooking.Columns.Add("STCity",typeof(string));
this.dtBooking.Columns.Add("STState",typeof(string));
this.dtBooking.Columns.Add("STCountry",typeof(string));
this.dtBooking.Columns.Add("PortDschCity",typeof(string));
this.dtBooking.Columns.Add("PortDschCountry",typeof(string));
this.dtBooking.Columns.Add("EarlyReturn",typeof(DateTime));
this.dtBooking.Columns.Add("PickUpEmpty",typeof(string));
this.dtBooking.Columns.Add("DispatchSent",typeof(DateTime));
this.dtBooking.Columns.Add("MasterInstSent",typeof(DateTime));
this.dtBooking.Columns.Add("AESUpdated",typeof(DateTime));
this.dtBooking.Columns.Add("OBLProofed",typeof(DateTime));
this.dtBooking.Columns.Add("RampCutOff",typeof(DateTime));
this.dtBooking.Columns.Add("ITNDocCutOff",typeof(DateTime));
this.dtBooking.Columns.Add("AESField",typeof(DateTime)); // ?
this.dtBooking.Columns.Add("DocSent",typeof(DateTime));
this.dtBooking.Columns.Add("OFBToAcct",typeof(DateTime));
this.dtBooking.Columns.Add("MasterBOL",typeof(string));
this.dtBooking.Columns.Add("ServiceContract",typeof(string));
this.dtBooking.Columns.Add("ShipmentNbr",typeof(string));
this.dtBooking.Columns.Add("VGM",typeof(DateTime)); // ?
this.dtBooking.Columns.Add("SysRowID",typeof(Guid)); // ?
profiler.endSection();
}
private void create_dtLoadHeader()
{ // keep in sync with UD101 Load Builder / Header
profiler.startSection("create_dtLoadHeader");
this.dtLoadHeader = new DataTable();
this.dtLoadHeader.Columns.Add("Load",typeof(string));
this.dtLoadHeader.Columns.Add("ShipToInfo",typeof(string));
this.dtLoadHeader.Columns.Add("ShipToZip",typeof(string));
this.dtLoadHeader.Columns.Add("ShipFromZip",typeof(string));
this.dtLoadHeader.Columns.Add("BOLOverride",typeof(bool));
this.dtLoadHeader.Columns.Add("BOContact",typeof(string));
this.dtLoadHeader.Columns.Add("BOName",typeof(string));
this.dtLoadHeader.Columns.Add("BOAddr1",typeof(string));
this.dtLoadHeader.Columns.Add("BOAddr2",typeof(string));
this.dtLoadHeader.Columns.Add("BOAddr3",typeof(string));
this.dtLoadHeader.Columns.Add("BOCity",typeof(string));
this.dtLoadHeader.Columns.Add("BOState",typeof(string));
this.dtLoadHeader.Columns.Add("BOZip",typeof(string));
this.dtLoadHeader.Columns.Add("BOCountry",typeof(string));
this.dtLoadHeader.Columns.Add("BOCountryNum",typeof(int));
this.dtLoadHeader.Columns.Add("ShipVia",typeof(string));
this.dtLoadHeader.Columns.Add("ShipViaCode",typeof(string));
this.dtLoadHeader.Columns.Add("Carrier",typeof(string));
this.dtLoadHeader.Columns.Add("Broker",typeof(string));
this.dtLoadHeader.Columns.Add("ShipBy",typeof(DateTime));
this.dtLoadHeader.Columns.Add("DeliverBy",typeof(DateTime));
this.dtLoadHeader.Columns.Add("TransitDays",typeof(int));
this.dtLoadHeader.Columns.Add("FreightTerms",typeof(string));
this.dtLoadHeader.Columns.Add("FreightTermsCode",typeof(string));
this.dtLoadHeader.Columns.Add("CustomerFreight",typeof(decimal));
this.dtLoadHeader.Columns.Add("TotalFreight",typeof(decimal));
this.dtLoadHeader.Columns.Add("BOLNumber",typeof(string));
this.dtLoadHeader.Columns.Add("FreightClass",typeof(string));
this.dtLoadHeader.Columns.Add("PRONumber",typeof(string));
this.dtLoadHeader.Columns.Add("ShipmentType",typeof(string));
this.dtLoadHeader.Columns.Add("ShipmentTypeCode",typeof(string));
this.dtLoadHeader.Columns.Add("Weight",typeof(decimal));
this.dtLoadHeader.Columns.Add("UnitCount",typeof(int));
this.dtLoadHeader.Columns.Add("Parts",typeof(string));
this.dtLoadHeader.Columns.Add("ShipFromSite",typeof(string));
this.dtLoadHeader.Columns.Add("Export",typeof(string));
this.dtLoadHeader.Columns.Add("ExportFrom",typeof(string));
this.dtLoadHeader.Columns.Add("ContainerSize",typeof(string));
this.dtLoadHeader.Columns.Add("Ref1",typeof(string));
this.dtLoadHeader.Columns.Add("Ref2",typeof(string));
this.dtLoadHeader.Columns.Add("Ref3",typeof(string));
this.dtLoadHeader.Columns.Add("TareWeight",typeof(decimal));
this.dtLoadHeader.Columns.Add("TrailerSize",typeof(int)); // actual label is Trailer Space
this.dtLoadHeader.Columns.Add("BookingNumber",typeof(string));
this.dtLoadHeader.Columns.Add("SealNumber",typeof(string));
this.dtLoadHeader.Columns.Add("ContainerNumber",typeof(string));
this.dtLoadHeader.Columns.Add("DockComment",typeof(string));
this.dtLoadHeader.Columns.Add("TrafficComment",typeof(string));
this.dtLoadHeader.Columns.Add("CarrierComment",typeof(string));
this.dtLoadHeader.Columns.Add("MarkForComment",typeof(string));
this.dtLoadHeader.Columns.Add("SysRowID",typeof(Guid));
profiler.endSection();
}
private void clearScreen()
{
profiler.startSection("clearScreen");
System.EventArgs args = new System.EventArgs(); // dummy up some blank args
btnClearBooking_Click(this.oTrans, args);
profiler.endSection();
}
private void btnClearBooking_Click(object sender, System.EventArgs args)
{
profiler.startSection("btnClearBooking_Click");
this.dtBooking.Clear();
this.edvBooking.Notify(new EpiNotifyArgs(this.oTrans, 0, 0));
this.txtBookingNum.Value = string.Empty;
this.txtKeyFieldPackPort.Value = string.Empty;
this.txtKeyFieldAdditional.Value = string.Empty;
this.txtBookingNum.Text = this.txtKeyFieldPackPort.Text = this.txtKeyFieldAdditional.Text = string.Empty;
profiler.endSection();
}
private void btnBooking_Click(object sender, System.EventArgs args)
{
profiler.startSection("btnBooking_Click");
System.EventArgs noArgs = new System.EventArgs();
try
{
bool recSelected;
string whereClause = @"";
System.Data.DataSet dsUD102Adapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "UD102Adapter", out recSelected, true, whereClause);
if (recSelected)
{
btnClearBooking_Click(this.oTrans, noArgs);
System.Data.DataRow adapterRow = dsUD102Adapter.Tables[0].Rows[0];
string booking = Convert.ToString(adapterRow["Key1"]);
this.adapterUD102.ClearData();
bool result = retrieveBooking(booking);
} // end if recSelected
else
{
btnClearBooking_Click(this.oTrans, noArgs);
}
}
catch (System.Exception ex)
{
MessageBox.Show(@"btnBooking_Click :" + ex.Message);
btnClearBooking_Click(this.oTrans, noArgs);
}
profiler.endSection();
}
private bool retrieveBooking(string booking)
{
profiler.startSection("retrieveBooking");
if (string.IsNullOrEmpty(booking)) return false;
using (oTrans.PushDisposableStatusText(@"Retrieving Booking data...", true))
{
try
{
this.adapterUD102.ClearData();
bool result = this.adapterUD102.GetByID(booking, string.Empty, string.Empty, string.Empty, string.Empty);
if (this.adapterUD102.UD102Data.UD102.Rows.Count == 1)
{
profiler.startSection("this.adapterUD102.UD102Data.UD102.Rows.Count == 1");
if (string.IsNullOrEmpty(Convert.ToString(this.adapterUD102.UD102Data.UD102.Rows[0]["Character01"])))
{
profiler.startSection("string.IsNullOrEmpty(Convert.ToString(this.adapterUD102.UD102Data.UD102.Rows[0][\"Character01\"]))");
DataRow newRow = this.dtBooking.NewRow();
for (int i = 0; i < this.dtBooking.Columns.Count; i++)
{
switch (Convert.ToString(this.dtBooking.Columns[i].DataType))
{
case "System.DateTime":
newRow[i] = default(DateTime);
break;
case "System.Decimal":
newRow[i] = default(decimal);
break;
case "System.Guid": // skip the Guid
break;
case "System.Int32":
newRow[i] = default(int);
break;
case "System.String":
newRow[i] = default(string);
break;
default:
break;
}
}
newRow["Booking"] = booking;
this.dtBooking.Rows.Add(newRow);
profiler.endSection();
}
else // Character01 isn't empty
{
profiler.startSection("Character01 isn't empty");
DataRow newRow = this.dtBooking.NewRow();
string[] bookingData = Convert.ToString(this.adapterUD102.UD102Data.UD102[0]["Character01"]).Split('~');
for (int i = 0; i < this.dtBooking.Columns.Count && i < bookingData.Length; i++)
{
switch (Convert.ToString(this.dtBooking.Columns[i].DataType))
{
case "System.DateTime":
if (!string.IsNullOrEmpty(bookingData[i]))
{
if (DateTime.Compare(default(DateTime), Convert.ToDateTime(bookingData[i])) < 0) newRow[i] = Convert.ToDateTime(bookingData[i]);
}
break;
case "System.Decimal":
if (string.IsNullOrEmpty(bookingData[i])) newRow[i] = 0m;
else newRow[i] = Convert.ToDecimal(bookingData[i]);
break;
case "System.Guid": // skip the Guid
break;
case "System.Int32":
if (string.IsNullOrEmpty(bookingData[i])) newRow[i] = 0;
else newRow[i] = Convert.ToInt32(bookingData[i]);
break;
case "System.String":
if (Convert.ToString(bookingData[i]).Contains("`")) newRow[i] = Convert.ToString(bookingData[i]).Replace("`", Environment.NewLine);
else Convert.ToString(bookingData[i]);
break;
default:
break;
}
}
this.dtBooking.Rows.Add(newRow);
profiler.endSection();
} // end if/else character01
this.edvBooking.Notify(new EpiNotifyArgs(this.oTrans, this.dtBooking.Rows.Count - 1, 0));
profiler.endSection();
}
txtBookingNum.Text = booking;
}
catch (System.Exception ex)
{
MessageBox.Show(@"Retrieve booking: " + ex.Message);
System.EventArgs noArgs = new System.EventArgs();
btnClearBooking_Click(this.oTrans, noArgs);
profiler.endSection();
return false;
}
}
profiler.endSection();
return true;
}
private void edvBooking_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
profiler.startSection("edvBooking_EpiViewNotification");
profiler.endSection();
}
private void dtBooking_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
profiler.startSection("dtBooking_AfterFieldChange");
profiler.endSection();
}
}
Apparently it’s saving only one box at a time. So if you update 2 boxes you would save twice for all changes to be saved in UD102 table.
Current screen layout. I have all bindings set and the search button is not the default search on UDEntry. It is an EpiButton with a click event associated with it.