// **************************************************
// Custom code for MainController
// Created: 9/15/2018 11:34:11 AM
// **************************************************
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
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
private EpiBasePanel V_GS_envision_1ViewDockPanel6;
private EpiDataView edvV_GS_Order_Notes_1View;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
private string custid;
private int ordernum;
private int qty;
private int quoteqty;
private int numcolors;
private string quotepartnum;
private string partnum;
private int quotenum;
private int newquoteqty;
private string newquotepartnum;
private int newnumcolors;
private int newqtybreaks;
private string newcustid;
private int neworderqty;
private string neworderpartnum;
private int ordernumcolors;
private int neworderqtybreaks;
private string ordercustid;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
V_GS_envision_1ViewDockPanel6 = (EpiBasePanel)csm.GetNativeControlReference("5f12913d-34ea-4b15-b607-5fdd29280f8b");
this.V_GS_Order_Detail_All_1View_Row.EpiRowChanged += new EpiRowChanged(this.V_GS_Order_Detail_All_1View_AfterRowChange);
this.V_GS_Quote_All_1View_Row.EpiRowChanged += new EpiRowChanged(this.V_GS_Quote_All_1View_AfterRowChange);
this.edvV_GS_Order_Notes_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_GS_Order_Notes_1View"]));
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
this.epiButtonC2.Click += new System.EventHandler(this.epiButtonC2_Click);
this.epiButtonC4.Click += new System.EventHandler(this.epiButtonC4_Click);
this.btnOrderNote.Click += new System.EventHandler(this.btnOrderNote_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.V_GS_Order_Detail_All_1View_Row.EpiRowChanged -= new EpiRowChanged(this.V_GS_Order_Detail_All_1View_AfterRowChange);
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
this.V_GS_Quote_All_1View_Row.EpiRowChanged -= new EpiRowChanged(this.V_GS_Quote_All_1View_AfterRowChange);
this.epiButtonC2.Click -= new System.EventHandler(this.epiButtonC2_Click);
this.epiButtonC4.Click -= new System.EventHandler(this.epiButtonC4_Click);
this.btnOrderNote.Click -= new System.EventHandler(this.btnOrderNote_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void V_GS_Order_Detail_All_1View_AfterRowChange(EpiRowChangedArgs args)
{
// ** Argument Properties and Uses **
// args.CurrentView.dataView[args.CurrentRow]["FieldName"]
// args.LastRow, args.CurrentRow, args.CurrentView
// Add Event Handler Code
//MessageBox.Show(ordernum.ToString() + "OrderDetailAllViewRowChange, " + ", " + qty.ToString() + ", " + numcolors.ToString());
custid = string.Empty;
ordernum = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["OrderDtl_OrderNum"].ToString());
custid = args.CurrentView.dataView[args.CurrentRow]["Customer_CustID"].ToString();
qty = Convert.ToInt32(Convert.ToDecimal(args.CurrentView.dataView[args.CurrentRow]["OrderDtl_OrderQty"].ToString()));
numcolors = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["OrderDtl_GS_NbrOfColors_c"].ToString());
partnum = args.CurrentView.dataView[args.CurrentRow]["OrderDtl_PartNum"].ToString();
epiTextBoxC1OrderItem.Text = args.CurrentView.dataView[args.CurrentRow]["OrderDtl_PartNum"].ToString();
epiNumericEditorC1OrderQty.Value = Convert.ToInt32(Convert.ToDecimal(args.CurrentView.dataView[args.CurrentRow]["OrderDtl_OrderQty"].ToString()));
epiNumericEditorC1OrderNumColors.Value = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["OrderDtl_GS_NbrOfColors_c"].ToString());
epiTextBoxC1OrderID.Text = args.CurrentView.dataView[args.CurrentRow]["Customer_CustID"].ToString();
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("GS_Order_Notes_Test");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("OrderNum", ordernum.ToString() , "nvarchar",false, Guid.NewGuid(), "A");
dqa.ExecuteByID("GS_Order_Notes_Test",qeds);
epiUltraGridC2.DataSource = dqa.QueryResults.Tables["Results"];
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
//pass list of parameters - Quote From Order
// these items cannot be null or empty //!
LaunchFormOptions lfo = new LaunchFormOptions();
System.Collections.Generic.Dictionary<string, string> mylist = new System.Collections.Generic.Dictionary<string, string>();
mylist.Add("entitynum", "0"); //this should be "0" if getting new quote or new sales order
neworderpartnum = epiTextBoxC1OrderItem.Text;
mylist.Add("partnum", neworderpartnum.ToString());
neworderqty = Convert.ToInt32(epiNumericEditorC1OrderQty.Text);
mylist.Add("quantity", neworderqty.ToString());
ordercustid = epiTextBoxC1OrderID.Text;
mylist.Add("custid", ordercustid);
neworderqtybreaks = Convert.ToInt32(epiNumericEditorC2OrderQtyBreak.Text);
mylist.Add("quantitybreaks", neworderqtybreaks.ToString());
ordernumcolors = Convert.ToInt32(epiNumericEditorC1OrderNumColors.Text);
mylist.Add("numofcolors", ordernumcolors.ToString()); //!
mylist.Add("prevorder", ordernum.ToString());
mylist.Add("actiontype", "NewQuote"); //!
string valuein = "Quote";
lfo.ValueIn = valuein;
lfo.ContextValue = mylist;
ProcessCaller.LaunchForm(oTrans, "jesCustF", lfo); //parameters (EpiTransaction, MenuName of DLL to call, LaunchFormOptions)
}
private void V_GS_Quote_All_1View_AfterRowChange(EpiRowChangedArgs args)
{
// ** Argument Properties and Uses **
// args.CurrentView.dataView[args.CurrentRow]["FieldName"]
// args.LastRow, args.CurrentRow, args.CurrentView
// Add Event Handler Code
//MessageBox.Show("Start " + custid + ", " + quotenum.ToString() + ", " + quoteqty.ToString() + ", " + numcolors.ToString() + ", " + quotepartnum.ToString());
custid = quotepartnum = newquotepartnum = string.Empty;
quotenum = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_QuoteNum"].ToString());
custid = args.CurrentView.dataView[args.CurrentRow]["Customer_CustID"].ToString();
quoteqty = Convert.ToInt32(Convert.ToDecimal(args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_SellingExpectedQty"].ToString()));
numcolors = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_GS_NbrOfColors_c"].ToString());
quotepartnum = args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_PartNum"].ToString();
epiTextBoxC11Item.Text = args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_PartNum"].ToString();
epiNumericEditorC1QQty.Value = Convert.ToInt32(Convert.ToDecimal(args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_SellingExpectedQty"].ToString()));
epiTextBoxC8Cust.Text = args.CurrentView.dataView[args.CurrentRow]["Customer_CustID"].ToString();
epiNumericEditorC2NumColors.Value = Convert.ToInt32(args.CurrentView.dataView[args.CurrentRow]["QuoteDtl_GS_NbrOfColors_c"].ToString());
}
private void epiButtonC2_Click(object sender, System.EventArgs args)
{
//pass in single value(entitynum - Quote Number) Edit Quote
// these items cannot be null or empty //!
LaunchFormOptions lfo = new LaunchFormOptions();
string valuein = “Quote”;
string contextvaluein = quotenum.ToString();// this will be the sales quote number //!
lfo.ValueIn = valuein;
lfo.ContextValue = contextvaluein;
ProcessCaller.LaunchForm(oTrans, “jesCustF”, lfo); //parameters (EpiTransaction, MenuName of DLL to call, LaunchFormOptions)
}
private void epiButtonC4_Click(object sender, System.EventArgs args)
{
//pass list of parameters - New Quote with Customer and Part
// these items cannot be null or empty //!
LaunchFormOptions lfo = new LaunchFormOptions();
System.Collections.Generic.Dictionary<string, string> mylist = new System.Collections.Generic.Dictionary<string, string>();
mylist.Add(“entitynum”, “0”); //this should be “0” if getting new quote or new sales order
newquotepartnum = epiTextBoxC11Item.Text;
mylist.Add(“partnum”, newquotepartnum);
newquoteqty = Convert.ToInt32(epiNumericEditorC1QQty.Text);
mylist.Add(“quantity”, newquoteqty.ToString()); //!
newcustid = epiTextBoxC8Cust.Text;
mylist.Add(“custid”, newcustid); //!
newqtybreaks = Convert.ToInt32(epiNumericEditorC3QQtyBreaks.Text);
mylist.Add(“quantitybreaks”, newqtybreaks.ToString());
newnumcolors = Convert.ToInt32(epiNumericEditorC2NumColors.Text);
mylist.Add(“numofcolors”, newnumcolors.ToString()); //!
mylist.Add(“actiontype”, “NewQuote”); //!
string valuein = “Quote”;
lfo.ValueIn = valuein;
lfo.ContextValue = mylist;
ProcessCaller.LaunchForm(oTrans, “jesCustF”, lfo); //parameters (EpiTransaction, MenuName of DLL to call, LaunchFormOptions)
}
private void MainController_Load(object sender, EventArgs args)
{
V_GS_envision_1ViewDockPanel6.Visible = false;
}
private void btnOrderNote_Click(object sender, System.EventArgs args)
{
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("GS_Order_Notes");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("OrderNum", ordernum.ToString() , "nvarchar",false, Guid.NewGuid(), "A");
dqa.ExecuteByID("GS_Order_Notes_Test",qeds);
epiUltraGridC1OrderNotes.DataSource = dqa.QueryResults.Tables["Results"];
}
}