Yes, We have custom code mentioned below
// **************************************************
// Custom code for UD13Form
// Created: 1/7/2018 6:01:27 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using Erp.Adapters;
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 Ice.Proxy.BO;
using Ice.Core;
using Ice.BO;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Reflection;
using Infragistics.Win.UltraWinToolbars;
using Infragistics.Win.UltraWinDock;
using Erp.BO;
public class Script
{
Ice.Core.Session session;
EpiUltraGrid grdList;
EpiTextBox txtKeyField;
EpiTextBox txtKeyField2;
EpiTextBox txtKeyField4;
EpiTextBox txtKeyField5;
public void InitializeCustomCode()
{
session = (Ice.Core.Session)UD13Form.Session;
grdList = (EpiUltraGrid)csm.GetNativeControlReference("7908565c-cc3c-43d1-b85b-9921ad88fb89");
txtKeyField = (EpiTextBox)csm.GetNativeControlReference("46567b2e-6bc0-4967-be35-a0ec6843838f");
txtKeyField2 = (EpiTextBox)csm.GetNativeControlReference("5feb5781-48c2-440b-845e-019bd6d897f3");
txtKeyField4 = (EpiTextBox)csm.GetNativeControlReference("2a1d9451-d277-48be-92f6-abca977cde0c");
txtKeyField5 = (EpiTextBox)csm.GetNativeControlReference("a6a32ec0-bc92-48cd-a6c0-7455927bf4aa");
this.grdList.InitializeLayout += new InitializeLayoutEventHandler(this.grdList_InitializeLayout);
this.grdList.AfterSelectChange += new AfterSelectChangeEventHandler(this.grdList_AfterSelectChange);
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
this.ucmbBuyer.ValueChanged += new System.EventHandler(this.ucmbBuyer_ValueChanged);
this.ucmbBuyer.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ucmbBuyer_KeyPress);
this.ucmbAction.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ucmbAction_KeyPress);
this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
this.btnSaveAmendment.Click += new System.EventHandler(this.btnSaveAmendment_Click);
HideToolBar();
}
public void DestroyCustomCode()
{
this.grdList.InitializeLayout -= new InitializeLayoutEventHandler(this.grdList_InitializeLayout);
this.grdList.AfterSelectChange -= new AfterSelectChangeEventHandler(this.grdList_AfterSelectChange);
this.btnSave.Click -= new System.EventHandler(this.btnSave_Click);
this.btnOpen.Click -= new System.EventHandler(this.btnOpen_Click);
this.ucmbBuyer.ValueChanged -= new System.EventHandler(this.ucmbBuyer_ValueChanged);
this.ucmbBuyer.KeyPress -= new System.Windows.Forms.KeyPressEventHandler(this.ucmbBuyer_KeyPress);
this.ucmbAction.KeyPress -= new System.Windows.Forms.KeyPressEventHandler(this.ucmbAction_KeyPress);
this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
this.btnSaveAmendment.Click -= new System.EventHandler(this.btnSaveAmendment_Click);
}
private void UD13Form_Load(object sender, EventArgs args)
{
ClearControls();
ClearUltraCombo();
BindMasterData();
}
private void BindMasterData()
{
BindBuyer();
BindAction();
BindGridData();
}
#region Bind Master Data
private void HideToolBar()
{
try
{
Object objForm = typeof(Ice.UI.App.UD13Entry.UD13Form).InvokeMember("baseDockManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD13Form, null);
UltraDockManager dock = (Infragistics.Win.UltraWinDock.UltraDockManager)objForm;
dock.DockAreas[0].Panes[0].Closed = true;
var obj = UD13Form.GetType().InvokeMember("baseToolbarsManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD13Form, null);
var tools = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)obj;
if(tools.Tools.Exists("FileMenu"))
tools.Tools["FileMenu"].SharedProps.Enabled = false;
if(tools.Tools.Exists("EditMenu"))
tools.Tools["EditMenu"].SharedProps.Enabled = false;
if(tools.Tools.Exists("ActionsMenu"))
tools.Tools["ActionsMenu"].SharedProps.Enabled = false;
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["NewMenuTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["NewTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["SaveTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["DeleteTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["NewMenuTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["CutTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["CopyTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["PasteTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["PrintTool"]);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.Remove(baseToolbarsManager.Tools["PrintPreviewTool"]);
}
catch
{
}
}
private void BindBuyer()
{
try
{
string whereClouse ="Company ='"+ session.CompanyID +"' AND InActive = False";
DataSet objds = csm.GetSearchRecords("PurAgentAdapter", "PurAgent", whereClouse);
if(objds != null && objds.Tables.Count > 0 && objds.Tables["PurAgent"].Rows.Count > 0)
{
this.ucmbBuyer.ValueMember = "BuyerID";
this.ucmbBuyer.DataSource = objds.Tables["PurAgent"];
this.ucmbBuyer.DisplayMember = "Name";
string[] fields = new string[]
{
"Name"
};
this.ucmbBuyer.SetColumnFilter(fields);
}
else
{
this.ucmbBuyer.DataSource = null;
}
}
catch
{
}
}
private void BindAction()
{
try
{
string whereClouse ="CodeTypeID = 'ACTION' AND IsActive = True";
DataSet objds = csm.GetSearchRecords("UserCodesAdapter", "UDCodes", whereClouse);
if(objds != null && objds.Tables.Count > 0 && objds.Tables["UDCodes"].Rows.Count >0)
{
this.ucmbAction.ValueMember ="CodeId";
this.ucmbAction.DataSource = objds.Tables["UDCodes"];
this.ucmbAction.DisplayMember ="CodeDesc";
string[] fields = new string[]
{
"CodeDesc"
};
this.ucmbAction.SetColumnFilter(fields);
}
else
{
this.ucmbAction.DataSource = null;
}
}
catch
{
}
}
private void BindGridData()
{
try
{
ClearControls();
string whereClouse = "Company = '" + session.CompanyID + "' AND Key3 = '" + session.UserID + "' AND CheckBox01 = false";
DataSet objds = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouse);
if (objds != null && objds.Tables.Count > 0 && objds.Tables["UD13"].Rows.Count > 0 )
{
if(objds.Tables["UD13"].Rows[0]["Character01"].ToString()== "1")
{
grdList.DataSource = objds.Tables["UD13"];
grdList.DataBind();
}
else
{
string whereClouseLevel = "UD13.Company = '" + session.CompanyID +"' AND Character01 = "+ (Convert.ToInt32(objds.Tables["UD13"].Rows[0]["Character01"]) - 1).ToString() + " And UD13.CheckBox01 = True";
DataSet objdsLevel = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouseLevel);
var result = from r1 in objds.Tables["UD13"].AsEnumerable()
join r2 in objdsLevel.Tables["UD13"].AsEnumerable()
on r1.Field<string>(2) equals r2.Field<string>(2)
select r1;
if (result != null && result.Count() > 0)
{
grdList.DataSource = result.CopyToDataTable();
grdList.DataBind();
}
else
{
BindEmptyGrid(result.CopyToDataTable());
}
}
}
else
{
BindEmptyGrid(objds.Tables["UD13"]);
}
}
catch
{
}
}
private void BindEmptyGrid(DataTable objdt)
{
grdList.DataSource = objdt;
grdList.DataBind();
}
#endregion
#region Grid and Combobox Events
private void ucmbBuyer_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs args)
{
args.Handled = true;
}
private void ucmbAction_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs args)
{
args.Handled = true;
}
private void ucmbBuyer_ValueChanged(object sender, System.EventArgs args)
{
ClearControls();
string BuyerId = Convert.ToString(ucmbBuyer.Value);
if(!String.IsNullOrEmpty(BuyerId))
{
BindGridData(BuyerId);
}
}
private void grdList_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
try
{
var grdList = sender as UltraGrid;
if(grdList == null)
return;
e.Layout.Override.SelectTypeRow = SelectType.Single;
e.Layout.Override.CellClickAction = CellClickAction.RowSelect;
e.Layout.Bands[0].Columns["Company"].Header.Caption = "Company";
e.Layout.Bands[0].Columns["Key1"].Header.Caption = "Plant";
e.Layout.Bands[0].Columns["Key2"].Header.Caption = "PO Number";
e.Layout.Bands[0].Columns["Key3"].Header.Caption = "Approver";
e.Layout.Bands[0].Columns["Key4"].Header.Caption = "Role";
e.Layout.Bands[0].Columns["Key5"].Header.Caption = "Vendor Num";
e.Layout.Bands[0].Columns["Character01"].Header.Caption = "Level";
e.Layout.Bands[0].Columns["Character02"].Header.Caption = "Vendor ID";
e.Layout.Bands[0].Columns["Character03"].Header.Caption = "Vendor Name";
e.Layout.Bands[0].Columns["Character04"].Header.Caption = "Project ID";
e.Layout.Bands[0].Columns["Character05"].Header.Caption = "Project Name";
e.Layout.Bands[0].Columns["Character06"].Header.Caption = "Buyer";
e.Layout.Bands[0].Columns["Character07"].Header.Caption = "Created By";
e.Layout.Bands[0].Columns["Character08"].Header.Caption = "Updated By";
e.Layout.Bands[0].Columns["Character09"].Header.Caption = "Comment";
e.Layout.Bands[0].Columns["Character10"].Header.Caption = "Action";
e.Layout.Bands[0].Columns["Number01"].Header.Caption = "PO Amount";
e.Layout.Bands[0].Columns["Number01"].Format = "0.00";
e.Layout.Bands[0].Columns["CheckBox01"].Header.Caption = "Approval Status";
e.Layout.Bands[0].Columns["CheckBox02"].Header.Caption = "Is Rejected";
e.Layout.Bands[0].Columns["Date01"].Header.Caption = "Created Date";
e.Layout.Bands[0].Columns["Date02"].Header.Caption = "Updated Date";
e.Layout.Bands[0].Columns["Date03"].Header.Caption = "Action Date";
e.Layout.Bands[0].Columns["Number02"].Hidden = true;
e.Layout.Bands[0].Columns["Number03"].Hidden = true;
e.Layout.Bands[0].Columns["Number04"].Hidden = true;
e.Layout.Bands[0].Columns["Number05"].Hidden = true;
e.Layout.Bands[0].Columns["Number06"].Hidden = true;
e.Layout.Bands[0].Columns["Number07"].Hidden = true;
e.Layout.Bands[0].Columns["Number08"].Hidden = true;
e.Layout.Bands[0].Columns["Number09"].Hidden = true;
e.Layout.Bands[0].Columns["Number10"].Hidden = true;
e.Layout.Bands[0].Columns["Number11"].Hidden = true;
e.Layout.Bands[0].Columns["Number12"].Hidden = true;
e.Layout.Bands[0].Columns["Number13"].Hidden = true;
e.Layout.Bands[0].Columns["Number14"].Hidden = true;
e.Layout.Bands[0].Columns["Number15"].Hidden = true;
e.Layout.Bands[0].Columns["Number16"].Hidden = true;
e.Layout.Bands[0].Columns["Number17"].Hidden = true;
e.Layout.Bands[0].Columns["Number18"].Hidden = true;
e.Layout.Bands[0].Columns["Number19"].Hidden = true;
e.Layout.Bands[0].Columns["Number20"].Hidden = true;
e.Layout.Bands[0].Columns["Date04"].Hidden = true;
e.Layout.Bands[0].Columns["Date05"].Hidden = true;
e.Layout.Bands[0].Columns["Date06"].Hidden = true;
e.Layout.Bands[0].Columns["Date07"].Hidden = true;
e.Layout.Bands[0].Columns["Date08"].Hidden = true;
e.Layout.Bands[0].Columns["Date09"].Hidden = true;
e.Layout.Bands[0].Columns["Date10"].Hidden = true;
e.Layout.Bands[0].Columns["Date11"].Hidden = true;
e.Layout.Bands[0].Columns["Date12"].Hidden = true;
e.Layout.Bands[0].Columns["Date13"].Hidden = true;
e.Layout.Bands[0].Columns["Date14"].Hidden = true;
e.Layout.Bands[0].Columns["Date15"].Hidden = true;
e.Layout.Bands[0].Columns["Date16"].Hidden = true;
e.Layout.Bands[0].Columns["Date17"].Hidden = true;
e.Layout.Bands[0].Columns["Date18"].Hidden = true;
e.Layout.Bands[0].Columns["Date19"].Hidden = true;
e.Layout.Bands[0].Columns["Date20"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox03"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox04"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox05"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox06"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox07"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox08"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox09"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox10"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox11"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox12"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox13"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox14"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox15"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox16"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox17"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox18"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox19"].Hidden = true;
e.Layout.Bands[0].Columns["CheckBox20"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar01"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar02"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar03"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar04"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar05"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar06"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar07"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar08"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar09"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar10"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar11"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar12"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar13"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar14"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar15"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar16"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar17"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar18"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar19"].Hidden = true;
e.Layout.Bands[0].Columns["ShortChar20"].Hidden = true;
e.Layout.Bands[0].Columns["GlobalUD13"].Hidden = true;
e.Layout.Bands[0].Columns["GlobalLock"].Hidden = true;
e.Layout.Bands[0].Columns["SysRevID"].Hidden = true;
e.Layout.Bands[0].Columns["SysRowID"].Hidden = true;
e.Layout.Bands[0].Columns["BitFlag"].Hidden = true;
e.Layout.Bands[0].Columns["RowMod"].Hidden = true;
}
catch
{
}
}
private void grdList_AfterSelectChange(object sender, System.EventArgs e)
{
try
{
ClearControls();
if(this.grdList.Selected.Rows.Count == 1)
{
foreach(UltraGridRow rowSelected in this.grdList.Selected.Rows)
{
string PONum = Convert.ToString(rowSelected.Cells["Key2"].Text);
string BuyerId = Convert.ToString(rowSelected.Cells["Character06"].Text);
if((!String.IsNullOrEmpty(PONum)) && (!String.IsNullOrEmpty(BuyerId)))
{
BindFormData(PONum , BuyerId);
BindAmendementhistory(PONum);//rahul 8/10/18
}
}
}
}
catch
{
}
}
#endregion
#region Form Functions
private string DoFormat(double profit)
{
var value = string.Format("{0:0.00}", profit);
if (value.EndsWith("00") )
return ((int)profit).ToString();
else
return value;
}
#endregion
private void BindGridData(string BuyerId)
{
string whereClouse = "Company = '" + session.CompanyID + "' AND Key3 = '" + session.UserID + "' And Character06 = '" + BuyerId + "' AND CheckBox01 = false";
DataSet objds = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouse);
if (objds != null && objds.Tables.Count > 0 && objds.Tables["UD13"].Rows.Count > 0 )
{
if(objds.Tables["UD13"].Rows[0]["Character01"].ToString()== "1")
{
grdList.DataSource = objds.Tables["UD13"];
grdList.DataBind();
grdList.Rows[0].Selected = true;
BindFormData(objds.Tables["UD13"]);
}
else
{
string whereClouseLevel = "UD13.Company = '" + session.CompanyID +"' AND Character01 = "+ (Convert.ToInt32(objds.Tables["UD13"].Rows[0]["Character01"]) - 1).ToString() + " And UD13.CheckBox01 = True";
DataSet objdsLevel = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouseLevel);
var result = from r1 in objds.Tables["UD13"].AsEnumerable()
join r2 in objdsLevel.Tables["UD13"].AsEnumerable()
on r1.Field<string>(2) equals r2.Field<string>(2)
select r1;
if (result != null && result.Count() > 0)
{
grdList.DataSource = result.CopyToDataTable();
grdList.DataBind();
BindFormData(result.CopyToDataTable());
}
else
{
BindEmptyGrid(result.CopyToDataTable());
}
}
}
else
{
BindEmptyGrid(objds.Tables["UD13"]);
ClearControls();
}
}
private void BindFormData(DataTable objdt)
{
try
{
ClearControls();
if(objdt.Rows.Count > 0)
{
txtKeyField.Text = string.Empty; // Buyer Limit
txtKeyField4.Text = Convert.ToString(objdt.Rows[0]["Key2"]); // PO Number
txtKeyField2.Text = DoFormat(Convert.ToDouble(objdt.Rows[0]["Number01"])); // PO Amount
txtKeyField5.Text = Convert.ToString(objdt.Rows[0]["Character03"]); // Supplier Name
}
}
catch
{
}
}
private void BindFormData(string PONum, string BuyerId)
{
try
{
string whereClouse = "Company = '" + session.CompanyID + "' AND Key2 = '" + PONum + "' AND Key3 = '" + session.UserID + "' And Character06 = '" + BuyerId + "' AND CheckBox01 = false";
DataSet objds = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouse);
if (objds != null && objds.Tables.Count > 0 && objds.Tables["UD13"].Rows.Count > 0 )
{
txtKeyField.Text = string.Empty; // Buyer Limit
txtKeyField4.Text = Convert.ToString(objds.Tables["UD13"].Rows[0]["Key2"]); // PO Number
txtKeyField2.Text = DoFormat(Convert.ToDouble(objds.Tables["UD13"].Rows[0]["Number01"])); // PO Amount
txtKeyField5.Text = Convert.ToString(objds.Tables["UD13"].Rows[0]["Character03"]); // Supplier Name
ucmbBuyer.Value = Convert.ToString(objds.Tables["UD13"].Rows[0]["Character06"]);
}
}
catch
{
}
}
#region Approve Methods
private void btnSave_Click(object sender, System.EventArgs args)
{
BeforeUpdateValidateData();
}
private void BeforeUpdateValidateData()
{
string BuyerID = Convert.ToString(ucmbBuyer.Value);
string PONum = Convert.ToString(txtKeyField4.Text);
string Action = Convert.ToString(ucmbAction.Value);
if(String.IsNullOrEmpty(BuyerID))
MessageBox.Show("Buyer must be select !!", "Required");
else if(String.IsNullOrEmpty(PONum))
MessageBox.Show("PONum must be required !!", "Required");
else if(String.IsNullOrEmpty(Action))
MessageBox.Show("Action must be select !!" , "Required");
else
UpdateApprovalMatrix(session.CompanyID, BuyerID, PONum, session.UserID, Action);
}
private void UpdateApprovalMatrix(string CompanyID, string BuyerID, string PONum, string UserID, string Action)
{
try
{
UD13Adapter objadapter = new UD13Adapter(this.oTrans);
objadapter.BOConnect();
string whereClause = "Company = '"+ CompanyID +"' AND Key2 = '"+ PONum +"' AND Key3 = '"+ UserID +"' AND Character06 = '"+ BuyerID +"' AND CheckBox01 = False";
Hashtable whereClauses = new Hashtable(1);
whereClauses.Add("UD13", whereClause);
SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
objadapter.InvokeSearch(searchOptions);
if(objadapter.UD13Data.UD13.Rows.Count > 0)
{
DataRow objdr = objadapter.UD13Data.UD13.Rows[0];
objdr.BeginEdit();
if(Action == "HOLD")
objdr["CheckBox01"] = false;
else
objdr["CheckBox01"] = true;
objdr["Character09"] = txtComment.Text;
objdr["Character10"] = Action;
objdr["Date03"] = DateTime.Now.Date;
objdr.EndEdit();
if (objadapter.Update())
{
if(Action == "REJECT")
EpiMessageBox.Show("Purchase Order reject successfully !!");
else if(Action == "HOLD")
HoldPurchaseOrder(CompanyID, BuyerID, PONum);
else
CheckRemainingApprovers(CompanyID, BuyerID, PONum, Action);
ClearControls();
BindGridData();
UpdateCustomerAmendmentbyNum(PONum);//Rahul Udate amendment 18/10/10 11am
}
else
{
EpiMessageBox.Show("Error: System error occured while approving Purchase Order !!");
}
objadapter.Dispose();
}
else
{
EpiMessageBox.Show("No record found !!");
}
}
catch(Exception ex)
{
ExceptionBox.Show(ex);
}
}
private void CheckRemainingApprovers(string CompanyID, string BuyerID, string PONum, string Action)
{
try
{
string whereClouse = "UD13.Company = '"+ CompanyID +"' AND UD13.Key2 = '"+ PONum +"' And CheckBox01 = False";
DataSet objds = csm.GetSearchRecords("UD13Adapter", "UD13", whereClouse);
DataTable objdt = objds.Tables["UD13"];
if(objdt != null && objdt.Rows.Count > 0 )
{
string remain = string.Empty;
foreach(DataRow objdr in objdt.Rows)
{
remain += "\n"+ Convert.ToString(objdr["Key4"])+"/"+ Convert.ToString(objdr["Key3"]);
}
ClearControls();
BindGridData();
EpiMessageBox.Show("Purchase Order Approval Pending From Role/User " + remain);
}
else
{
ApprovePurchaseOrder(CompanyID, BuyerID, PONum);
//UpdatePOHeader(CompanyID, BuyerID, PONum);
}
}
catch(Exception ex)
{
EpiMessageBox.Show(ex.Message);
}
}
private void ApprovePurchaseOrder(string CompanyID, string BuyerID, string PONum)
{
try
{
POAdapter objPO = new POAdapter(oTrans);
objPO.BOConnect();
string whereClause = "Company = '"+ CompanyID +"' AND PONum = '"+ PONum +"' AND BuyerID = '"+ BuyerID +"'";
Hashtable objHashTable = new Hashtable(1);
objHashTable.Add("POHeader", whereClause);
SearchOptions objSearch = SearchOptions.CreateRuntimeSearch(objHashTable, DataSetMode.RowsDataSet);
objPO.InvokeSearch(objSearch);
DataRow objdr = objPO.POData.POHeader.Rows[0];
if(objdr != null)
{
objdr.BeginEdit();
objdr["ApprovalStatus"] = "A";
objdr["ApprovedBy"] = session.UserID;
objdr["ApprovedDate"] = DateTime.Now.Date;
objdr["Approve"] = true;
objdr["ChangeDate"] = DateTime.Now;
objdr.EndEdit();
if (objPO.Update())
EpiMessageBox.Show("Purchase Order approved successfully !!");
else
EpiMessageBox.Show("Error: System error occured while Approving Purchase Order !!");
}
objPO.Dispose();
}
catch(Exception ex)
{
ExceptionBox.Show(ex);
}
}
private void HoldPurchaseOrder(string CompanyID, string BuyerID, string PONum)
{
try
{
POAdapter objPO = new POAdapter(oTrans);
objPO.BOConnect();
string whereClause = "Company = '"+ CompanyID +"' AND PONum = '"+ PONum +"' AND BuyerID = '"+ BuyerID +"'";
Hashtable objHashTable = new Hashtable(1);
objHashTable.Add("POHeader", whereClause);
SearchOptions objSearch = SearchOptions.CreateRuntimeSearch(objHashTable, DataSetMode.RowsDataSet);
objPO.InvokeSearch(objSearch);
DataRow objdr = objPO.POData.POHeader.Rows[0];
if(objdr != null)
{
objdr.BeginEdit();
objdr["OrderHeld"] = true;
objdr["ChangeDate"]= DateTime.Now;
objdr.EndEdit();
if (objPO.Update())
EpiMessageBox.Show("Purchase Order hold successfully !!");
else
EpiMessageBox.Show("Error: System error occured while Holding Purchase Order !!");
}
objPO.Dispose();
}
catch(Exception ex)
{
ExceptionBox.Show(ex);
}
}
#endregion
#region Open Purchase Order
private void btnOpen_Click(object sender, System.EventArgs args)
{
try
{
string PONum = txtKeyField4.Text;
if(!String.IsNullOrEmpty(PONum))
{
LaunchFormOptions objLounch = new LaunchFormOptions();
objLounch.ValueIn = PONum;
objLounch.IsModal = true;
ProcessCaller.LaunchForm(oTrans,"PMGO2001", objLounch, true);
}
else
{
MessageBox.Show("Please select atleast one record !!");
}
}
catch
{
}
}
#endregion
#region Clear Controls
private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
switch (args.Tool.Key)
{
case "ClearTool":
ClearControls();
ClearUltraCombo();
BindGridData();
BindMasterData();
break;
}
}
private void ClearControls()
{
txtKeyField.Text = string.Empty; // Buyer Limit
txtKeyField4.Text = string.Empty; // PO Number
txtKeyField2.Text = string.Empty; // PO Amount
txtKeyField5.Text = string.Empty; // Supplier Name
txtComment.Text = string.Empty;
}
private void ClearUltraCombo()
{
this.ucmbBuyer.Value = "";
this.ucmbAction.Value = "";
}
#endregion
#region Rahul 10/5/2018 amendment
private void BindAmendementhistory(string poNum)
{
try
{
string whereClouse ="POHeader.PONum='"+poNum+"'";
DataSet dsPOHeader = csm.GetSearchRecords("POAdapter", "POHeader", whereClouse);
if(dsPOHeader != null && dsPOHeader.Tables.Count > 0 && dsPOHeader .Tables["POHeader"].Rows.Count >0)
{
this.txtPreviouseAmendment.Text = dsPOHeader.Tables[0].Rows[0]["Amended_Reason_c"].ToString();
if(dsPOHeader.Tables[0].Rows[0]["CustOnHold_c"].ToString()=="True")
{
// this.chkCustomerOnHold.Checked=true;
}
else
{
// this.chkCustomerOnHold.Checked=false;
}
}
}
catch
{
}
}
private void UpdateCustomerAmendmentbyNum(string PONum)
{
POAdapter objadapter = new POAdapter(this.oTrans);
objadapter.BOConnect();
string whereClause = "POHeader.Company = '"+ session.CompanyID +"' AND POHeader.PONum='"+PONum+"'";
Hashtable whereClauses = new Hashtable(1);
whereClauses.Add("POHeader", whereClause);
SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
objadapter.InvokeSearch(searchOptions);
DataRow objdr = objadapter.POData.POHeader.Rows[0];
bool result =false;
if(objdr != null)
{
objdr.BeginEdit();
objdr["Amended_Reason_c"] = txtPreviouseAmendment.Text;
objdr.EndEdit();
}
result = objadapter.Update();
}
#endregion
private void btnSaveAmendment_Click(object sender, System.EventArgs args)
{
if(MessageBox.Show("Are you sure want to save Suggestion?","Confirm Save!!", MessageBoxButtons.YesNo)== DialogResult.Yes)
{
txtPreviouseAmendment.Text+="\n"+ session.UserID +": "+DateTime.Now.ToString()+"\n"+txtReason.Text+"\n";
txtReason.Text="";
}
}
}