Issues after clear
unknown
csharp
4 years ago
8.4 kB
8
Indexable
// **************************************************
// Custom code for VendorForm
// Created: 3/17/2022 3:39:43 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.UI;
using Ice.Lib;
using Ice.BO;
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.Lib.Broadcast;
using System.Reflection;
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 **
BAQDataView baqViewDateRange;
string pubBinding;
IPublisher pub;
public static bool IsDateMin(string input)
{
DateTime temp;
return DateTime.TryParse(input, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out temp) &&
temp.Hour == 0 &&
temp.Minute == 0 &&
temp.Second == 0 &&
temp.Millisecond == 0 &&
temp > DateTime.MinValue;
}
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnAddDates.Click += new System.EventHandler(this.btnAddDates_Click);
this.ugInvRange.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ugInvRange_InitializeLayout);
this.txtVendID.TextChanged += new System.EventHandler(this.txtVendID_TextChanged);
this.dtStartDate.AfterExitEditMode += new System.EventHandler(this.dtStartDate_AfterExitEditMode);
this.dtEndDate.AfterExitEditMode += new System.EventHandler(this.dtEndDate_AfterExitEditMode);
//this.VendorForm.AfterToolClick += new Ice.Lib.Framework.AfterToolClickEventHandler(this.VendorForm_AfterToolClick);
CreateDateRangeBAQView();
// End Wizard Added Custom Method Calls
}
public void CreateDateRangeBAQView()
{
baqViewDateRange = new BAQDataView("JBIS-SupplierListQry");
oTrans.Add("JBIS-SupplierListQry",baqViewDateRange);
string pubBinding = "VendorDetail.VendorID";
IPublisher pub = oTrans.GetPublisher(pubBinding);
if(pub==null || string.IsNullOrEmpty(txtVendID.Text))
{ //check if the pub exists
oTrans.PublishColumnChange(pubBinding, "vendorNumPub");
pub = oTrans.GetPublisher(pubBinding);
MessageBox.Show("Clearing pubBinding");
}
if(pub != null) {
baqViewDateRange.SubscribeToPublisher(pub.PublishName, "Vendor_VendorID");
}
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.btnAddDates.Click -= new System.EventHandler(this.btnAddDates_Click);
this.ugInvRange.InitializeLayout -= new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ugInvRange_InitializeLayout);
this.txtVendID.TextChanged -= new System.EventHandler(this.txtVendID_TextChanged);
this.dtEndDate.AfterExitEditMode -= new System.EventHandler(this.dtEndDate_AfterExitEditMode);
this.dtStartDate.AfterExitEditMode -= new System.EventHandler(this.dtStartDate_AfterExitEditMode);
//this.VendorForm.AfterToolClick -= new Ice.Lib.Framework.AfterToolClickEventHandler(this.VendorForm_AfterToolClick);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void RefreshBAQDataView(BAQDataView iBaqView)
{
MethodInfo mi = iBaqView.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(iBaqView, new object[]{ true });
}
private void ClearBAQDataView(BAQDataView iBaqView)
{
FieldInfo dqAdapter = iBaqView.GetType().GetField("dqAdapter", BindingFlags.Instance | BindingFlags.NonPublic);
Ice.Adapters.DynamicQueryAdapter dsQ = (Ice.Adapters.DynamicQueryAdapter)dqAdapter.GetValue(iBaqView);
dsQ.QueryResults.Clear();
}
private void btnAddDates_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (string.IsNullOrEmpty(txtVendID.Text))
{
MessageBox.Show("Please enter customer");
} else
{
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("JBIS-SuppInvLkUp");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("ConfirmSupplier", txtVendID.Text, "nvarchar",false, Guid.NewGuid(),"A");
qeds.ExecutionParameter.AddExecutionParameterRow("FromDate", dtStartDate.Text, "date",false, Guid.NewGuid(),"d");
qeds.ExecutionParameter.AddExecutionParameterRow("ToDate", dtEndDate.Text, "date",false, Guid.NewGuid(),"d");
dqa.ExecuteByID("JBIS-SuppInvLkUp",qeds);
MessageBox.Show("about to show results");
ugInvRange.DataSource = dqa.QueryResults.Tables["Results"];
}
}
private void ugInvRange_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs args)
{
// ** Place Event Handling Code Here **
args.Layout.Bands[0].Columns[3].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[4].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[7].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[10].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[11].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[12].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[27].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[40].Format = "###,###,##0.00";
args.Layout.Bands[0].Columns[41].Format = "###,###,##0.00";
}
private void txtVendID_TextChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (string.IsNullOrEmpty(txtVendID.Text))
{
ugInvRange.DataSource = null;
dtStartDate.Text = "12/31/2021";
dtEndDate.Text = "12/31/2021";
txtVendID.Text = "";
ClearBAQDataView(baqViewDateRange);
string pubBinding = "VendorDetail.VendorID";
IPublisher pub = oTrans.GetPublisher(pubBinding);
oTrans.PublishColumnChange(pubBinding, "vendorNumPub");
pub = oTrans.GetPublisher(pubBinding);
MessageBox.Show("Clearing pubBinding after ttxtvendid textchanged");
}
}
private void dtStartDate_AfterExitEditMode(object sender, System.EventArgs args)
{
if (IsDateMin(dtStartDate.Text))
{
DateTime? endDate = DateTime.Parse(dtEndDate.Text);
DateTime? startDate = DateTime.Parse(dtStartDate.Text);
//string eD = endDate.ToString();
//string sD = startDate.ToString();
// ** Place Event Handling Code Here **
if(DateTime.Parse(dtStartDate.Text)>(DateTime.Parse(dtEndDate.Text)))
{
MessageBox.Show("Start date is greater than end date, please fix this before continuing");
startDate = endDate.Value.AddDays(-1);
string startDatePlusOne = startDate.ToString();
dtStartDate.Text = startDatePlusOne;
}
}
else
{
MessageBox.Show("please enter an start date");
DateTime? endDate = DateTime.Parse(dtEndDate.Text);
DateTime? startDate;
startDate = endDate.Value.AddDays(-1);
string startDatePlusOne = startDate.ToString();
dtStartDate.Text = startDatePlusOne;
}
}
private void dtEndDate_AfterExitEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (IsDateMin(dtEndDate.Text))
{
DateTime? endDate = DateTime.Parse(dtEndDate.Text);
DateTime? startDate = DateTime.Parse(dtStartDate.Text);
endDate = endDate.Value.AddDays(1);
if(DateTime.Parse(dtEndDate.Text)<(DateTime.Parse(dtStartDate.Text)))
{
MessageBox.Show("End date is less than Start date, please fix this before continuing");
endDate = startDate.Value.AddDays(1);
string endDatePlusOne = endDate.ToString();
dtEndDate.Text = endDatePlusOne;
}
}
else
{
MessageBox.Show("please enter an end date");
DateTime? startDate= DateTime.Parse(dtStartDate.Text);
DateTime? endDate;
endDate = startDate.Value.AddDays(1);
string endDatePlusOne = endDate.ToString();
dtEndDate.Text = endDatePlusOne;
}
}
}Editor is loading...