Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // **************************************************
- // Custom code for UD01Form
- // Created: 10/23/2014 2:16:50 PM
- // **************************************************
- using System;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Windows.Forms;
- using Ice.BO;
- using Ice.UI;
- using Ice.Lib.Customization;
- using Ice.Lib.ExtendedProps;
- using Ice.Lib.Framework;
- using Ice.Lib.Searches;
- using Ice.UI.FormFunctions;
- using System.Reflection;
- using Infragistics.Win.UltraWinGrid;
- public class Script
- {
- private Ice.Lib.Customization.CustomScriptManager csm;
- private Ice.UI.App.UD01Entry.Transaction oTrans;
- private Ice.UI.App.UD01Entry.UD01Form UD01Form;
- private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager baseToolbarsManager;
- private System.Data.DataTable UD01_Column;
- private Ice.Lib.Framework.EpiDataView UD01_Row;
- private System.Data.DataTable UD01Attch_Column;
- private Ice.Lib.Framework.EpiDataView AutoAttachUD01_Row;
- private System.Data.DataTable BpmData_Column;
- private Ice.Lib.Framework.EpiDataView CallContextBpmData_Row;
- private System.Data.DataTable Client_Column;
- private Ice.Lib.Framework.EpiDataView CallContextClientData_Row;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet1;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet2;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet3;
- private Ice.Lib.Framework.EpiDockManagerPanel Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8;
- private Ice.Lib.Framework.EpiUltraGrid grdMain;
- private Ice.Lib.Framework.EpiUltraGrid grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44;
- private Ice.Lib.Framework.EpiGroupBox epiGroupBox1;
- private Ice.Lib.Framework.EpiGroupBox epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe;
- private Ice.Lib.Framework.EpiButton btnSelectAll;
- private Ice.Lib.Framework.EpiButton btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4;
- private Ice.Lib.Framework.EpiButton btnUnSelectAl;
- private Ice.Lib.Framework.EpiButton btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578;
- private Ice.Lib.Framework.EpiGroupBox bbbb;
- private Ice.Lib.Framework.EpiGroupBox bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536;
- private Ice.Lib.Framework.EpiButton btnCreateJobs;
- private Ice.Lib.Framework.EpiButton btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c;
- private Ice.Lib.Framework.EpiButton epiButtonC1;
- private Ice.Lib.Framework.EpiButton epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36;
- public void InitializeGlobalVariables(Ice.Lib.Customization.CustomScriptManager csm)
- {
- this.csm = csm;
- this.oTrans = ((Ice.UI.App.UD01Entry.Transaction)(this.csm.GetGlobalInstance("oTrans")));
- this.UD01Form = ((Ice.UI.App.UD01Entry.UD01Form)(this.csm.GetGlobalInstance("UD01Form")));
- this.baseToolbarsManager = ((Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)(this.csm.GetGlobalInstance("baseToolbarsManager")));
- this.UD01_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("UD01_Column")));
- this.UD01_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("UD01_Row")));
- this.UD01Attch_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("UD01Attch_Column")));
- this.AutoAttachUD01_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("AutoAttachUD01_Row")));
- this.BpmData_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("BpmData_Column")));
- this.CallContextBpmData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextBpmData_Row")));
- this.Client_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("Client_Column")));
- this.CallContextClientData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextClientData_Row")));
- Ice.Lib.Customization.PersonalizeCustomizeManager personalizeCustomizeManager = this.csm.PersonalizeCustomizeManager;
- System.Windows.Forms.Control topControl = personalizeCustomizeManager.TopControl;
- topControl.FindForm().SuspendLayout();
- // Creating custom targets.
- this.Sheet1 = new Ice.Lib.Framework.EpiDockManagerPanel();
- this.Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033 = this.Sheet1;
- System.Collections.Hashtable customControls = personalizeCustomizeManager.CustControlMan.CustomControlsHT;
- customControls.Add("ba9594b7-d2d2-426c-a533-38f0318f3033", this.Sheet1);
- System.Collections.Hashtable controlsHT = personalizeCustomizeManager.ControlsHT;
- controlsHT.Add("ba9594b7-d2d2-426c-a533-38f0318f3033", this.Sheet1);
- this.Sheet1.Name = "Sheet1";
- this.Sheet1.EpiGuid = "ba9594b7-d2d2-426c-a533-38f0318f3033";
- this.Sheet2 = new Ice.Lib.Framework.EpiDockManagerPanel();
- this.Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6 = this.Sheet2;
- customControls.Add("7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", this.Sheet2);
- controlsHT.Add("7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", this.Sheet2);
- this.Sheet2.Name = "Sheet2";
- this.Sheet2.EpiGuid = "7b1b5b5f-0912-43ef-b10b-cc361e21fbe6";
- this.Sheet3 = new Ice.Lib.Framework.EpiDockManagerPanel();
- this.Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8 = this.Sheet3;
- customControls.Add("42938545-be6b-40c2-bccc-d521b3d1b0b8", this.Sheet3);
- controlsHT.Add("42938545-be6b-40c2-bccc-d521b3d1b0b8", this.Sheet3);
- this.Sheet3.Name = "Sheet3";
- this.Sheet3.EpiGuid = "42938545-be6b-40c2-bccc-d521b3d1b0b8";
- this.grdMain = new Ice.Lib.Framework.EpiUltraGrid();
- this.grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44 = this.grdMain;
- customControls.Add("78ea3de5-e734-43e7-adbc-a4b06d4ebd44", this.grdMain);
- controlsHT.Add("78ea3de5-e734-43e7-adbc-a4b06d4ebd44", this.grdMain);
- this.grdMain.Name = "grdMain";
- this.grdMain.EpiGuid = "78ea3de5-e734-43e7-adbc-a4b06d4ebd44";
- this.epiGroupBox1 = new Ice.Lib.Framework.EpiGroupBox();
- this.epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe = this.epiGroupBox1;
- customControls.Add("aa67cac3-28aa-46c0-996a-77aa548defbe", this.epiGroupBox1);
- controlsHT.Add("aa67cac3-28aa-46c0-996a-77aa548defbe", this.epiGroupBox1);
- this.epiGroupBox1.Name = "epiGroupBox1";
- this.epiGroupBox1.EpiGuid = "aa67cac3-28aa-46c0-996a-77aa548defbe";
- this.btnSelectAll = new Ice.Lib.Framework.EpiButton();
- this.btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4 = this.btnSelectAll;
- customControls.Add("27f11a92-d512-4acd-9baa-dd85ea939ee4", this.btnSelectAll);
- controlsHT.Add("27f11a92-d512-4acd-9baa-dd85ea939ee4", this.btnSelectAll);
- this.btnSelectAll.Name = "btnSelectAll";
- this.btnSelectAll.EpiGuid = "27f11a92-d512-4acd-9baa-dd85ea939ee4";
- this.btnUnSelectAl = new Ice.Lib.Framework.EpiButton();
- this.btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578 = this.btnUnSelectAl;
- customControls.Add("517214e2-1cf4-4d48-baab-1d1979a35578", this.btnUnSelectAl);
- controlsHT.Add("517214e2-1cf4-4d48-baab-1d1979a35578", this.btnUnSelectAl);
- this.btnUnSelectAl.Name = "btnUnSelectAl";
- this.btnUnSelectAl.EpiGuid = "517214e2-1cf4-4d48-baab-1d1979a35578";
- this.bbbb = new Ice.Lib.Framework.EpiGroupBox();
- this.bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536 = this.bbbb;
- customControls.Add("4b987139-527e-4df1-b2fc-6bbd0ea32536", this.bbbb);
- controlsHT.Add("4b987139-527e-4df1-b2fc-6bbd0ea32536", this.bbbb);
- this.bbbb.Name = "bbbb";
- this.bbbb.EpiGuid = "4b987139-527e-4df1-b2fc-6bbd0ea32536";
- this.btnCreateJobs = new Ice.Lib.Framework.EpiButton();
- this.btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c = this.btnCreateJobs;
- customControls.Add("57669000-6dc2-4d84-8a65-10c64551bb5c", this.btnCreateJobs);
- controlsHT.Add("57669000-6dc2-4d84-8a65-10c64551bb5c", this.btnCreateJobs);
- this.btnCreateJobs.Name = "btnCreateJobs";
- this.btnCreateJobs.EpiGuid = "57669000-6dc2-4d84-8a65-10c64551bb5c";
- this.epiButtonC1 = new Ice.Lib.Framework.EpiButton();
- this.epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36 = this.epiButtonC1;
- customControls.Add("df7a4510-eba7-4b6d-aa68-d2c340269a36", this.epiButtonC1);
- controlsHT.Add("df7a4510-eba7-4b6d-aa68-d2c340269a36", this.epiButtonC1);
- this.epiButtonC1.Name = "epiButtonC1";
- this.epiButtonC1.EpiGuid = "df7a4510-eba7-4b6d-aa68-d2c340269a36";
- // Sheet1
- this.Sheet1.AutoScroll = true;
- System.Collections.Hashtable customSheets = personalizeCustomizeManager.CustControlMan.CustomSheetsHT;
- Infragistics.Win.UltraWinDock.DockableControlPane local1 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet1, "ba9594b7-d2d2-426c-a533-38f0318f3033", customSheets);
- if ((local1 != null))
- {
- Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet1);
- local1.Text = "";
- local1.TextTab = "Sheet1";
- Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local1, "baseDockManager1dff11bc-3024-4d17-acfc-b7af287e274b");
- }
- // Sheet2
- this.Sheet2.Controls.Add(this.grdMain);
- this.Sheet2.Controls.SetChildIndex(this.grdMain, 0);
- this.Sheet2.AutoScroll = true;
- Infragistics.Win.UltraWinDock.DockableControlPane local2 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet2, "7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", customSheets);
- if ((local2 != null))
- {
- Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet2);
- local2.Text = "";
- local2.TextTab = "Sheet2";
- Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local2, "baseDockManagerba9594b7-d2d2-426c-a533-38f0318f3033");
- }
- // Sheet3
- this.Sheet3.Controls.Add(this.epiGroupBox1);
- this.Sheet3.Controls.Add(this.bbbb);
- this.Sheet3.Controls.Add(this.epiButtonC1);
- this.Sheet3.Controls.SetChildIndex(this.epiButtonC1, 0);
- this.Sheet3.Controls.SetChildIndex(this.bbbb, 1);
- this.Sheet3.Controls.SetChildIndex(this.epiGroupBox1, 1);
- this.Sheet3.AutoScroll = true;
- Infragistics.Win.UltraWinDock.DockableControlPane local3 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet3, "42938545-be6b-40c2-bccc-d521b3d1b0b8", customSheets);
- if ((local3 != null))
- {
- Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet3);
- local3.Text = "";
- local3.TextTab = "Sheet3";
- Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local3, "baseDockManagerba9594b7-d2d2-426c-a533-38f0318f3033");
- }
- // ice.core.session.dll
- // ice.contracts.bo.dynamicquery.dll
- // grdMain
- this.grdMain.Top = 68;
- this.grdMain.Left = 993;
- this.grdMain.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.grdMain.Width = 1648;
- this.grdMain.Height = 652;
- this.grdMain.Text = "";
- // epiGroupBox1
- this.epiGroupBox1.Top = 0;
- this.epiGroupBox1.Left = 3;
- this.epiGroupBox1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.epiGroupBox1.Width = 202;
- this.epiGroupBox1.Height = 82;
- this.epiGroupBox1.Text = "Batch Selection";
- this.epiGroupBox1.Controls.Add(this.btnSelectAll);
- this.epiGroupBox1.Controls.Add(this.btnUnSelectAl);
- this.epiGroupBox1.Controls.SetChildIndex(this.btnSelectAll, 0);
- this.epiGroupBox1.Controls.SetChildIndex(this.btnUnSelectAl, 0);
- // btnSelectAll
- this.btnSelectAll.Top = 17;
- this.btnSelectAll.Left = 14;
- this.btnSelectAll.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.btnSelectAll.Width = 156;
- this.btnSelectAll.Height = 27;
- this.btnSelectAll.Text = "Select Selection";
- // btnUnSelectAl
- this.btnUnSelectAl.Top = 49;
- this.btnUnSelectAl.Left = 14;
- this.btnUnSelectAl.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.btnUnSelectAl.Width = 156;
- this.btnUnSelectAl.Height = 27;
- this.btnUnSelectAl.Text = "Unselect Selection";
- // bbbb
- this.bbbb.Top = 1;
- this.bbbb.Left = 207;
- this.bbbb.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.bbbb.Width = 376;
- this.bbbb.Height = 78;
- this.bbbb.Text = "Job Creation";
- this.bbbb.Controls.Add(this.btnCreateJobs);
- this.bbbb.Controls.SetChildIndex(this.btnCreateJobs, 0);
- // btnCreateJobs
- this.btnCreateJobs.Top = 25;
- this.btnCreateJobs.Left = 120;
- this.btnCreateJobs.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- this.btnCreateJobs.Width = 140;
- this.btnCreateJobs.Height = 33;
- this.btnCreateJobs.Text = "Create Jobs";
- // erp.contracts.bo.jobentry.dll
- // erp.contracts.bo.lotselectupdate.dll
- // ice.contracts.bo.ud08.dll
- // ice.contracts.lib.boreader.dll
- // epiButtonC1
- this.epiButtonC1.Top = -121;
- this.epiButtonC1.Left = 844;
- this.epiButtonC1.Width = 74;
- this.epiButtonC1.Height = 33;
- this.epiButtonC1.Text = "epiButtonC1";
- // listPanel1
- Ice.Lib.Framework.EpiBasePanel local4 = ((Ice.Lib.Framework.EpiBasePanel)(personalizeCustomizeManager.ControlsHT["5bc5702d-bf5b-4bcd-8555-a5be760a5449"]));
- local4.Top = 232;
- local4.Left = 64;
- local4.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- local4.Width = 520;
- local4.Height = 352;
- System.Collections.Hashtable nativeSheets = personalizeCustomizeManager.NativeSheetsDCPsHT;
- Infragistics.Win.UltraWinDock.DockableControlPane local5 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.GetDockableControlPane(local4, "5bc5702d-bf5b-4bcd-8555-a5be760a5449", nativeSheets);
- if ((local5 != null))
- {
- local4.Visible = false;
- Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddToSheetsVisToggleHT(personalizeCustomizeManager, local4);
- }
- // detailPanel1
- Ice.Lib.Framework.EpiBasePanel local6 = ((Ice.Lib.Framework.EpiBasePanel)(personalizeCustomizeManager.ControlsHT["d5488fbc-e47b-46b6-aa3e-9ab7d923315a"]));
- local6.Top = 112;
- local6.Left = 488;
- local6.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- local6.Width = 488;
- local6.Height = 192;
- Infragistics.Win.UltraWinDock.DockableControlPane local7 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.GetDockableControlPane(local6, "d5488fbc-e47b-46b6-aa3e-9ab7d923315a", nativeSheets);
- if ((local7 != null))
- {
- local6.Visible = false;
- Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddToSheetsVisToggleHT(personalizeCustomizeManager, local6);
- }
- // UD01Form
- Ice.Lib.Framework.EpiBaseForm local8 = ((Ice.Lib.Framework.EpiBaseForm)(personalizeCustomizeManager.ControlsHT["2dcd1674-5e34-4d98-b493-c75747027376"]));
- local8.Top = -4;
- local8.Left = -4;
- local8.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
- local8.Width = 1372;
- local8.Height = 748;
- local8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
- local8.Text = "Order Batching";
- // Finishing control initialization.
- topControl.FindForm().ResumeLayout();
- }
- public void DestroyGlobalVariables()
- {
- this.Sheet1 = null;
- this.Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033 = null;
- this.Sheet2 = null;
- this.Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6 = null;
- this.Sheet3 = null;
- this.Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8 = null;
- this.grdMain = null;
- this.grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44 = null;
- this.epiGroupBox1 = null;
- this.epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe = null;
- this.btnSelectAll = null;
- this.btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4 = null;
- this.btnUnSelectAl = null;
- this.btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578 = null;
- this.bbbb = null;
- this.bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536 = null;
- this.btnCreateJobs = null;
- this.btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c = null;
- this.epiButtonC1 = null;
- this.epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36 = null;
- this.csm = null;
- this.oTrans = null;
- this.UD01Form = null;
- this.baseToolbarsManager = null;
- this.UD01_Column = null;
- this.UD01_Row = null;
- this.UD01Attch_Column = null;
- this.AutoAttachUD01_Row = null;
- this.BpmData_Column = null;
- this.CallContextBpmData_Row = null;
- this.Client_Column = null;
- this.CallContextClientData_Row = null;
- }
- public static string[] GetTranslatableStrings()
- {
- return new string[] {
- "",
- "Sheet1",
- "Sheet2",
- "Sheet3",
- "Batch Selection",
- "Select Selection",
- "Unselect Selection",
- "Job Creation",
- "Create Jobs",
- "epiButtonC1",
- "Order Batching"};
- }
- public static string GetStringByID(string id)
- {
- return "";
- }
- // ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
- // Begin Wizard Added Module Level Variables **
- private EpiBaseAdapter oTrans_adapter;
- private EpiDataView edvCallContextBpmData;
- // End Wizard Added Module Level Variables **
- private string m_inputString;
- private System.Collections.Hashtable m_gridContextMenu;
- // Add Custom Module Level Variables Here **
- private DataTable m_dtOrdersToBatch;
- private string m_plantLotSeqUpdate;
- public void InitializeCustomCode()
- {
- // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
- // Begin Wizard Added Variable Initialization
- this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
- this.oTrans_adapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_adapter"]));
- this.oTrans_adapter.BeforeAdapterMethod += new BeforeAdapterMethod(this.oTrans_adapter_BeforeAdapterMethod);
- this.edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
- this.edvCallContextBpmData.EpiViewNotification += new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
- // End Wizard Added Variable Initialization
- // Begin Wizard Added Custom Method Calls
- m_plantLotSeqUpdate = " ";
- GetData(false);
- this.btnSelectAll.Click += new System.EventHandler(this.btnSelectAll_Click);
- this.btnUnSelectAl.Click += new System.EventHandler(this.btnUnSelectAl_Click);
- this.btnCreateJobs.Click += new System.EventHandler(this.btnCreateJobs_Click);
- LoadGridContextMenuHashTable();
- this.grdMain.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_AfterCellUpdate);
- this.grdMain.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_CellChange);
- this.grdMain.AfterSelectChange += GridRowSelected;
- this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_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.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
- this.oTrans_adapter.BeforeAdapterMethod -= new BeforeAdapterMethod(this.oTrans_adapter_BeforeAdapterMethod);
- this.oTrans_adapter = null;
- this.btnSelectAll.Click -= new System.EventHandler(this.btnSelectAll_Click);
- this.btnUnSelectAl.Click -= new System.EventHandler(this.btnUnSelectAl_Click);
- this.btnCreateJobs.Click -= new System.EventHandler(this.btnCreateJobs_Click);
- this.grdMain.AfterCellUpdate -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_AfterCellUpdate);
- this.grdMain.CellChange -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_CellChange);
- this.grdMain.AfterSelectChange -= GridRowSelected;
- this.edvCallContextBpmData.EpiViewNotification -= new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
- this.edvCallContextBpmData = null;
- this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
- // End Wizard Added Object Disposal
- // Begin Custom Code Disposal
- // End Custom Code Disposal
- }
- private void UD01Form_Load(object sender, EventArgs args)
- {
- HideStuff();
- SetVersionNumber();
- SetExtendedProperties();
- DisableButtons();
- UD01Form.WindowState = FormWindowState.Maximized;
- grdMain.Dock = DockStyle.Fill;
- GetData(false);
- }
- #region Selection Order - Population and Validation
- private void GridRowSelected(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e){
- if(typeof(UltraGridRow)!=e.Type)
- return; // Didn't select a row.
- if(grdMain.Selected.Rows.Count==0)
- return; // Nothing is selected.
- var selectedRow = grdMain.Selected.Rows[grdMain.Selected.Rows.Count-1];
- var selectionOrder = selectedRow.Cells["Calculated_SelectionOrder"];
- selectionOrder.Value = GetNextSelectionOrder();
- }
- private int GetNextSelectionOrder(){
- var maxOrder = 0;
- // Loop through the grid and find the highest current selection
- foreach(var row in grdMain.Rows){
- var currentOrder = Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value);
- if(currentOrder > maxOrder)
- maxOrder=currentOrder;
- }
- // Add 1 to get the next position
- return maxOrder+1;
- }
- private void ValidateSelectionOrder(){
- var maxSelection = GetNextSelectionOrder()-1; // We want the highest current, not the next value.
- var selectedRows = 0;
- foreach(var row in grdMain.Rows)
- if(Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value)!=0)
- selectedRows++;
- if(selectedRows!=maxSelection)
- throw new Exception(string.Format("You have selected {0} rows. Max order is {1}. Check sequence for gaps.", selectedRows, maxSelection));
- }
- #endregion
- private void DisableButtons()
- {
- Infragistics.Win.UltraWinToolbars.UltraToolbarsManager Toolbar;
- object obj = typeof(Ice.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolbarsManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD01Form, null);
- Toolbar = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)obj;
- //Toolbar.Tools["NewTool"].SharedProps.Enabled = false;
- //Toolbar.Tools["SaveTool"].SharedProps.Enabled = false;
- //Toolbar.Tools["DeleteTool"].SharedProps.Enabled = false;
- foreach ( Infragistics.Win.UltraWinToolbars.ToolBase tool in Toolbar.Tools )
- {
- if ( tool.Key.ToLower().Contains("refresh") || tool.Key.ToLower().Contains("customiz") || tool.Key.ToLower().Contains("clear") || tool.Key.ToLower().Contains("help") || tool.Key.ToLower().Contains("about"))
- {
- }else
- {
- tool.SharedProps.Enabled = false;
- }
- }
- }
- private void HideStuff()
- {
- try {
- System.Windows.Forms.Control con = null;
- foreach (Control con_loopVariable in UD01Form.Controls) {
- con = con_loopVariable;
- if ((con.Name.Trim().ToLower() == "windowdockingarea1")) {
- con.Visible = false;
- }
- }
- } catch ( Exception ex )
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void SetVersionNumber()
- {
- string version = "?.?";
- string custName = oTrans.EpiBaseForm.CustomizationName;
- if ((custName.LastIndexOf("_") > 0)) {
- version = custName.Substring(custName.LastIndexOf("_") + 1, custName.Length - custName.LastIndexOf("_") - 1);
- }
- UD01Form.Text = UD01Form.Text + " - Version " + version;
- }
- private void SetExtendedProperties()
- {
- //edvUD01.dataView.Table.Columns["Number01"].ExtendedProperties["Format"] = ">>>>>>>>9";
- //edvUD01.dataView.Table.Columns["Number02"].ExtendedProperties["Format"] = ">>>>>>>>9";
- //edvUD01.dataView.Table.Columns["ShortChar01"].ExtendedProperties["ReadOnly"] = true;
- }
- private void GetData( bool bClear )
- {
- try
- {
- System.Collections.Hashtable parameters = new System.Collections.Hashtable();
- if ( bClear )
- {
- parameters.Add("pcompany", "None" );
- }
- else
- {
- parameters.Add("pcompany", ((Ice.Core.Session)oTrans.Session).CompanyID );
- }
- grdMain.DataSource = null;
- DataTable dt = GetQueryData("CPEToBatchOrders", parameters);
- DataTable dtExistingCast = GetQueryData("CPEExistingCasts", parameters);
- DataRow[] needJobs = dt.Select("Calculated_JobNumHide = '~'");
- m_dtOrdersToBatch = dt.Clone();
- foreach ( DataRow needJob in needJobs )
- {
- DataRow[] hasCastRow = dtExistingCast.Select("OrderDtl_PerConLastName_c = '" + needJob["Calculated_Contact_Last_Name"].ToString() + "'");
- if ( hasCastRow.Length > 0 )
- {
- //needJob["Calculated_OnHand_Cast_LotNum"] = hasCastRow[0]["PartLot_LotNum"];
- if ( needJob["Calculated_OnHand_Cast_LotNum"].ToString().ToLower() == hasCastRow[0]["PartLot_LotNum"].ToString().ToLower() )
- {
- needJob["Calculated_Left_Hide"] = hasCastRow[0]["OrderDtl_CPE_DspMouldLeft_c"];
- needJob["Calculated_Right_Hide"] = hasCastRow[0]["OrderDtl_CPE_DspMouldRight_c"];
- }
- needJob["Calculated_HasExistingCast_Hide"] = true;
- }
- m_dtOrdersToBatch.ImportRow(needJob);
- }
- dt.Clear();
- SetGridContextMenu(ref m_dtOrdersToBatch);
- grdMain.DataSource = m_dtOrdersToBatch;
- FormatGrid(ref grdMain);
- }catch ( Exception ex )
- {
- MessageBox.Show("GetData error: " + ex.Message);
- }
- }
- private DataTable GetQueryData(string baqName, System.Collections.Hashtable parameters)
- {
- // ** Place Event Handling Code Here **
- Ice.Core.Session session = (Ice.Core.Session)oTrans.Session;
- Ice.BO.DynamicQueryDataSet baqQuery = null;
- Ice.BO.QueryExecutionDataSet executionDS = null;
- string caption = string.Empty;
- Ice.Adapters.DynamicQueryAdapter adDynamicQuery = new Ice.Adapters.DynamicQueryAdapter(this.oTrans);
- adDynamicQuery.BOConnect();
- try
- {
- adDynamicQuery.ClearDynamicQueryData();
- baqQuery = adDynamicQuery.GetQueryDesignData(baqName) as Ice.BO.DynamicQueryDataSet;
- executionDS = adDynamicQuery.GetQueryExecutionParametersByID(baqName);
- if (baqQuery != null && executionDS != null)
- {
- for (int i = 0; i < executionDS.ExecutionParameter.Rows.Count; i++)
- {
- string executeParams = executionDS.ExecutionParameter[i]["ParameterID"].ToString().Trim().ToLower();
- if (parameters.Contains(executeParams))
- {
- executionDS.ExecutionParameter[i]["ParameterValue"] = parameters[executeParams].ToString();
- }
- }
- executionDS.AcceptChanges();
- adDynamicQuery.Execute(baqQuery, executionDS);
- }
- else
- {
- MessageBox.Show(baqName + " not found.");
- }
- //return m_adDynamicQuery.QueryResults.Tables[0];
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error running " + baqName + ":" + ex.Message);
- }
- DataTable dataTable = adDynamicQuery.QueryResults.Tables[0];//.Copy();
- adDynamicQuery.Dispose();
- adDynamicQuery = null;
- return dataTable;
- }
- private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
- {
- if ( args.Tool.Key.Trim().ToLower().Contains("clear") )
- {
- ClearForm();
- }
- else if ( args.Tool.Key.ToLower().Contains("refresh") )
- {
- GetData(false);
- }
- }
- private void ClearForm()
- {
- GetData(true);
- }
- private void oTrans_adapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)
- {
- args.Cancel = true;
- }
- private void FormatGrid( ref Ice.Lib.Framework.EpiUltraGrid grid)
- {
- try
- {
- grid.DisplayLayout.Override.AllowMultiCellOperations = Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.Copy | Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.Paste;
- foreach ( Infragistics.Win.UltraWinGrid.UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns )
- {
- if ( col.Header.Caption.Contains("_") )
- {
- col.Header.Caption = col.Header.Caption.Replace("_", " ");
- }
- if ( col.Header.Caption.Trim().ToLower().EndsWith("hide") || col.Key.Trim().ToLower().EndsWith("hide") || col.Key == "Calculated_OnHand_Cast_LotNum")
- {
- col.Hidden = true;
- }
- if ( col.Header.Caption.Trim().ToLower() == "use existing cast" )// || col.Key.Trim().ToLower() == "calculated_box_number" )
- {
- foreach ( Infragistics.Win.UltraWinGrid.UltraGridRow grRow in grid.Rows )
- {
- if ( string.IsNullOrEmpty(grRow.Cells["Calculated_OnHand_Cast_LotNum"].Value.ToString().Trim()) )
- {
- grRow.Cells["Calculated_Use_Existing_Cast"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- else
- {
- // grRow.Cells["Calculated_Use_Existing_Cast"].Value = true;
- // grRow.Cells["Calculated_Batch"].Value = false;
- }
- }
- }
- else
- {
- if ( col.Header.Caption.Trim().ToLower() == "batch" || col.Header.Caption.Trim().ToLower()=="selectionorder")// || col.Key.Trim().ToLower() == "calculated_box_number" )
- {}
- else
- {
- col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- }
- }
- /* foreach ( Infragistics.Win.UltraWinGrid.UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns )
- {
- if ( col.Header.Caption == "ReceiptQty" )
- {
- col.Format = "###,##0.00";
- }
- else if ( col.Header.Caption == "Completed" )
- {
- }
- else
- {
- col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- }
- foreach ( Infragistics.Win.UltraWinGrid.UltraGridRow row in grid.Rows )
- {
- if ( (Convert.ToString(row.Cells["Calculated_ProcessHide"].Value)).Trim().ToString() == "true")
- {
- row.Cells["Calculated_Completed"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- row.Cells["Calculated_ReceiptQty"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- }*/
- }catch ( Exception ex )
- {
- //MessageBox.Show("FormatGrid error: " + ex.Message);
- }
- }
- private void SetGridContextMenu(ref DataTable table)
- {
- try
- {
- foreach ( System.Collections.DictionaryEntry dic in m_gridContextMenu )
- {
- if ( table.Columns.Contains(dic.Key.ToString() ) )
- {
- table.Columns[dic.Key.ToString()].ExtendedProperties["Like"] = dic.Value.ToString();
- table.Columns[dic.Key.ToString()].ExtendedProperties["EpiContextMenuKey"] = dic.Value.ToString();
- }
- }
- }catch (Exception ex )
- {
- //MessageBox.Show("SetGridContextMenu error: " + ex.Message);
- }
- }
- private void LoadGridContextMenuHashTable()
- {
- try
- {
- m_gridContextMenu = new System.Collections.Hashtable();
- m_gridContextMenu.Add("Company_Company", "Company.CompanyID");
- m_gridContextMenu.Add("Calculated_JobNumHide", "JobHead.JobNum");
- m_gridContextMenu.Add("ProjectID", "Project.ProjectID");
- m_gridContextMenu.Add("Calculated_Partnum", "Part.PartNum");
- m_gridContextMenu.Add("Calculated_OrderNum", "OrderHed.OrderNum");
- m_gridContextMenu.Add("Customer.CustID", "Calculated_CustID");
- m_gridContextMenu.Add("SupplierNum", "Vendor.VendorNum");
- }catch ( Exception ex )
- {
- MessageBox.Show("LoadGrid Context Menu Hash error: " + ex.Message);
- }
- }
- private void btnSelectAll_Click(object sender, System.EventArgs args){
- foreach(var row in grdMain.Rows){
- var ordered = Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value);
- if(ordered!=0){
- row.Cells["Calculated_Batch"].Value = true;
- row.Update();
- }
- }
- }
- private void btnUnSelectAl_Click(object sender, System.EventArgs args){
- foreach(var row in grdMain.Rows){
- row.Cells["Calculated_Batch"].Value = false;
- row.Update();
- }
- }
- private void btnCreateJobs_Click(object sender, System.EventArgs args){
- try{
- // This will generate exceptions if there are
- // errors in the ordering.
- ValidateSelectionOrder();
- CreateJobs();
- } catch(Exception ex){
- MessageBox.Show(ex.Message);
- }
- }
- private bool GetLatestRev(string partNum, out string rev)
- {
- bool hasRev = false;
- rev = "";
- try
- {
- System.Collections.Hashtable parameters = new System.Collections.Hashtable();
- parameters.Add("ppartnum", partNum );
- DataTable dt = GetQueryData("CPELatestRev", parameters);
- if ( dt.Rows.Count > 0 )
- {
- rev = dt.Rows[0]["PartRev_RevisionNum"].ToString();
- hasRev = true;
- }
- }
- catch ( Exception ex )
- {
- MessageBox.Show("GetLastest rev error: " + ex.Message);
- }
- return hasRev;
- }
- private class ClassPosition
- {
- public bool bLeft;
- public bool bRight;
- public ClassPosition(bool right, bool left)
- {
- bLeft = left;
- bRight = right;
- }
- }
- private void CreateJobs()
- {
- string loc = "401";
- m_plantLotSeqUpdate = " ";
- try
- {
- bool bNewCastFromJobError = false;
- string strNewCastFromJobError = "\nOrder lines may need to be updated to select an existing cast.\n\n";
- int totalReq = 0;
- int totalCastExistReq = 0;
- DataRow[] batchRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = false", "Calculated_SelectionOrder ASC" );
- DataRow[] batchCastExistRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = true", "Calculated_SelectionOrder ASC");
- foreach ( DataRow batchRow in batchRows )
- {
- totalReq += Convert.ToInt32(batchRow["Calculated_Qty"]);
- }
- foreach ( DataRow batchCastExistRow in batchCastExistRows )
- {
- totalCastExistReq += Convert.ToInt32(batchCastExistRow["Calculated_Qty"]);
- }
- string messageAsk = "";
- if ( batchRows.Length > 0 )
- {
- messageAsk = "Batch " + totalReq.ToString().Trim() + " parts into groups of 10 with a new cast from " + batchRows.Length.ToString().Trim() + " order release lines?";
- }
- if ( batchCastExistRows.Length > 0 )
- {
- if ( messageAsk == "" )
- {
- messageAsk = "Batch " + totalCastExistReq.ToString().Trim() + " parts into groups of 10 with a existing casts from " + batchCastExistRows.Length.ToString().Trim() + " order release lines?";
- }
- else
- {
- messageAsk += "\n and batch " + totalCastExistReq.ToString().Trim() + " parts into groups of 10 with a existing casts from " + batchCastExistRows.Length.ToString().Trim() + " order release lines?";
- }
- }
- //find distincts existing cast numbers
- System.Collections.Hashtable existingCast = new System.Collections.Hashtable();
- foreach ( DataRow existRow in batchCastExistRows )
- {
- string theCast = existRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim();
- if ( !existingCast.Contains(theCast) )
- {
- existingCast.Add(theCast,Convert.ToInt32(existRow["Calculated_Qty"]));
- }
- else
- {
- existingCast[theCast] = Convert.ToInt32(existingCast[theCast]) + Convert.ToInt32(existRow["Calculated_Qty"]);
- }
- }
- if ( totalCastExistReq + totalReq <= 0 )
- {
- MessageBox.Show("Nothing selected to batch!");
- }
- else if ( MessageBox.Show(messageAsk,"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes )
- {
- Erp.Proxy.BO.JobEntryImpl boJobEntry = null;
- boJobEntry = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.JobEntryImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/jobentry.svc");
- Erp.BO.JobEntryDataSet dsJobEntry = null;
- Ice.Proxy.BO.UD08Impl boUD08 = null;
- boUD08 = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Ice.Proxy.BO.UD08Impl>((Ice.Core.Session)oTrans.Session, "ice/bo/UD08.svc");
- string message = " ";
- string currentJob = "";
- string currentLotNum = "";
- string firstJob = "";
- int numUOM = 0;
- int numJobs = 0;
- int jobBatchCount = 0;
- int rowCounter = 0;
- int castSpotCounter = 0;
- int numOfEA = 0;
- System.Collections.Hashtable castPosition = new System.Collections.Hashtable();
- System.Collections.Hashtable newCasts = new System.Collections.Hashtable();
- System.Collections.Hashtable newCastsCreated = new System.Collections.Hashtable();
- foreach ( DataRow batchRow in batchRows )
- {
- // see if we are triggered to create a next cast but we still have a right or left that will fit in
- // if the last row filled in a left or right perhpas the cast is now full
- if ( numUOM == 8 )
- {
- if ( castPosition.Count == 5 )// all rows full
- {
- numUOM = 0;
- rowCounter = 0;
- castSpotCounter = 0;
- }
- }
- else if ( numUOM == 0 )
- {
- if (castPosition.Contains(batchRow["Calculated_PerConIDHide"].ToString().Trim()))
- {
- ClassPosition cpCheck = (ClassPosition)castPosition[batchRow["Calculated_PerConIDHide"].ToString().Trim()];
- if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cpCheck.bRight == false) || ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cpCheck.bLeft == false ) )
- {
- castSpotCounter = 8;
- numUOM = 8;
- rowCounter = 4;
- }
- else
- {
- castPosition.Clear();
- }
- }
- else
- {
- castPosition.Clear();
- }
- }
- batchRow["Calculated_ProcessHide"] = true;
- numOfEA = Convert.ToInt32(batchRow["Calculated_Qty"]);
- numUOM = numUOM + Convert.ToInt32(batchRow["Calculated_Qty"]);
- if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
- {
- numUOM += 1;
- }
- ++rowCounter;
- castSpotCounter += numOfEA;
- if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
- {
- castSpotCounter += 1;
- }
- oTrans.PushStatusText("Processing Order " + batchRow["Calculated_OrderNum"].ToString() + " Line " + batchRow["Calculated_OrderLine"].ToString() + "...", true);
- if ( rowCounter == 1 )
- {
- ++numJobs;
- jobBatchCount = 10;
- if ( totalReq < 10 )
- {
- jobBatchCount = totalReq;
- }
- dsJobEntry = new Erp.BO.JobEntryDataSet();
- boJobEntry.GetNextJobNum(out currentJob);
- boJobEntry.GetNewJobHead(dsJobEntry);
- if ( firstJob == "" )
- {
- firstJob = currentJob;
- }
- dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"] = currentJob;
- dsJobEntry.Tables["JobHead"].Rows[0]["Plant"] = ((Ice.Core.Session)oTrans.Session).PlantID;
- dsJobEntry.Tables["JobHead"].Rows[0]["PartNum"] = batchRow["Calculated_PartNum"];
- boJobEntry.ChangeJobHeadPartNum(dsJobEntry);
- dsJobEntry.Tables["JobHead"].Rows[0]["ReqDueDate"] = batchRow["Calculated_Need_By_Date"];
- currentLotNum = CreateNewPlantLotNumber( batchRow["Calculated_CastPartNumHide"].ToString(), currentJob, Convert.ToDateTime(batchRow["Calculated_Need_By_Date"]) );
- dsJobEntry.Tables["JobHead"].Rows[0]["CastLotNumber_c"] = currentLotNum;
- //MessageBox.Show("adding: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
- if ( !newCastsCreated.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- newCastsCreated.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), currentLotNum);
- // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
- }
- boJobEntry.Update(dsJobEntry);
- string rev;
- if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
- {
- boJobEntry.GetDetails(currentJob, 0, "Method", 0, 0, "", 0, batchRow["Calculated_PartNum"].ToString(), rev, "", true, false, false, false);
- }
- // get job prod
- dsJobEntry = boJobEntry.GetByID(currentJob);
- // divide op qty by prod qty
- if ( jobBatchCount != 0 )
- {
- foreach ( DataRow oprRow in dsJobEntry.Tables["JobOper"].Rows )
- {
- oprRow["RowMod"] = "U";
- oprRow["ProdStandard"] = Convert.ToDecimal(oprRow["ProdStandard"]) / Convert.ToDecimal(jobBatchCount);
- }
- boJobEntry.Update(dsJobEntry);
- }
- //set all material to fixedqty
- DataRow[] mtlRows = dsJobEntry.Tables["JobMtl"].Select("assemblyseq = 0 and fixedqty = 0");
- foreach ( DataRow mtlRow in mtlRows )
- {
- mtlRow["RowMod"] = "U";
- mtlRow["FixedQty"] = true;
- mtlRow["QtyPer"] = Convert.ToDecimal(mtlRow["QtyPer"]) * numOfEA;
- }
- boJobEntry.Update(dsJobEntry);
- AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), currentLotNum, castSpotCounter, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, true,"","");
- boJobEntry.InsertNewJobAsmbl(dsJobEntry, currentJob, 0,0,0);
- DataRow[] asmRows = dsJobEntry.Tables["JobAsmbl"].Select("RowMod = 'A'");
- asmRows[0]["PartNum"] = batchRow["Calculated_CastPartNumHide"];
- boJobEntry.ChangeJobAsmblPartNum(dsJobEntry);
- bool bHasRev = false;
- if ( GetLatestRev(batchRow["Calculated_CastPartNumHide"].ToString(), out rev) )
- {
- bHasRev = true;
- if ( asmRows[0]["RevisionNum"].ToString().Trim().ToLower() != rev.ToString().Trim().ToLower() )
- {
- asmRows[0]["RevisionNum"] = rev;
- boJobEntry.ChangeJobAsmblRevisionNum(dsJobEntry);
- }
- }
- int assemblySeq = Convert.ToInt32(asmRows[0]["AssemblySeq"]);
- decimal qtyPer = 0.1M;
- if ( jobBatchCount != 0 )
- {
- Double pow = Math.Pow(10,7);
- Double truncated = Math.Truncate((1.0 / jobBatchCount) * pow ) / pow;
- //qtyPer = 1.0M / Convert.ToDecimal(jobBatchCount);
- qtyPer = Convert.ToDecimal(truncated);
- }
- asmRows[0]["QtyPer"] = qtyPer;
- boJobEntry.ChangeJobAsmblQtyPer(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- if ( bHasRev )//( GetLatestRev(batchRow["Calculated_CastPartNumHide"].ToString(), out rev) )
- {
- boJobEntry.GetDetails(currentJob,assemblySeq, "Method", 0, 0, "", 0, batchRow["Calculated_CastPartNumHide"].ToString(), rev, "", true, false, false, false);
- }
- dsJobEntry = boJobEntry.GetByID(currentJob);
- AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_CastPartNumHide"].ToString(),1,0, currentLotNum, "");
- castPosition.Clear();
- if ( !castPosition.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- bool right = true;
- bool left = true;
- if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
- {
- right = false;
- }
- else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
- {
- left = false;
- }
- ClassPosition cp = new ClassPosition(right, left);
- castPosition.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), cp);
- // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
- }
- }
- else
- {
- if ( !newCastsCreated.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- newCastsCreated.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), currentLotNum);
- // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
- }
- DataRow[] jobPartExists = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- if ( jobPartExists.Length <= 0 )
- {
- //MessageBox.Show("584 add " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
- }
- else
- {
- //MessageBox.Show("589 update " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- UpdateJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
- }
- DataRow[] jobPartRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- // get job prod
- AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
- // if this is UOM left and a UOM right exists add it to the same cast
- // if this is UOM right and a UOM left exists add it to the same cast
- // set the castSpotCounter to a different value
- if ( !castPosition.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- bool right = true;
- bool left = true;
- if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
- {
- right = false;
- }
- else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
- {
- left = false;
- }
- castPosition.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), new ClassPosition(right, left));
- // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), currentLotNum, castSpotCounter, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, true,"","");
- }
- else
- {
- ClassPosition cp = (ClassPosition)castPosition[batchRow["Calculated_PerConIDHide"].ToString().Trim()];
- if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cp.bRight == false) || ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cp.bLeft == false ) )
- {
- cp.bLeft = true;
- cp.bRight = true;
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), currentLotNum, 2, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, true,"","");
- castSpotCounter -= 2;
- numUOM -= 2;
- }
- else
- {
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), currentLotNum, castSpotCounter, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, true,"","");
- }
- }
- // add in operations for this part
- dsJobEntry = boJobEntry.GetByID(currentJob);
- string rev;
- bool bUpdate = false;
- if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
- {
- System.Collections.Hashtable parameters = new System.Collections.Hashtable();
- parameters.Add("ppartnum", batchRow["Calculated_PartNum"].ToString() );
- parameters.Add("previsionnum", rev );
- DataTable dtNewOps = GetQueryData("CPEPartOpr", parameters);
- foreach ( DataRow newOper in dtNewOps.Rows )
- {
- DataRow[] jobOperRows = dsJobEntry.Tables["JobOper"].Select("assemblyseq = 0 and OpCode = '" + newOper["Calculated_OpCode"].ToString() + "'");
- if ( jobOperRows.Length > 0 )
- {
- jobOperRows[0]["RowMod"] = "U";
- jobOperRows[0]["ProdStandard"] = Convert.ToDecimal(jobOperRows[0]["ProdStandard"]) + (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
- bUpdate = true;
- }
- else
- {
- // add in the new operation
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- boJobEntry.GetNewJobOper(dsJobEntry, currentJob,0);
- string refresh;
- boJobEntry.ChangeJobOperOpCode(newOper["Calculated_OpCode"].ToString(), out refresh, dsJobEntry);
- DataRow[] newOperRow = dsJobEntry.Tables["JobOper"].Select("RowMod = 'A'");
- boJobEntry.ChangeJobOperOpStdID(dsJobEntry);
- newOperRow[0]["ProdStandard"] = (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
- boJobEntry.ChangeJobOperProdStandard(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- }
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- DataTable dtNewMtl = GetQueryData("CPEPartMtl", parameters);
- bUpdate = false;
- foreach ( DataRow newMtl in dtNewMtl.Rows )
- {
- DataRow[] jobMtlRows = dsJobEntry.Tables["JobMtl"].Select("AssemblySeq = 0 and PartNum = '" + newMtl["Calculated_PartNum"].ToString() + "' and IUM = '" + newMtl["Calculated_UOM"].ToString() + "'");
- if ( jobMtlRows.Length > 0 )
- {
- //MessageBox.Show("653 increase mtl " + Convert.ToString(jobMtlRows[0]["QtyPer"]) + " + " + (Convert.ToString(newMtl["Calculated_QtyPer"]) + " * " + numOfEA.ToString()));
- jobMtlRows[0]["RowMod"] = "U";
- jobMtlRows[0]["QtyPer"] = Convert.ToDecimal(jobMtlRows[0]["QtyPer"]) + (Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA);
- bUpdate = true;
- }
- else
- {
- // add in new material
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- loc = "577";
- boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
- string str1; string str2;string str3; bool b1; bool b2; bool b3;
- string partNum = newMtl["Calculated_PartNum"].ToString();
- DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
- // newMtlRow[0]["PartNum"] = partNum;
- // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
- boJobEntry.ChangeJobMtlPartNum(dsJobEntry, true, ref partNum, new Guid("00000000-0000-0000-0000-000000000000"),"", "", out str1,out b1, out str2,out b2, out b3, out str3);
- if ( newMtlRow[0]["IUM"].ToString() != newMtl["Calculated_UOM"].ToString())
- {
- boJobEntry.ChangeJobMtlIUM(newMtl["Calculated_UOM"].ToString(), dsJobEntry);
- }
- newMtlRow[0]["FixedQty"] = true;
- newMtlRow[0]["QtyPer"] = Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA;
- boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- loc = "590";
- }
- }
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- }
- // add in materials for this part
- }
- }
- if (numUOM >= 10)
- {
- numUOM = 0;
- rowCounter = 0;
- castSpotCounter = 0;
- }
- --totalReq;
- oTrans.PopStatus();
- }
- numUOM = 0;
- jobBatchCount = 0;
- rowCounter = 0;
- castSpotCounter = 0;
- numOfEA = 0;
- // set the new R parts castnumber to the newly created one
- // add in existing casts used to the newCastCreated so R parts that use cast can use it
- DataRow[] addExistingReuseCasts = m_dtOrdersToBatch.Select("Calculated_OnHand_Cast_LotNum <> 'NEW CAST FROM JOB'");
- foreach ( DataRow addRow in addExistingReuseCasts )
- {
- if ( addRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim().Length > 0 )
- {
- if ( !newCastsCreated.Contains( addRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- newCastsCreated.Add(addRow["Calculated_PerConIDHide"].ToString().Trim(), addRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim());
- }
- }
- }
- DataRow[] setNewBatchRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = 'NEW CAST FROM JOB'");
- foreach ( DataRow rRow in setNewBatchRows )
- {
- if ( newCastsCreated.Contains( rRow["Calculated_PerConIDHide"].ToString().Trim() ))
- {
- rRow["Calculated_OnHand_Cast_LotNum"] = newCastsCreated[rRow["Calculated_PerConIDHide"].ToString().Trim()].ToString().Trim();
- rRow["Calculated_OnHand_Cast"] = newCastsCreated[rRow["Calculated_PerConIDHide"].ToString().Trim()].ToString().Trim() + "xx";
- }
- }
- existingCast = new System.Collections.Hashtable();
- foreach ( DataRow existRow in batchCastExistRows )
- {
- string theCast = existRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim();
- if ( theCast != "NEW CAST FROM JOB" )
- {
- if ( !existingCast.Contains(theCast) )
- {
- existingCast.Add(theCast,Convert.ToInt32(existRow["Calculated_Qty"]));
- }
- else
- {
- existingCast[theCast] = Convert.ToInt32(existingCast[theCast]) + Convert.ToInt32(existRow["Calculated_Qty"]);
- }
- }
- else
- {
- bNewCastFromJobError = true;
- strNewCastFromJobError += "OrderNum: " + existRow["Calculated_OrderNum"].ToString() + " OrderLine: " + existRow["Calculated_OrderLine"].ToString() + "\n";
- }
- }
- foreach ( System.Collections.DictionaryEntry dic in existingCast )
- {
- string theCast = dic.Key.ToString();
- DataRow[] castRows = m_dtOrdersToBatch.Select("Calculated_ProcessHide = 0 and Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = '" + theCast + "'");
- rowCounter = 0;
- // filter out to ensure same person is not on the same job
- while ( castRows.Length > 0 )
- {
- System.Collections.Hashtable personOnCast = new System.Collections.Hashtable();
- rowCounter = 0;
- foreach ( DataRow batchRow in castRows )
- {
- bool bAddRowToCast = true;
- bool bAddingOneMore = false;
- if ( personOnCast.Contains(batchRow["Calculated_PerConIDHide"].ToString()))
- {
- //skip this row and do it in the next job
- bAddRowToCast = false;
- ClassPosition cp = (ClassPosition)personOnCast[batchRow["Calculated_PerConIDHide"].ToString()];
- if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cp.bLeft == false) || (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cp.bRight == false) )
- {
- bAddRowToCast = true;
- bAddingOneMore = true;
- cp.bLeft = true;
- cp.bRight = true;
- }
- }
- if ( bAddRowToCast )
- {
- batchRow["Calculated_ProcessHide"] = true;
- if ( !personOnCast.Contains(batchRow["Calculated_PerConIDHide"].ToString()))
- {
- bool right = true;
- bool left = true;
- if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
- {
- right = false;
- }
- else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
- {
- left = false;
- }
- personOnCast.Add(batchRow["Calculated_PerConIDHide"].ToString(),new ClassPosition(right, left));
- }
- numOfEA = Convert.ToInt32(batchRow["Calculated_Qty"]);
- numUOM = numUOM + Convert.ToInt32(batchRow["Calculated_Qty"]);
- if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
- {
- numUOM += 1;
- }
- ++rowCounter;
- castSpotCounter += numOfEA;
- if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
- {
- castSpotCounter += 1;
- }
- oTrans.PushStatusText("Processing Order " + batchRow["Calculated_OrderNum"].ToString() + " Line " + batchRow["Calculated_OrderLine"].ToString() + "...", true);
- if ( rowCounter == 1 )
- {
- ++numJobs;
- jobBatchCount = castRows.Length;
- dsJobEntry = new Erp.BO.JobEntryDataSet();
- boJobEntry.GetNextJobNum(out currentJob);
- boJobEntry.GetNewJobHead(dsJobEntry);
- if ( firstJob == "" )
- {
- firstJob = currentJob;
- }
- dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"] = currentJob;
- dsJobEntry.Tables["JobHead"].Rows[0]["Plant"] = ((Ice.Core.Session)oTrans.Session).PlantID;
- dsJobEntry.Tables["JobHead"].Rows[0]["PartNum"] = batchRow["Calculated_PartNum"];
- boJobEntry.ChangeJobHeadPartNum(dsJobEntry);
- dsJobEntry.Tables["JobHead"].Rows[0]["ReqDueDate"] = batchRow["Calculated_Need_By_Date"];
- //currentLotNum = CreateNewLotNumber( batchRow["Calculated_CastPartNumHide"].ToString(), currentJob, Convert.ToDateTime(batchRow["Calculated_Need_By_Date"]) );
- dsJobEntry.Tables["JobHead"].Rows[0]["CastLotNumber_c"] = theCast;
- boJobEntry.Update(dsJobEntry);
- string rev;
- if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
- {
- boJobEntry.GetDetails(currentJob, 0, "Method", 0, 0, "", 0, batchRow["Calculated_PartNum"].ToString(), rev, "", true, false, false, false);
- }
- // get job prod
- dsJobEntry = boJobEntry.GetByID(currentJob);
- // divide op qty by prod qty
- if ( jobBatchCount != 0 )
- {
- foreach ( DataRow oprRow in dsJobEntry.Tables["JobOper"].Rows )
- {
- oprRow["RowMod"] = "U";
- oprRow["ProdStandard"] = Convert.ToDecimal(oprRow["ProdStandard"]) / Convert.ToDecimal(jobBatchCount);
- }
- boJobEntry.Update(dsJobEntry);
- }
- //set all material to fixedqty
- DataRow[] mtlRows = dsJobEntry.Tables["JobMtl"].Select("assemblyseq = 0 and fixedqty = 0");
- foreach ( DataRow mtlRow in mtlRows )
- {
- mtlRow["RowMod"] = "U";
- mtlRow["FixedQty"] = true;
- mtlRow["QtyPer"] = Convert.ToDecimal(mtlRow["QtyPer"]) * numOfEA;
- }
- boJobEntry.Update(dsJobEntry);
- AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), theCast, castSpotCounter, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, false, Convert.ToString(batchRow["Calculated_Left_Hide"]), Convert.ToString(batchRow["Calculated_Right_Hide"]));
- dsJobEntry = boJobEntry.GetByID(currentJob);
- // add cast as a co-part - not for rework job
- //AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_CastPartNumHide"].ToString(),1,0, theCast, "");
- // add the cast as a material - not for rework job
- /*boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
- string str1; string str2; bool b1; bool b2; bool b3;
- string partNum = batchRow["Calculated_CastPartNumHide"].ToString();
- DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
- // newMtlRow[0]["PartNum"] = partNum;
- // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
- boJobEntry.ChangeJobMtlPartNum(dsJobEntry, true, ref partNum, new Guid("00000000-0000-0000-0000-000000000000"),"", "", out str1, out b1, out str2,out b2, out b3);
- newMtlRow[0]["FixedQty"] = true;
- newMtlRow[0]["QtyPer"] = 1;
- boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
- boJobEntry.Update(dsJobEntry); */
- }
- else
- {
- DataRow[] jobPartExists = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- if ( jobPartExists.Length <= 0 )
- {
- //MessageBox.Show("584 add " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
- }
- else
- {
- //MessageBox.Show("589 update " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- UpdateJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
- }
- DataRow[] jobPartRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
- // get job prod
- AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
- CreateUD08Row( ref boUD08, batchRow["Calculated_PartNum"].ToString(), theCast, castSpotCounter, batchRow["Calculated_PerConIDHide"].ToString(),Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToString(batchRow["Calculated_SalesUM"]), numOfEA, false,Convert.ToString(batchRow["Calculated_Left_Hide"]), Convert.ToString(batchRow["Calculated_Right_Hide"]));
- // add in operations for this part
- dsJobEntry = boJobEntry.GetByID(currentJob);
- string rev;
- bool bUpdate = false;
- if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
- {
- System.Collections.Hashtable parameters = new System.Collections.Hashtable();
- parameters.Add("ppartnum", batchRow["Calculated_PartNum"].ToString() );
- parameters.Add("previsionnum", rev );
- DataTable dtNewOps = GetQueryData("CPEPartOpr", parameters);
- foreach ( DataRow newOper in dtNewOps.Rows )
- {
- DataRow[] jobOperRows = dsJobEntry.Tables["JobOper"].Select("assemblyseq = 0 and OpCode = '" + newOper["Calculated_OpCode"].ToString() + "'");
- if ( jobOperRows.Length > 0 )
- {
- jobOperRows[0]["RowMod"] = "U";
- jobOperRows[0]["ProdStandard"] = Convert.ToDecimal(jobOperRows[0]["ProdStandard"]) + (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
- bUpdate = true;
- }
- else
- {
- // add in the new operation
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- boJobEntry.GetNewJobOper(dsJobEntry, currentJob,0);
- string refresh;
- boJobEntry.ChangeJobOperOpCode(newOper["Calculated_OpCode"].ToString(), out refresh, dsJobEntry);
- DataRow[] newOperRow = dsJobEntry.Tables["JobOper"].Select("RowMod = 'A'");
- boJobEntry.ChangeJobOperOpStdID(dsJobEntry);
- newOperRow[0]["ProdStandard"] = (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
- boJobEntry.ChangeJobOperProdStandard(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- }
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- DataTable dtNewMtl = GetQueryData("CPEPartMtl", parameters);
- bUpdate = false;
- foreach ( DataRow newMtl in dtNewMtl.Rows )
- {
- DataRow[] jobMtlRows = dsJobEntry.Tables["JobMtl"].Select("AssemblySeq = 0 and PartNum = '" + newMtl["Calculated_PartNum"].ToString() + "' and IUM = '" + newMtl["Calculated_UOM"].ToString() + "'");
- if ( jobMtlRows.Length > 0 )
- {
- //MessageBox.Show("653 increase mtl " + Convert.ToString(jobMtlRows[0]["QtyPer"]) + " + " + (Convert.ToString(newMtl["Calculated_QtyPer"]) + " * " + numOfEA.ToString()));
- jobMtlRows[0]["RowMod"] = "U";
- jobMtlRows[0]["QtyPer"] = Convert.ToDecimal(jobMtlRows[0]["QtyPer"]) + (Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA);
- bUpdate = true;
- }
- else
- {
- // add in new material
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- }
- loc = "577";
- boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
- string str1; string str2; string str3; bool b1; bool b2; bool b3;
- string partNum = newMtl["Calculated_PartNum"].ToString();
- DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
- // newMtlRow[0]["PartNum"] = partNum;
- // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
- boJobEntry.ChangeJobMtlPartNum(dsJobEntry, true, ref partNum, new Guid("00000000-0000-0000-0000-000000000000"),"", "", out str1, out b1, out str2,out b2, out b3, out str3);
- if ( newMtlRow[0]["IUM"].ToString() != newMtl["Calculated_UOM"].ToString())
- {
- boJobEntry.ChangeJobMtlIUM(newMtl["Calculated_UOM"].ToString(), dsJobEntry);
- }
- newMtlRow[0]["FixedQty"] = true;
- newMtlRow[0]["QtyPer"] = Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA;
- boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- bUpdate = false;
- loc = "590";
- }
- }
- if ( bUpdate )
- {
- boJobEntry.Update(dsJobEntry);
- }
- // add in materials for this part
- }
- }
- castRows = m_dtOrdersToBatch.Select("Calculated_ProcessHide = 0 and Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = '" + theCast + "'");
- }// end of else
- } // end of foreach
- personOnCast.Clear();
- personOnCast = null;
- }// end while
- }
- string jobMessage = numJobs.ToString() + " jobs created from " + firstJob + " to " + currentJob;
- if ( bNewCastFromJobError )
- {
- jobMessage += "\n\nJobs for Reorder parts not created for the following orders. A New part must be created for the person during the same batching run.\n" + strNewCastFromJobError;
- }
- MessageBox.Show(jobMessage + message + m_plantLotSeqUpdate);
- if ( boJobEntry != null )
- {
- boJobEntry.Dispose();
- boJobEntry = null;
- }
- if ( dsJobEntry != null )
- dsJobEntry.Clear();
- if ( boUD08 != null )
- {
- boUD08.Dispose();
- boUD08 = null;
- }
- GetData(false);
- }
- }catch ( Exception ex )
- {
- MessageBox.Show(loc + " < Create Jobs error: " + ex.Message);
- }
- }
- private void CreateUD08Row( ref Ice.Proxy.BO.UD08Impl boUD08, string partNum, string lotNum, int mouldNum, string perCon, int orderNum, int orderLine, string salesUM, int numOfEA, bool createNew, string left, string right)
- {
- try
- {
- /*string leftOrRight = "Right";
- if ( salesUM.Trim().ToLower() == "right" )
- {
- leftOrRight = "Right";
- }*/
- //MessageBox.Show(mouldNum.ToString() + " <> " + numOfEA.ToString());
- for ( int count = 0; count < 2; ++count)//numOfEA; ++count)
- {
- Ice.BO.UD08DataSet dsUD08 = new Ice.BO.UD08DataSet();
- boUD08.GetaNewUD08(dsUD08);
- dsUD08.Tables["UD08"].Rows[0]["Key1"] = partNum;
- dsUD08.Tables["UD08"].Rows[0]["Key2"] = lotNum;
- dsUD08.Tables["UD08"].Rows[0]["Key3"] = mouldNum - count;
- dsUD08.Tables["UD08"].Rows[0]["Key4"] = orderNum.ToString();
- dsUD08.Tables["UD08"].Rows[0]["Key5"] = orderLine.ToString();
- dsUD08.Tables["UD08"].Rows[0]["Number01"] = Convert.ToInt32(mouldNum) - count;
- dsUD08.Tables["UD08"].Rows[0]["Number02"] = orderNum;
- dsUD08.Tables["UD08"].Rows[0]["Number03"] = orderLine;
- dsUD08.Tables["UD08"].Rows[0]["ShortChar01"] = perCon;
- dsUD08.Tables["UD08"].Rows[0]["ShortChar02"] = salesUM;
- if ((mouldNum - count) % 2 == 0)
- {
- dsUD08.Tables["UD08"].Rows[0]["ShortChar03"] = "Left";
- }
- else
- {
- dsUD08.Tables["UD08"].Rows[0]["ShortChar03"] = "Right";
- }
- try
- {
- boUD08.Update(dsUD08);
- }catch ( Exception ex1 )
- {
- if ( ex1.Message.Contains("uplicate") )
- {
- }
- else
- {
- MessageBox.Show("CreateUD08Row inner error: " + ex1.Message);
- }
- }
- /* if ( leftOrRight == "Right" )
- {
- leftOrRight = "Left";
- }
- else
- {
- leftOrRight = "Right";
- }*/
- }
- }catch ( Exception ex )
- {
- MessageBox.Show("CreateUD08Row error: " + ex.Message);
- }
- }
- private void UpdateJobPart(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int qty, int weight, string lotNum, string newcomment)
- {
- try
- {
- DataRow[] newRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + partNum + "'");
- if ( newRows.Length > 0 )
- {
- string comment = newRows[0]["Comment_c"].ToString();
- if ( comment.Length > 0 )
- {
- newRows[0]["Comment_c"] = comment + System.Environment.NewLine + newcomment;
- boJobEntry.Update(dsJobEntry);
- }
- }
- }catch ( Exception ex )
- {
- MessageBox.Show("Add Job Part Error: " + ex.Message);
- }
- }
- private void AddJobPart(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int qty, int weight, string lotNum, string comment)
- {
- try
- {
- boJobEntry.GetNewJobPart(dsJobEntry, dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"].ToString());
- DataRow[] newRows = dsJobEntry.Tables["JobPart"].Select("RowMod = 'A'");
- newRows[0]["PartNum"] = partNum;
- boJobEntry.ChangeJobPartPartNum(dsJobEntry);
- newRows[0]["LbrCostBase"] = weight;
- newRows[0]["MtlCostBase"] = weight;
- newRows[0]["CPE_CastNumber_c"] = lotNum;
- newRows[0]["Comment_c"] = comment;
- boJobEntry.Update(dsJobEntry);
- }catch ( Exception ex )
- {
- MessageBox.Show("Add Job Part Error: " + ex.Message);
- }
- }
- private void AddJobProd(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int orderNum, int orderLine, int orderRelNum)
- {
- try
- {
- boJobEntry.GetNewJobProd(dsJobEntry, dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"].ToString(), partNum, 0, 0, 0, "", "", 0);
- DataRow[] jobProdRows = dsJobEntry.Tables["JobProd"].Select("RowMod = 'A'");
- jobProdRows[0]["MakeToType"] = "ORDER";
- boJobEntry.ChangeJobProdMakeToType(dsJobEntry);
- jobProdRows[0]["OrderNum"] = orderNum;
- boJobEntry.ChangeJobProdOrderNum(dsJobEntry);
- jobProdRows[0]["OrderLine"] = orderLine;
- boJobEntry.ChangeJobProdOrderLine(dsJobEntry);
- jobProdRows[0]["OrderRelNum"] = orderRelNum;
- boJobEntry.ChangeJobProdOrderRelNum(dsJobEntry);
- boJobEntry.Update(dsJobEntry);
- }catch ( Exception ex )
- {
- MessageBox.Show("Add Job Part Error: " + ex.Message);
- }
- }
- private string CreateNewPlantLotNumber(string partNum, string jobNum, DateTime mfgDate)
- {
- string newLotNum = "";
- try
- {
- System.Collections.Hashtable parameters = new System.Collections.Hashtable();
- DataTable dt = GetQueryData("CPENextCastLot", parameters);
- int nextSequence = 1;
- if ( (dt.Rows[0]["PlantConfCtrl_CastLotSequence_c"]) != System.DBNull.Value )
- {
- nextSequence = Convert.ToInt32(dt.Rows[0]["PlantConfCtrl_CastLotSequence_c"]);
- }
- string plantIDentifier = "1";
- if ( dt.Rows[0]["PlantConfCtrl_CastLotPlantIdentifier_c"] != System.DBNull.Value )
- {
- plantIDentifier = Convert.ToString(dt.Rows[0]["PlantConfCtrl_CastLotPlantIdentifier_c"]);
- }
- string prefix = "AA";
- if ( dt.Rows[0]["PlantConfCtrl_CastLotPrefix_c"] != System.DBNull.Value )
- {
- prefix = Convert.ToString(dt.Rows[0]["PlantConfCtrl_CastLotPrefix_c"]);
- }
- newLotNum = string.Format("{0}{1}{2:00000}",prefix , plantIDentifier , nextSequence);
- bool recSelected = false;
- string where = "partnum = '" + partNum + "' and lotnum = '" + newLotNum + "'";
- DataSet ds = SearchFunctions.listLookup(oTrans,"LotSelectUpdate", out recSelected, false, where);
- while ( recSelected )
- {
- nextSequence += 1;
- if ( nextSequence >= 99999 )
- {
- nextSequence = 1;
- char[] bits = prefix.ToCharArray();
- if (bits.Length == 2)
- {
- switch (bits[1])
- {
- case 'Z':
- bits[1] = 'A';
- ++bits[0];
- if (bits[0] > 'Z')
- bits[0] = 'A';
- break;
- default:
- ++bits[1];
- break;
- }
- prefix = bits[0].ToString().Trim() + bits[1].ToString().Trim();
- }
- }
- newLotNum = string.Format("{0}{1}{2:00000}",prefix , plantIDentifier , nextSequence);
- where = "partnum = '" + partNum + "' and lotnum = '" + newLotNum + "'";
- ds = SearchFunctions.listLookup(oTrans,"LotSelectUpdate", out recSelected, false, where);
- m_plantLotSeqUpdate = String.Format("WARNING: Inform System Administrator that lot sequence values at plant level for CAST part need to be updated to following:\nPrefix: {0}\nSequence{1}",prefix,nextSequence + 1);
- }
- Erp.Proxy.BO.LotSelectUpdateImpl boLotSelectUpdate = null;
- boLotSelectUpdate = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.LotSelectUpdateImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/LotSelectUpdate.svc");
- Erp.BO.LotSelectUpdateDataSet dsLotSelectUpdate = new Erp.BO.LotSelectUpdateDataSet();
- boLotSelectUpdate.GetNewPartLot(dsLotSelectUpdate, partNum);
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["LotNum"] = newLotNum;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["Batch"] = jobNum;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["MfgDt"] = mfgDate;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["ExpirationDate"] = mfgDate.AddYears(5);
- boLotSelectUpdate.Update(dsLotSelectUpdate);
- dsLotSelectUpdate.Clear();
- boLotSelectUpdate.Dispose();
- }catch ( Exception ex )
- {
- MessageBox.Show("CreateNewLotNumber error: " + ex.Message);
- }
- return newLotNum;
- }
- private DataSet BOReaderData(string businessObject, string filter, string fieldList)
- {
- DataSet ds = new DataSet();
- Ice.Core.Session session = null;
- Ice.Proxy.Lib.BOReaderImpl boReader = null;
- try
- {
- session = (Ice.Core.Session)oTrans.Session;
- boReader = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>(session, "ice/lib/BOReader.svc");
- ds = boReader.GetRows("Erp:BO:" + businessObject, filter, fieldList);
- }
- catch (Exception ex)
- {
- MessageBox.Show("BOReader error: " + ex.Message);
- }
- finally
- {
- if (boReader != null)
- {
- boReader.Dispose();
- }
- }
- return ds;
- }
- private string IncrementLetters(string letters)
- {
- char[] bits = letters.ToCharArray();
- if (bits.Length == 2)
- {
- switch (bits[1])
- {
- case 'Z':
- bits[1] = 'A';
- ++bits[0];
- if (bits[0] > 'Z')
- bits[0] = 'A';
- break;
- default:
- ++bits[1];
- break;
- }
- letters = bits[0].ToString() + bits[1].ToString();
- }
- return letters;
- }
- private string CreateNewStdLotNumber(string partNum, string jobNum, DateTime mfgDate)
- {
- string newLotNum = "";
- try
- {
- Erp.Proxy.BO.LotSelectUpdateImpl boLotSelectUpdate = null;
- boLotSelectUpdate = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.LotSelectUpdateImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/LotSelectUpdate.svc");
- Erp.BO.LotSelectUpdateDataSet dsLotSelectUpdate = new Erp.BO.LotSelectUpdateDataSet();
- boLotSelectUpdate.GetNewPartLot(dsLotSelectUpdate, partNum);
- boLotSelectUpdate.GenerateNewLotNum(partNum, out newLotNum);
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["LotNum"] = newLotNum;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["Batch"] = jobNum;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["MfgDt"] = mfgDate;
- dsLotSelectUpdate.Tables["PartLot"].Rows[0]["ExpirationDate"] = mfgDate.AddYears(5);
- boLotSelectUpdate.Update(dsLotSelectUpdate);
- dsLotSelectUpdate.Clear();
- boLotSelectUpdate.Dispose();
- }catch ( Exception ex )
- {
- MessageBox.Show("CreateNewLotNumber error: " + ex.Message);
- }
- return newLotNum;
- }
- private void grdMain_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args)
- {
- if ( args.Cell.Column.Key == "Calculated_Use_Existing_Cast" )
- {
- args.Cell.Row.Cells["Calculated_Batch"].Value = args.Cell.Row.Cells["Calculated_Use_Existing_Cast"].Value;
- grdMain.ActiveRow.Update();
- }
- if ( args.Cell.Column.Key == "Calculated_Batch" )
- {
- if ( args.Cell.Row.Cells["Calculated_PartNum"].Value.ToString().ToUpper().EndsWith("R") )
- {
- if ( args.Cell.Row.Cells["Calculated_OnHand_Cast_LotNum"].Value.ToString().Trim().Length == 0 )
- {
- args.Cell.Row.Cells["Calculated_Use_Existing_Cast"].Value = true;
- args.Cell.Row.Cells["Calculated_OnHand_Cast_LotNum"].Value = "NEW CAST FROM JOB";
- args.Cell.Row.Cells["Calculated_OnHand_Cast"].Value = "NEW CAST FROM JOB";
- grdMain.ActiveRow.Update();
- }
- }
- }
- }
- private void grdMain_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args)
- {
- if ( args.Cell.Column.Key == "Calculated_Use_Existing_Cast" )
- {
- grdMain.ActiveRow.Update();
- }
- }
- private void edvCallContextBpmData_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
- {
- // ** Argument Properties and Uses **
- // view.dataView[args.Row]["FieldName"]
- // args.Row, args.Column, args.Sender, args.NotifyType
- // NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
- if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
- {
- if ((args.Row > -1))
- {
- }
- }
- }
- private void epiButtonC1_Click(object sender, System.EventArgs args)
- {
- MessageBox.Show(CreateNewPlantLotNumber("CAST", "TESTCreate", DateTime.Now));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement