· 8 years ago · Jan 11, 2018, 07:16 PM
1// **************************************************
2// Custom code for UD01Form
3// Created: 10/23/2014 2:16:50 PM
4// **************************************************
5using System;
6using System.ComponentModel;
7using System.Data;
8using System.Diagnostics;
9using System.Windows.Forms;
10using Ice.BO;
11using Ice.UI;
12using Ice.Lib.Customization;
13using Ice.Lib.ExtendedProps;
14using Ice.Lib.Framework;
15using Ice.Lib.Searches;
16using Ice.UI.FormFunctions;
17using System.Reflection;
18using Infragistics.Win.UltraWinGrid;
19
20public class Script
21{
22
23 private Ice.Lib.Customization.CustomScriptManager csm;
24
25 private Ice.UI.App.UD01Entry.Transaction oTrans;
26
27 private Ice.UI.App.UD01Entry.UD01Form UD01Form;
28
29 private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager baseToolbarsManager;
30
31 private System.Data.DataTable UD01_Column;
32
33 private Ice.Lib.Framework.EpiDataView UD01_Row;
34
35 private System.Data.DataTable UD01Attch_Column;
36
37 private Ice.Lib.Framework.EpiDataView AutoAttachUD01_Row;
38
39 private System.Data.DataTable BpmData_Column;
40
41 private Ice.Lib.Framework.EpiDataView CallContextBpmData_Row;
42
43 private System.Data.DataTable Client_Column;
44
45 private Ice.Lib.Framework.EpiDataView CallContextClientData_Row;
46
47 private Ice.Lib.Framework.EpiDockManagerPanel Sheet1;
48
49 private Ice.Lib.Framework.EpiDockManagerPanel Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033;
50
51 private Ice.Lib.Framework.EpiDockManagerPanel Sheet2;
52
53 private Ice.Lib.Framework.EpiDockManagerPanel Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6;
54
55 private Ice.Lib.Framework.EpiDockManagerPanel Sheet3;
56
57 private Ice.Lib.Framework.EpiDockManagerPanel Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8;
58
59 private Ice.Lib.Framework.EpiUltraGrid grdMain;
60
61 private Ice.Lib.Framework.EpiUltraGrid grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44;
62
63 private Ice.Lib.Framework.EpiGroupBox epiGroupBox1;
64
65 private Ice.Lib.Framework.EpiGroupBox epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe;
66
67 private Ice.Lib.Framework.EpiButton btnSelectAll;
68
69 private Ice.Lib.Framework.EpiButton btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4;
70
71 private Ice.Lib.Framework.EpiButton btnUnSelectAl;
72
73 private Ice.Lib.Framework.EpiButton btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578;
74
75 private Ice.Lib.Framework.EpiGroupBox bbbb;
76
77 private Ice.Lib.Framework.EpiGroupBox bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536;
78
79 private Ice.Lib.Framework.EpiButton btnCreateJobs;
80
81 private Ice.Lib.Framework.EpiButton btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c;
82
83 private Ice.Lib.Framework.EpiButton epiButtonC1;
84
85 private Ice.Lib.Framework.EpiButton epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36;
86
87 public void InitializeGlobalVariables(Ice.Lib.Customization.CustomScriptManager csm)
88 {
89 this.csm = csm;
90 this.oTrans = ((Ice.UI.App.UD01Entry.Transaction)(this.csm.GetGlobalInstance("oTrans")));
91 this.UD01Form = ((Ice.UI.App.UD01Entry.UD01Form)(this.csm.GetGlobalInstance("UD01Form")));
92 this.baseToolbarsManager = ((Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)(this.csm.GetGlobalInstance("baseToolbarsManager")));
93 this.UD01_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("UD01_Column")));
94 this.UD01_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("UD01_Row")));
95 this.UD01Attch_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("UD01Attch_Column")));
96 this.AutoAttachUD01_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("AutoAttachUD01_Row")));
97 this.BpmData_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("BpmData_Column")));
98 this.CallContextBpmData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextBpmData_Row")));
99 this.Client_Column = ((System.Data.DataTable)(this.csm.GetGlobalInstance("Client_Column")));
100 this.CallContextClientData_Row = ((Ice.Lib.Framework.EpiDataView)(this.csm.GetGlobalInstance("CallContextClientData_Row")));
101 Ice.Lib.Customization.PersonalizeCustomizeManager personalizeCustomizeManager = this.csm.PersonalizeCustomizeManager;
102 System.Windows.Forms.Control topControl = personalizeCustomizeManager.TopControl;
103 topControl.FindForm().SuspendLayout();
104 // Creating custom targets.
105 this.Sheet1 = new Ice.Lib.Framework.EpiDockManagerPanel();
106 this.Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033 = this.Sheet1;
107 System.Collections.Hashtable customControls = personalizeCustomizeManager.CustControlMan.CustomControlsHT;
108 customControls.Add("ba9594b7-d2d2-426c-a533-38f0318f3033", this.Sheet1);
109 System.Collections.Hashtable controlsHT = personalizeCustomizeManager.ControlsHT;
110 controlsHT.Add("ba9594b7-d2d2-426c-a533-38f0318f3033", this.Sheet1);
111 this.Sheet1.Name = "Sheet1";
112 this.Sheet1.EpiGuid = "ba9594b7-d2d2-426c-a533-38f0318f3033";
113 this.Sheet2 = new Ice.Lib.Framework.EpiDockManagerPanel();
114 this.Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6 = this.Sheet2;
115 customControls.Add("7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", this.Sheet2);
116 controlsHT.Add("7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", this.Sheet2);
117 this.Sheet2.Name = "Sheet2";
118 this.Sheet2.EpiGuid = "7b1b5b5f-0912-43ef-b10b-cc361e21fbe6";
119 this.Sheet3 = new Ice.Lib.Framework.EpiDockManagerPanel();
120 this.Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8 = this.Sheet3;
121 customControls.Add("42938545-be6b-40c2-bccc-d521b3d1b0b8", this.Sheet3);
122 controlsHT.Add("42938545-be6b-40c2-bccc-d521b3d1b0b8", this.Sheet3);
123 this.Sheet3.Name = "Sheet3";
124 this.Sheet3.EpiGuid = "42938545-be6b-40c2-bccc-d521b3d1b0b8";
125 this.grdMain = new Ice.Lib.Framework.EpiUltraGrid();
126 this.grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44 = this.grdMain;
127 customControls.Add("78ea3de5-e734-43e7-adbc-a4b06d4ebd44", this.grdMain);
128 controlsHT.Add("78ea3de5-e734-43e7-adbc-a4b06d4ebd44", this.grdMain);
129 this.grdMain.Name = "grdMain";
130 this.grdMain.EpiGuid = "78ea3de5-e734-43e7-adbc-a4b06d4ebd44";
131 this.epiGroupBox1 = new Ice.Lib.Framework.EpiGroupBox();
132 this.epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe = this.epiGroupBox1;
133 customControls.Add("aa67cac3-28aa-46c0-996a-77aa548defbe", this.epiGroupBox1);
134 controlsHT.Add("aa67cac3-28aa-46c0-996a-77aa548defbe", this.epiGroupBox1);
135 this.epiGroupBox1.Name = "epiGroupBox1";
136 this.epiGroupBox1.EpiGuid = "aa67cac3-28aa-46c0-996a-77aa548defbe";
137 this.btnSelectAll = new Ice.Lib.Framework.EpiButton();
138 this.btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4 = this.btnSelectAll;
139 customControls.Add("27f11a92-d512-4acd-9baa-dd85ea939ee4", this.btnSelectAll);
140 controlsHT.Add("27f11a92-d512-4acd-9baa-dd85ea939ee4", this.btnSelectAll);
141 this.btnSelectAll.Name = "btnSelectAll";
142 this.btnSelectAll.EpiGuid = "27f11a92-d512-4acd-9baa-dd85ea939ee4";
143 this.btnUnSelectAl = new Ice.Lib.Framework.EpiButton();
144 this.btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578 = this.btnUnSelectAl;
145 customControls.Add("517214e2-1cf4-4d48-baab-1d1979a35578", this.btnUnSelectAl);
146 controlsHT.Add("517214e2-1cf4-4d48-baab-1d1979a35578", this.btnUnSelectAl);
147 this.btnUnSelectAl.Name = "btnUnSelectAl";
148 this.btnUnSelectAl.EpiGuid = "517214e2-1cf4-4d48-baab-1d1979a35578";
149 this.bbbb = new Ice.Lib.Framework.EpiGroupBox();
150 this.bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536 = this.bbbb;
151 customControls.Add("4b987139-527e-4df1-b2fc-6bbd0ea32536", this.bbbb);
152 controlsHT.Add("4b987139-527e-4df1-b2fc-6bbd0ea32536", this.bbbb);
153 this.bbbb.Name = "bbbb";
154 this.bbbb.EpiGuid = "4b987139-527e-4df1-b2fc-6bbd0ea32536";
155 this.btnCreateJobs = new Ice.Lib.Framework.EpiButton();
156 this.btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c = this.btnCreateJobs;
157 customControls.Add("57669000-6dc2-4d84-8a65-10c64551bb5c", this.btnCreateJobs);
158 controlsHT.Add("57669000-6dc2-4d84-8a65-10c64551bb5c", this.btnCreateJobs);
159 this.btnCreateJobs.Name = "btnCreateJobs";
160 this.btnCreateJobs.EpiGuid = "57669000-6dc2-4d84-8a65-10c64551bb5c";
161 this.epiButtonC1 = new Ice.Lib.Framework.EpiButton();
162 this.epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36 = this.epiButtonC1;
163 customControls.Add("df7a4510-eba7-4b6d-aa68-d2c340269a36", this.epiButtonC1);
164 controlsHT.Add("df7a4510-eba7-4b6d-aa68-d2c340269a36", this.epiButtonC1);
165 this.epiButtonC1.Name = "epiButtonC1";
166 this.epiButtonC1.EpiGuid = "df7a4510-eba7-4b6d-aa68-d2c340269a36";
167 // Sheet1
168 this.Sheet1.AutoScroll = true;
169 System.Collections.Hashtable customSheets = personalizeCustomizeManager.CustControlMan.CustomSheetsHT;
170 Infragistics.Win.UltraWinDock.DockableControlPane local1 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet1, "ba9594b7-d2d2-426c-a533-38f0318f3033", customSheets);
171 if ((local1 != null))
172 {
173 Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet1);
174 local1.Text = "";
175 local1.TextTab = "Sheet1";
176 Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local1, "baseDockManager1dff11bc-3024-4d17-acfc-b7af287e274b");
177 }
178 // Sheet2
179 this.Sheet2.Controls.Add(this.grdMain);
180 this.Sheet2.Controls.SetChildIndex(this.grdMain, 0);
181 this.Sheet2.AutoScroll = true;
182 Infragistics.Win.UltraWinDock.DockableControlPane local2 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet2, "7b1b5b5f-0912-43ef-b10b-cc361e21fbe6", customSheets);
183 if ((local2 != null))
184 {
185 Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet2);
186 local2.Text = "";
187 local2.TextTab = "Sheet2";
188 Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local2, "baseDockManagerba9594b7-d2d2-426c-a533-38f0318f3033");
189 }
190 // Sheet3
191 this.Sheet3.Controls.Add(this.epiGroupBox1);
192 this.Sheet3.Controls.Add(this.bbbb);
193 this.Sheet3.Controls.Add(this.epiButtonC1);
194 this.Sheet3.Controls.SetChildIndex(this.epiButtonC1, 0);
195 this.Sheet3.Controls.SetChildIndex(this.bbbb, 1);
196 this.Sheet3.Controls.SetChildIndex(this.epiGroupBox1, 1);
197 this.Sheet3.AutoScroll = true;
198 Infragistics.Win.UltraWinDock.DockableControlPane local3 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.InitializeSheet(this.Sheet3, "42938545-be6b-40c2-bccc-d521b3d1b0b8", customSheets);
199 if ((local3 != null))
200 {
201 Ice.Lib.Customization.Designers.EpiDockManagerPanelDesigner.AddCustomDockManager(personalizeCustomizeManager, this.Sheet3);
202 local3.Text = "";
203 local3.TextTab = "Sheet3";
204 Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddCustomSheetToDockManager(personalizeCustomizeManager, local3, "baseDockManagerba9594b7-d2d2-426c-a533-38f0318f3033");
205 }
206 // ice.core.session.dll
207 // ice.contracts.bo.dynamicquery.dll
208 // grdMain
209 this.grdMain.Top = 68;
210 this.grdMain.Left = 993;
211 this.grdMain.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
212 this.grdMain.Width = 1648;
213 this.grdMain.Height = 652;
214 this.grdMain.Text = "";
215 // epiGroupBox1
216 this.epiGroupBox1.Top = 0;
217 this.epiGroupBox1.Left = 3;
218 this.epiGroupBox1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
219 this.epiGroupBox1.Width = 202;
220 this.epiGroupBox1.Height = 82;
221 this.epiGroupBox1.Text = "Batch Selection";
222 this.epiGroupBox1.Controls.Add(this.btnSelectAll);
223 this.epiGroupBox1.Controls.Add(this.btnUnSelectAl);
224 this.epiGroupBox1.Controls.SetChildIndex(this.btnSelectAll, 0);
225 this.epiGroupBox1.Controls.SetChildIndex(this.btnUnSelectAl, 0);
226 // btnSelectAll
227 this.btnSelectAll.Top = 17;
228 this.btnSelectAll.Left = 14;
229 this.btnSelectAll.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
230 this.btnSelectAll.Width = 156;
231 this.btnSelectAll.Height = 27;
232 this.btnSelectAll.Text = "Select Selection";
233 // btnUnSelectAl
234 this.btnUnSelectAl.Top = 49;
235 this.btnUnSelectAl.Left = 14;
236 this.btnUnSelectAl.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
237 this.btnUnSelectAl.Width = 156;
238 this.btnUnSelectAl.Height = 27;
239 this.btnUnSelectAl.Text = "Unselect Selection";
240 // bbbb
241 this.bbbb.Top = 1;
242 this.bbbb.Left = 207;
243 this.bbbb.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
244 this.bbbb.Width = 376;
245 this.bbbb.Height = 78;
246 this.bbbb.Text = "Job Creation";
247 this.bbbb.Controls.Add(this.btnCreateJobs);
248 this.bbbb.Controls.SetChildIndex(this.btnCreateJobs, 0);
249 // btnCreateJobs
250 this.btnCreateJobs.Top = 25;
251 this.btnCreateJobs.Left = 120;
252 this.btnCreateJobs.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
253 this.btnCreateJobs.Width = 140;
254 this.btnCreateJobs.Height = 33;
255 this.btnCreateJobs.Text = "Create Jobs";
256 // erp.contracts.bo.jobentry.dll
257 // erp.contracts.bo.lotselectupdate.dll
258 // ice.contracts.bo.ud08.dll
259 // ice.contracts.lib.boreader.dll
260 // epiButtonC1
261 this.epiButtonC1.Top = -121;
262 this.epiButtonC1.Left = 844;
263 this.epiButtonC1.Width = 74;
264 this.epiButtonC1.Height = 33;
265 this.epiButtonC1.Text = "epiButtonC1";
266 // listPanel1
267 Ice.Lib.Framework.EpiBasePanel local4 = ((Ice.Lib.Framework.EpiBasePanel)(personalizeCustomizeManager.ControlsHT["5bc5702d-bf5b-4bcd-8555-a5be760a5449"]));
268 local4.Top = 232;
269 local4.Left = 64;
270 local4.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
271 local4.Width = 520;
272 local4.Height = 352;
273 System.Collections.Hashtable nativeSheets = personalizeCustomizeManager.NativeSheetsDCPsHT;
274 Infragistics.Win.UltraWinDock.DockableControlPane local5 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.GetDockableControlPane(local4, "5bc5702d-bf5b-4bcd-8555-a5be760a5449", nativeSheets);
275 if ((local5 != null))
276 {
277 local4.Visible = false;
278 Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddToSheetsVisToggleHT(personalizeCustomizeManager, local4);
279 }
280 // detailPanel1
281 Ice.Lib.Framework.EpiBasePanel local6 = ((Ice.Lib.Framework.EpiBasePanel)(personalizeCustomizeManager.ControlsHT["d5488fbc-e47b-46b6-aa3e-9ab7d923315a"]));
282 local6.Top = 112;
283 local6.Left = 488;
284 local6.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
285 local6.Width = 488;
286 local6.Height = 192;
287 Infragistics.Win.UltraWinDock.DockableControlPane local7 = Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.GetDockableControlPane(local6, "d5488fbc-e47b-46b6-aa3e-9ab7d923315a", nativeSheets);
288 if ((local7 != null))
289 {
290 local6.Visible = false;
291 Ice.Lib.Customization.Designers.EpiCustomSheetDesigner.AddToSheetsVisToggleHT(personalizeCustomizeManager, local6);
292 }
293 // UD01Form
294 Ice.Lib.Framework.EpiBaseForm local8 = ((Ice.Lib.Framework.EpiBaseForm)(personalizeCustomizeManager.ControlsHT["2dcd1674-5e34-4d98-b493-c75747027376"]));
295 local8.Top = -4;
296 local8.Left = -4;
297 local8.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left);
298 local8.Width = 1372;
299 local8.Height = 748;
300 local8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
301 local8.Text = "Order Batching";
302 // Finishing control initialization.
303 topControl.FindForm().ResumeLayout();
304 }
305
306 public void DestroyGlobalVariables()
307 {
308 this.Sheet1 = null;
309 this.Sheet1_ba9594b7_d2d2_426c_a533_38f0318f3033 = null;
310 this.Sheet2 = null;
311 this.Sheet2_7b1b5b5f_0912_43ef_b10b_cc361e21fbe6 = null;
312 this.Sheet3 = null;
313 this.Sheet3_42938545_be6b_40c2_bccc_d521b3d1b0b8 = null;
314 this.grdMain = null;
315 this.grdMain_78ea3de5_e734_43e7_adbc_a4b06d4ebd44 = null;
316 this.epiGroupBox1 = null;
317 this.epiGroupBox1_aa67cac3_28aa_46c0_996a_77aa548defbe = null;
318 this.btnSelectAll = null;
319 this.btnSelectAll_27f11a92_d512_4acd_9baa_dd85ea939ee4 = null;
320 this.btnUnSelectAl = null;
321 this.btnUnSelectAl_517214e2_1cf4_4d48_baab_1d1979a35578 = null;
322 this.bbbb = null;
323 this.bbbb_4b987139_527e_4df1_b2fc_6bbd0ea32536 = null;
324 this.btnCreateJobs = null;
325 this.btnCreateJobs_57669000_6dc2_4d84_8a65_10c64551bb5c = null;
326 this.epiButtonC1 = null;
327 this.epiButtonC1_df7a4510_eba7_4b6d_aa68_d2c340269a36 = null;
328 this.csm = null;
329 this.oTrans = null;
330 this.UD01Form = null;
331 this.baseToolbarsManager = null;
332 this.UD01_Column = null;
333 this.UD01_Row = null;
334 this.UD01Attch_Column = null;
335 this.AutoAttachUD01_Row = null;
336 this.BpmData_Column = null;
337 this.CallContextBpmData_Row = null;
338 this.Client_Column = null;
339 this.CallContextClientData_Row = null;
340 }
341
342 public static string[] GetTranslatableStrings()
343 {
344 return new string[] {
345 "",
346 "Sheet1",
347 "Sheet2",
348 "Sheet3",
349 "Batch Selection",
350 "Select Selection",
351 "Unselect Selection",
352 "Job Creation",
353 "Create Jobs",
354 "epiButtonC1",
355 "Order Batching"};
356 }
357
358 public static string GetStringByID(string id)
359 {
360 return "";
361 }
362 // ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
363 // Begin Wizard Added Module Level Variables **
364
365 private EpiBaseAdapter oTrans_adapter;
366 private EpiDataView edvCallContextBpmData;
367 // End Wizard Added Module Level Variables **
368 private string m_inputString;
369 private System.Collections.Hashtable m_gridContextMenu;
370 // Add Custom Module Level Variables Here **
371 private DataTable m_dtOrdersToBatch;
372 private string m_plantLotSeqUpdate;
373 public void InitializeCustomCode()
374 {
375 // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
376 // Begin Wizard Added Variable Initialization
377
378 this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
379 this.oTrans_adapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_adapter"]));
380 this.oTrans_adapter.BeforeAdapterMethod += new BeforeAdapterMethod(this.oTrans_adapter_BeforeAdapterMethod);
381 this.edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
382 this.edvCallContextBpmData.EpiViewNotification += new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
383 // End Wizard Added Variable Initialization
384
385 // Begin Wizard Added Custom Method Calls
386 m_plantLotSeqUpdate = " ";
387 GetData(false);
388 this.btnSelectAll.Click += new System.EventHandler(this.btnSelectAll_Click);
389 this.btnUnSelectAl.Click += new System.EventHandler(this.btnUnSelectAl_Click);
390 this.btnCreateJobs.Click += new System.EventHandler(this.btnCreateJobs_Click);
391 LoadGridContextMenuHashTable();
392 this.grdMain.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_AfterCellUpdate);
393 this.grdMain.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_CellChange);
394 this.grdMain.AfterSelectChange += GridRowSelected;
395 this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
396 // End Wizard Added Custom Method Calls
397 }
398
399 public void DestroyCustomCode()
400 {
401 // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
402 // Begin Wizard Added Object Disposal
403
404 this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
405 this.oTrans_adapter.BeforeAdapterMethod -= new BeforeAdapterMethod(this.oTrans_adapter_BeforeAdapterMethod);
406 this.oTrans_adapter = null;
407 this.btnSelectAll.Click -= new System.EventHandler(this.btnSelectAll_Click);
408 this.btnUnSelectAl.Click -= new System.EventHandler(this.btnUnSelectAl_Click);
409 this.btnCreateJobs.Click -= new System.EventHandler(this.btnCreateJobs_Click);
410 this.grdMain.AfterCellUpdate -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_AfterCellUpdate);
411 this.grdMain.CellChange -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.grdMain_CellChange);
412 this.grdMain.AfterSelectChange -= GridRowSelected;
413 this.edvCallContextBpmData.EpiViewNotification -= new EpiViewNotification(this.edvCallContextBpmData_EpiViewNotification);
414 this.edvCallContextBpmData = null;
415 this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
416 // End Wizard Added Object Disposal
417
418 // Begin Custom Code Disposal
419
420 // End Custom Code Disposal
421 }
422
423 private void UD01Form_Load(object sender, EventArgs args)
424 {
425
426 HideStuff();
427 SetVersionNumber();
428 SetExtendedProperties();
429 DisableButtons();
430 UD01Form.WindowState = FormWindowState.Maximized;
431 grdMain.Dock = DockStyle.Fill;
432
433
434 GetData(false);
435 }
436
437 #region Selection Order - Population and Validation
438 private void GridRowSelected(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e){
439 if(typeof(UltraGridRow)!=e.Type)
440 return; // Didn't select a row.
441 if(grdMain.Selected.Rows.Count==0)
442 return; // Nothing is selected.
443
444 var selectedRow = grdMain.Selected.Rows[grdMain.Selected.Rows.Count-1];
445 var selectionOrder = selectedRow.Cells["Calculated_SelectionOrder"];
446 selectionOrder.Value = GetNextSelectionOrder();
447 }
448
449 private int GetNextSelectionOrder(){
450 var maxOrder = 0;
451
452 // Loop through the grid and find the highest current selection
453 foreach(var row in grdMain.Rows){
454 var currentOrder = Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value);
455 if(currentOrder > maxOrder)
456 maxOrder=currentOrder;
457 }
458 // Add 1 to get the next position
459 return maxOrder+1;
460 }
461
462 private void ValidateSelectionOrder(){
463 var maxSelection = GetNextSelectionOrder()-1; // We want the highest current, not the next value.
464
465 var selectedRows = 0;
466 foreach(var row in grdMain.Rows)
467 if(Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value)!=0)
468 selectedRows++;
469
470 if(selectedRows!=maxSelection)
471 throw new Exception(string.Format("You have selected {0} rows. Max order is {1}. Check sequence for gaps.", selectedRows, maxSelection));
472 }
473 #endregion
474
475 private void DisableButtons()
476 {
477 Infragistics.Win.UltraWinToolbars.UltraToolbarsManager Toolbar;
478 object obj = typeof(Ice.UI.App.UD01Entry.UD01Form).InvokeMember("baseToolbarsManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD01Form, null);
479 Toolbar = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)obj;
480 //Toolbar.Tools["NewTool"].SharedProps.Enabled = false;
481 //Toolbar.Tools["SaveTool"].SharedProps.Enabled = false;
482 //Toolbar.Tools["DeleteTool"].SharedProps.Enabled = false;
483
484 foreach ( Infragistics.Win.UltraWinToolbars.ToolBase tool in Toolbar.Tools )
485 {
486 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"))
487 {
488 }else
489 {
490 tool.SharedProps.Enabled = false;
491 }
492 }
493
494
495 }
496 private void HideStuff()
497 {
498
499 try {
500 System.Windows.Forms.Control con = null;
501 foreach (Control con_loopVariable in UD01Form.Controls) {
502 con = con_loopVariable;
503 if ((con.Name.Trim().ToLower() == "windowdockingarea1")) {
504 con.Visible = false;
505 }
506
507
508 }
509
510
511 } catch ( Exception ex )
512 {
513 MessageBox.Show(ex.Message);
514 }
515
516 }
517
518 private void SetVersionNumber()
519 {
520 string version = "?.?";
521 string custName = oTrans.EpiBaseForm.CustomizationName;
522 if ((custName.LastIndexOf("_") > 0)) {
523 version = custName.Substring(custName.LastIndexOf("_") + 1, custName.Length - custName.LastIndexOf("_") - 1);
524 }
525 UD01Form.Text = UD01Form.Text + " - Version " + version;
526
527 }
528
529 private void SetExtendedProperties()
530 {
531
532 //edvUD01.dataView.Table.Columns["Number01"].ExtendedProperties["Format"] = ">>>>>>>>9";
533 //edvUD01.dataView.Table.Columns["Number02"].ExtendedProperties["Format"] = ">>>>>>>>9";
534 //edvUD01.dataView.Table.Columns["ShortChar01"].ExtendedProperties["ReadOnly"] = true;
535 }
536
537 private void GetData( bool bClear )
538 {
539 try
540 {
541 System.Collections.Hashtable parameters = new System.Collections.Hashtable();
542 if ( bClear )
543 {
544 parameters.Add("pcompany", "None" );
545 }
546 else
547 {
548 parameters.Add("pcompany", ((Ice.Core.Session)oTrans.Session).CompanyID );
549 }
550 grdMain.DataSource = null;
551
552 DataTable dt = GetQueryData("CPEToBatchOrders", parameters);
553 DataTable dtExistingCast = GetQueryData("CPEExistingCasts", parameters);
554
555
556 DataRow[] needJobs = dt.Select("Calculated_JobNumHide = '~'");
557 m_dtOrdersToBatch = dt.Clone();
558 foreach ( DataRow needJob in needJobs )
559 {
560
561 DataRow[] hasCastRow = dtExistingCast.Select("OrderDtl_PerConLastName_c = '" + needJob["Calculated_Contact_Last_Name"].ToString() + "'");
562 if ( hasCastRow.Length > 0 )
563 {
564 //needJob["Calculated_OnHand_Cast_LotNum"] = hasCastRow[0]["PartLot_LotNum"];
565 if ( needJob["Calculated_OnHand_Cast_LotNum"].ToString().ToLower() == hasCastRow[0]["PartLot_LotNum"].ToString().ToLower() )
566 {
567 needJob["Calculated_Left_Hide"] = hasCastRow[0]["OrderDtl_CPE_DspMouldLeft_c"];
568 needJob["Calculated_Right_Hide"] = hasCastRow[0]["OrderDtl_CPE_DspMouldRight_c"];
569
570 }
571 needJob["Calculated_HasExistingCast_Hide"] = true;
572 }
573
574 m_dtOrdersToBatch.ImportRow(needJob);
575
576 }
577
578 dt.Clear();
579 SetGridContextMenu(ref m_dtOrdersToBatch);
580 grdMain.DataSource = m_dtOrdersToBatch;
581 FormatGrid(ref grdMain);
582 }catch ( Exception ex )
583 {
584 MessageBox.Show("GetData error: " + ex.Message);
585 }
586 }
587
588 private DataTable GetQueryData(string baqName, System.Collections.Hashtable parameters)
589 {
590 // ** Place Event Handling Code Here **
591 Ice.Core.Session session = (Ice.Core.Session)oTrans.Session;
592 Ice.BO.DynamicQueryDataSet baqQuery = null;
593 Ice.BO.QueryExecutionDataSet executionDS = null;
594 string caption = string.Empty;
595 Ice.Adapters.DynamicQueryAdapter adDynamicQuery = new Ice.Adapters.DynamicQueryAdapter(this.oTrans);
596 adDynamicQuery.BOConnect();
597 try
598 {
599
600 adDynamicQuery.ClearDynamicQueryData();
601 baqQuery = adDynamicQuery.GetQueryDesignData(baqName) as Ice.BO.DynamicQueryDataSet;
602 executionDS = adDynamicQuery.GetQueryExecutionParametersByID(baqName);
603
604 if (baqQuery != null && executionDS != null)
605 {
606 for (int i = 0; i < executionDS.ExecutionParameter.Rows.Count; i++)
607 {
608 string executeParams = executionDS.ExecutionParameter[i]["ParameterID"].ToString().Trim().ToLower();
609 if (parameters.Contains(executeParams))
610 {
611 executionDS.ExecutionParameter[i]["ParameterValue"] = parameters[executeParams].ToString();
612 }
613 }
614
615 executionDS.AcceptChanges();
616
617 adDynamicQuery.Execute(baqQuery, executionDS);
618 }
619 else
620 {
621 MessageBox.Show(baqName + " not found.");
622 }
623 //return m_adDynamicQuery.QueryResults.Tables[0];
624 }
625 catch (Exception ex)
626 {
627 MessageBox.Show("Error running " + baqName + ":" + ex.Message);
628
629 }
630
631 DataTable dataTable = adDynamicQuery.QueryResults.Tables[0];//.Copy();
632 adDynamicQuery.Dispose();
633 adDynamicQuery = null;
634 return dataTable;
635
636 }
637
638 private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
639 {
640 if ( args.Tool.Key.Trim().ToLower().Contains("clear") )
641 {
642 ClearForm();
643 }
644 else if ( args.Tool.Key.ToLower().Contains("refresh") )
645 {
646 GetData(false);
647 }
648 }
649
650 private void ClearForm()
651 {
652 GetData(true);
653 }
654
655 private void oTrans_adapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)
656 {
657
658 args.Cancel = true;
659
660
661 }
662
663 private void FormatGrid( ref Ice.Lib.Framework.EpiUltraGrid grid)
664 {
665 try
666 {
667
668 grid.DisplayLayout.Override.AllowMultiCellOperations = Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.Copy | Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.Paste;
669 foreach ( Infragistics.Win.UltraWinGrid.UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns )
670 {
671 if ( col.Header.Caption.Contains("_") )
672 {
673 col.Header.Caption = col.Header.Caption.Replace("_", " ");
674 }
675 if ( col.Header.Caption.Trim().ToLower().EndsWith("hide") || col.Key.Trim().ToLower().EndsWith("hide") || col.Key == "Calculated_OnHand_Cast_LotNum")
676 {
677 col.Hidden = true;
678 }
679 if ( col.Header.Caption.Trim().ToLower() == "use existing cast" )// || col.Key.Trim().ToLower() == "calculated_box_number" )
680 {
681 foreach ( Infragistics.Win.UltraWinGrid.UltraGridRow grRow in grid.Rows )
682 {
683 if ( string.IsNullOrEmpty(grRow.Cells["Calculated_OnHand_Cast_LotNum"].Value.ToString().Trim()) )
684 {
685 grRow.Cells["Calculated_Use_Existing_Cast"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
686 }
687 else
688 {
689 // grRow.Cells["Calculated_Use_Existing_Cast"].Value = true;
690 // grRow.Cells["Calculated_Batch"].Value = false;
691 }
692 }
693 }
694 else
695 {
696 if ( col.Header.Caption.Trim().ToLower() == "batch" || col.Header.Caption.Trim().ToLower()=="selectionorder")// || col.Key.Trim().ToLower() == "calculated_box_number" )
697 {}
698 else
699 {
700 col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
701 }
702 }
703
704 }
705
706
707
708 /* foreach ( Infragistics.Win.UltraWinGrid.UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns )
709 {
710 if ( col.Header.Caption == "ReceiptQty" )
711 {
712 col.Format = "###,##0.00";
713 }
714 else if ( col.Header.Caption == "Completed" )
715 {
716 }
717 else
718 {
719 col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
720 }
721
722 }
723
724 foreach ( Infragistics.Win.UltraWinGrid.UltraGridRow row in grid.Rows )
725 {
726
727 if ( (Convert.ToString(row.Cells["Calculated_ProcessHide"].Value)).Trim().ToString() == "true")
728 {
729 row.Cells["Calculated_Completed"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
730 row.Cells["Calculated_ReceiptQty"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
731 }
732 }*/
733
734 }catch ( Exception ex )
735 {
736 //MessageBox.Show("FormatGrid error: " + ex.Message);
737 }
738
739 }
740
741 private void SetGridContextMenu(ref DataTable table)
742 {
743 try
744 {
745 foreach ( System.Collections.DictionaryEntry dic in m_gridContextMenu )
746 {
747 if ( table.Columns.Contains(dic.Key.ToString() ) )
748 {
749 table.Columns[dic.Key.ToString()].ExtendedProperties["Like"] = dic.Value.ToString();
750 table.Columns[dic.Key.ToString()].ExtendedProperties["EpiContextMenuKey"] = dic.Value.ToString();
751 }
752 }
753 }catch (Exception ex )
754 {
755 //MessageBox.Show("SetGridContextMenu error: " + ex.Message);
756 }
757 }
758
759 private void LoadGridContextMenuHashTable()
760 {
761 try
762 {
763 m_gridContextMenu = new System.Collections.Hashtable();
764 m_gridContextMenu.Add("Company_Company", "Company.CompanyID");
765 m_gridContextMenu.Add("Calculated_JobNumHide", "JobHead.JobNum");
766 m_gridContextMenu.Add("ProjectID", "Project.ProjectID");
767 m_gridContextMenu.Add("Calculated_Partnum", "Part.PartNum");
768 m_gridContextMenu.Add("Calculated_OrderNum", "OrderHed.OrderNum");
769 m_gridContextMenu.Add("Customer.CustID", "Calculated_CustID");
770 m_gridContextMenu.Add("SupplierNum", "Vendor.VendorNum");
771 }catch ( Exception ex )
772 {
773 MessageBox.Show("LoadGrid Context Menu Hash error: " + ex.Message);
774 }
775 }
776
777 private void btnSelectAll_Click(object sender, System.EventArgs args){
778 foreach(var row in grdMain.Rows){
779 var ordered = Convert.ToInt32(row.Cells["Calculated_SelectionOrder"].Value);
780 if(ordered!=0){
781 row.Cells["Calculated_Batch"].Value = true;
782 row.Update();
783 }
784 }
785 }
786
787 private void btnUnSelectAl_Click(object sender, System.EventArgs args){
788 foreach(var row in grdMain.Rows){
789 row.Cells["Calculated_Batch"].Value = false;
790 row.Update();
791 }
792 }
793
794 private void btnCreateJobs_Click(object sender, System.EventArgs args){
795 try{
796 // This will generate exceptions if there are
797 // errors in the ordering.
798 ValidateSelectionOrder();
799
800 CreateJobs();
801 } catch(Exception ex){
802 MessageBox.Show(ex.Message);
803 }
804 }
805
806
807
808 private bool GetLatestRev(string partNum, out string rev)
809 {
810 bool hasRev = false;
811 rev = "";
812 try
813 {
814 System.Collections.Hashtable parameters = new System.Collections.Hashtable();
815 parameters.Add("ppartnum", partNum );
816
817 DataTable dt = GetQueryData("CPELatestRev", parameters);
818 if ( dt.Rows.Count > 0 )
819 {
820 rev = dt.Rows[0]["PartRev_RevisionNum"].ToString();
821 hasRev = true;
822 }
823
824 }
825 catch ( Exception ex )
826 {
827 MessageBox.Show("GetLastest rev error: " + ex.Message);
828 }
829 return hasRev;
830 }
831
832 private class ClassPosition
833 {
834 public bool bLeft;
835 public bool bRight;
836 public ClassPosition(bool right, bool left)
837 {
838 bLeft = left;
839 bRight = right;
840 }
841 }
842 private void CreateJobs()
843 {
844 string loc = "401";
845 m_plantLotSeqUpdate = " ";
846 try
847 {
848 bool bNewCastFromJobError = false;
849 string strNewCastFromJobError = "\nOrder lines may need to be updated to select an existing cast.\n\n";
850 int totalReq = 0;
851 int totalCastExistReq = 0;
852 DataRow[] batchRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = false", "Calculated_SelectionOrder ASC" );
853 DataRow[] batchCastExistRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = true", "Calculated_SelectionOrder ASC");
854 foreach ( DataRow batchRow in batchRows )
855 {
856 totalReq += Convert.ToInt32(batchRow["Calculated_Qty"]);
857 }
858 foreach ( DataRow batchCastExistRow in batchCastExistRows )
859 {
860 totalCastExistReq += Convert.ToInt32(batchCastExistRow["Calculated_Qty"]);
861 }
862 string messageAsk = "";
863 if ( batchRows.Length > 0 )
864 {
865 messageAsk = "Batch " + totalReq.ToString().Trim() + " parts into groups of 10 with a new cast from " + batchRows.Length.ToString().Trim() + " order release lines?";
866 }
867 if ( batchCastExistRows.Length > 0 )
868 {
869 if ( messageAsk == "" )
870 {
871 messageAsk = "Batch " + totalCastExistReq.ToString().Trim() + " parts into groups of 10 with a existing casts from " + batchCastExistRows.Length.ToString().Trim() + " order release lines?";
872 }
873 else
874 {
875 messageAsk += "\n and batch " + totalCastExistReq.ToString().Trim() + " parts into groups of 10 with a existing casts from " + batchCastExistRows.Length.ToString().Trim() + " order release lines?";
876 }
877
878 }
879 //find distincts existing cast numbers
880 System.Collections.Hashtable existingCast = new System.Collections.Hashtable();
881 foreach ( DataRow existRow in batchCastExistRows )
882 {
883 string theCast = existRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim();
884 if ( !existingCast.Contains(theCast) )
885 {
886 existingCast.Add(theCast,Convert.ToInt32(existRow["Calculated_Qty"]));
887 }
888 else
889 {
890 existingCast[theCast] = Convert.ToInt32(existingCast[theCast]) + Convert.ToInt32(existRow["Calculated_Qty"]);
891 }
892 }
893
894 if ( totalCastExistReq + totalReq <= 0 )
895 {
896 MessageBox.Show("Nothing selected to batch!");
897 }
898 else if ( MessageBox.Show(messageAsk,"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes )
899 {
900 Erp.Proxy.BO.JobEntryImpl boJobEntry = null;
901 boJobEntry = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.JobEntryImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/jobentry.svc");
902 Erp.BO.JobEntryDataSet dsJobEntry = null;
903
904 Ice.Proxy.BO.UD08Impl boUD08 = null;
905 boUD08 = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Ice.Proxy.BO.UD08Impl>((Ice.Core.Session)oTrans.Session, "ice/bo/UD08.svc");
906
907
908 string message = " ";
909 string currentJob = "";
910 string currentLotNum = "";
911 string firstJob = "";
912 int numUOM = 0;
913 int numJobs = 0;
914 int jobBatchCount = 0;
915 int rowCounter = 0;
916 int castSpotCounter = 0;
917 int numOfEA = 0;
918
919 System.Collections.Hashtable castPosition = new System.Collections.Hashtable();
920
921 System.Collections.Hashtable newCasts = new System.Collections.Hashtable();
922 System.Collections.Hashtable newCastsCreated = new System.Collections.Hashtable();
923 foreach ( DataRow batchRow in batchRows )
924 {
925
926 // see if we are triggered to create a next cast but we still have a right or left that will fit in
927 // if the last row filled in a left or right perhpas the cast is now full
928 if ( numUOM == 8 )
929 {
930 if ( castPosition.Count == 5 )// all rows full
931 {
932 numUOM = 0;
933 rowCounter = 0;
934 castSpotCounter = 0;
935 }
936 }
937 else if ( numUOM == 0 )
938 {
939
940 if (castPosition.Contains(batchRow["Calculated_PerConIDHide"].ToString().Trim()))
941 {
942 ClassPosition cpCheck = (ClassPosition)castPosition[batchRow["Calculated_PerConIDHide"].ToString().Trim()];
943 if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cpCheck.bRight == false) || ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cpCheck.bLeft == false ) )
944 {
945 castSpotCounter = 8;
946 numUOM = 8;
947 rowCounter = 4;
948 }
949 else
950 {
951 castPosition.Clear();
952 }
953 }
954 else
955 {
956 castPosition.Clear();
957 }
958 }
959
960 batchRow["Calculated_ProcessHide"] = true;
961 numOfEA = Convert.ToInt32(batchRow["Calculated_Qty"]);
962 numUOM = numUOM + Convert.ToInt32(batchRow["Calculated_Qty"]);
963 if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
964 {
965 numUOM += 1;
966 }
967 ++rowCounter;
968 castSpotCounter += numOfEA;
969 if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
970 {
971 castSpotCounter += 1;
972 }
973 oTrans.PushStatusText("Processing Order " + batchRow["Calculated_OrderNum"].ToString() + " Line " + batchRow["Calculated_OrderLine"].ToString() + "...", true);
974 if ( rowCounter == 1 )
975 {
976 ++numJobs;
977 jobBatchCount = 10;
978 if ( totalReq < 10 )
979 {
980 jobBatchCount = totalReq;
981 }
982 dsJobEntry = new Erp.BO.JobEntryDataSet();
983 boJobEntry.GetNextJobNum(out currentJob);
984 boJobEntry.GetNewJobHead(dsJobEntry);
985 if ( firstJob == "" )
986 {
987 firstJob = currentJob;
988 }
989 dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"] = currentJob;
990 dsJobEntry.Tables["JobHead"].Rows[0]["Plant"] = ((Ice.Core.Session)oTrans.Session).PlantID;
991 dsJobEntry.Tables["JobHead"].Rows[0]["PartNum"] = batchRow["Calculated_PartNum"];
992 boJobEntry.ChangeJobHeadPartNum(dsJobEntry);
993 dsJobEntry.Tables["JobHead"].Rows[0]["ReqDueDate"] = batchRow["Calculated_Need_By_Date"];
994 currentLotNum = CreateNewPlantLotNumber( batchRow["Calculated_CastPartNumHide"].ToString(), currentJob, Convert.ToDateTime(batchRow["Calculated_Need_By_Date"]) );
995 dsJobEntry.Tables["JobHead"].Rows[0]["CastLotNumber_c"] = currentLotNum;
996 //MessageBox.Show("adding: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
997 if ( !newCastsCreated.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
998 {
999 newCastsCreated.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), currentLotNum);
1000 // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
1001 }
1002 boJobEntry.Update(dsJobEntry);
1003 string rev;
1004 if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
1005 {
1006 boJobEntry.GetDetails(currentJob, 0, "Method", 0, 0, "", 0, batchRow["Calculated_PartNum"].ToString(), rev, "", true, false, false, false);
1007 }
1008 // get job prod
1009 dsJobEntry = boJobEntry.GetByID(currentJob);
1010 // divide op qty by prod qty
1011
1012 if ( jobBatchCount != 0 )
1013 {
1014 foreach ( DataRow oprRow in dsJobEntry.Tables["JobOper"].Rows )
1015 {
1016 oprRow["RowMod"] = "U";
1017 oprRow["ProdStandard"] = Convert.ToDecimal(oprRow["ProdStandard"]) / Convert.ToDecimal(jobBatchCount);
1018 }
1019 boJobEntry.Update(dsJobEntry);
1020 }
1021
1022
1023 //set all material to fixedqty
1024 DataRow[] mtlRows = dsJobEntry.Tables["JobMtl"].Select("assemblyseq = 0 and fixedqty = 0");
1025 foreach ( DataRow mtlRow in mtlRows )
1026 {
1027 mtlRow["RowMod"] = "U";
1028 mtlRow["FixedQty"] = true;
1029 mtlRow["QtyPer"] = Convert.ToDecimal(mtlRow["QtyPer"]) * numOfEA;
1030 }
1031 boJobEntry.Update(dsJobEntry);
1032
1033 AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
1034 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,"","");
1035
1036 boJobEntry.InsertNewJobAsmbl(dsJobEntry, currentJob, 0,0,0);
1037 DataRow[] asmRows = dsJobEntry.Tables["JobAsmbl"].Select("RowMod = 'A'");
1038 asmRows[0]["PartNum"] = batchRow["Calculated_CastPartNumHide"];
1039 boJobEntry.ChangeJobAsmblPartNum(dsJobEntry);
1040 bool bHasRev = false;
1041 if ( GetLatestRev(batchRow["Calculated_CastPartNumHide"].ToString(), out rev) )
1042 {
1043 bHasRev = true;
1044 if ( asmRows[0]["RevisionNum"].ToString().Trim().ToLower() != rev.ToString().Trim().ToLower() )
1045 {
1046 asmRows[0]["RevisionNum"] = rev;
1047 boJobEntry.ChangeJobAsmblRevisionNum(dsJobEntry);
1048 }
1049 }
1050 int assemblySeq = Convert.ToInt32(asmRows[0]["AssemblySeq"]);
1051 decimal qtyPer = 0.1M;
1052
1053 if ( jobBatchCount != 0 )
1054 {
1055 Double pow = Math.Pow(10,7);
1056 Double truncated = Math.Truncate((1.0 / jobBatchCount) * pow ) / pow;
1057 //qtyPer = 1.0M / Convert.ToDecimal(jobBatchCount);
1058 qtyPer = Convert.ToDecimal(truncated);
1059 }
1060 asmRows[0]["QtyPer"] = qtyPer;
1061 boJobEntry.ChangeJobAsmblQtyPer(dsJobEntry);
1062
1063 boJobEntry.Update(dsJobEntry);
1064
1065 if ( bHasRev )//( GetLatestRev(batchRow["Calculated_CastPartNumHide"].ToString(), out rev) )
1066 {
1067 boJobEntry.GetDetails(currentJob,assemblySeq, "Method", 0, 0, "", 0, batchRow["Calculated_CastPartNumHide"].ToString(), rev, "", true, false, false, false);
1068 }
1069 dsJobEntry = boJobEntry.GetByID(currentJob);
1070
1071 AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_CastPartNumHide"].ToString(),1,0, currentLotNum, "");
1072
1073 castPosition.Clear();
1074 if ( !castPosition.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
1075 {
1076 bool right = true;
1077 bool left = true;
1078 if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
1079 {
1080 right = false;
1081 }
1082 else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
1083 {
1084 left = false;
1085 }
1086
1087 ClassPosition cp = new ClassPosition(right, left);
1088 castPosition.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), cp);
1089 // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
1090 }
1091
1092 }
1093 else
1094 {
1095
1096 if ( !newCastsCreated.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
1097 {
1098 newCastsCreated.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), currentLotNum);
1099 // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
1100 }
1101 DataRow[] jobPartExists = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1102 if ( jobPartExists.Length <= 0 )
1103 {
1104
1105 //MessageBox.Show("584 add " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1106 AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
1107 }
1108 else
1109 {
1110 //MessageBox.Show("589 update " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1111 UpdateJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
1112 }
1113 DataRow[] jobPartRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1114
1115 // get job prod
1116 AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
1117
1118 // if this is UOM left and a UOM right exists add it to the same cast
1119
1120 // if this is UOM right and a UOM left exists add it to the same cast
1121 // set the castSpotCounter to a different value
1122
1123 if ( !castPosition.Contains( batchRow["Calculated_PerConIDHide"].ToString().Trim() ))
1124 {
1125 bool right = true;
1126 bool left = true;
1127 if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
1128 {
1129 right = false;
1130 }
1131 else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
1132 {
1133 left = false;
1134 }
1135
1136
1137 castPosition.Add(batchRow["Calculated_PerConIDHide"].ToString().Trim(), new ClassPosition(right, left));
1138 // MessageBox.Show("ADDED: " + batchRow["Calculated_PerConIDHide"].ToString().Trim() + " " + currentLotNum);
1139
1140 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,"","");
1141 }
1142 else
1143 {
1144
1145 ClassPosition cp = (ClassPosition)castPosition[batchRow["Calculated_PerConIDHide"].ToString().Trim()];
1146 if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cp.bRight == false) || ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cp.bLeft == false ) )
1147 {
1148 cp.bLeft = true;
1149 cp.bRight = true;
1150 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,"","");
1151 castSpotCounter -= 2;
1152 numUOM -= 2;
1153 }
1154 else
1155 {
1156 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,"","");
1157 }
1158 }
1159
1160
1161
1162 // add in operations for this part
1163 dsJobEntry = boJobEntry.GetByID(currentJob);
1164 string rev;
1165 bool bUpdate = false;
1166 if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
1167 {
1168 System.Collections.Hashtable parameters = new System.Collections.Hashtable();
1169 parameters.Add("ppartnum", batchRow["Calculated_PartNum"].ToString() );
1170 parameters.Add("previsionnum", rev );
1171 DataTable dtNewOps = GetQueryData("CPEPartOpr", parameters);
1172 foreach ( DataRow newOper in dtNewOps.Rows )
1173 {
1174 DataRow[] jobOperRows = dsJobEntry.Tables["JobOper"].Select("assemblyseq = 0 and OpCode = '" + newOper["Calculated_OpCode"].ToString() + "'");
1175 if ( jobOperRows.Length > 0 )
1176 {
1177 jobOperRows[0]["RowMod"] = "U";
1178 jobOperRows[0]["ProdStandard"] = Convert.ToDecimal(jobOperRows[0]["ProdStandard"]) + (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
1179 bUpdate = true;
1180 }
1181 else
1182 {
1183 // add in the new operation
1184 if ( bUpdate )
1185 {
1186 boJobEntry.Update(dsJobEntry);
1187 bUpdate = false;
1188 }
1189 boJobEntry.GetNewJobOper(dsJobEntry, currentJob,0);
1190 string refresh;
1191 boJobEntry.ChangeJobOperOpCode(newOper["Calculated_OpCode"].ToString(), out refresh, dsJobEntry);
1192 DataRow[] newOperRow = dsJobEntry.Tables["JobOper"].Select("RowMod = 'A'");
1193
1194 boJobEntry.ChangeJobOperOpStdID(dsJobEntry);
1195 newOperRow[0]["ProdStandard"] = (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
1196 boJobEntry.ChangeJobOperProdStandard(dsJobEntry);
1197 boJobEntry.Update(dsJobEntry);
1198 bUpdate = false;
1199 }
1200 }
1201
1202 if ( bUpdate )
1203 {
1204 boJobEntry.Update(dsJobEntry);
1205 bUpdate = false;
1206 }
1207 DataTable dtNewMtl = GetQueryData("CPEPartMtl", parameters);
1208 bUpdate = false;
1209 foreach ( DataRow newMtl in dtNewMtl.Rows )
1210 {
1211 DataRow[] jobMtlRows = dsJobEntry.Tables["JobMtl"].Select("AssemblySeq = 0 and PartNum = '" + newMtl["Calculated_PartNum"].ToString() + "' and IUM = '" + newMtl["Calculated_UOM"].ToString() + "'");
1212
1213 if ( jobMtlRows.Length > 0 )
1214 {
1215 //MessageBox.Show("653 increase mtl " + Convert.ToString(jobMtlRows[0]["QtyPer"]) + " + " + (Convert.ToString(newMtl["Calculated_QtyPer"]) + " * " + numOfEA.ToString()));
1216 jobMtlRows[0]["RowMod"] = "U";
1217 jobMtlRows[0]["QtyPer"] = Convert.ToDecimal(jobMtlRows[0]["QtyPer"]) + (Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA);
1218 bUpdate = true;
1219
1220 }
1221 else
1222 {
1223 // add in new material
1224 if ( bUpdate )
1225 {
1226 boJobEntry.Update(dsJobEntry);
1227 bUpdate = false;
1228 }
1229 loc = "577";
1230 boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
1231 string str1; string str2;string str3; bool b1; bool b2; bool b3;
1232 string partNum = newMtl["Calculated_PartNum"].ToString();
1233 DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
1234 // newMtlRow[0]["PartNum"] = partNum;
1235 // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
1236
1237
1238 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);
1239 if ( newMtlRow[0]["IUM"].ToString() != newMtl["Calculated_UOM"].ToString())
1240 {
1241 boJobEntry.ChangeJobMtlIUM(newMtl["Calculated_UOM"].ToString(), dsJobEntry);
1242 }
1243 newMtlRow[0]["FixedQty"] = true;
1244 newMtlRow[0]["QtyPer"] = Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA;
1245
1246 boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
1247
1248 boJobEntry.Update(dsJobEntry);
1249 bUpdate = false;
1250 loc = "590";
1251 }
1252 }
1253 if ( bUpdate )
1254 {
1255 boJobEntry.Update(dsJobEntry);
1256 }
1257 // add in materials for this part
1258 }
1259
1260 }
1261 if (numUOM >= 10)
1262 {
1263 numUOM = 0;
1264 rowCounter = 0;
1265 castSpotCounter = 0;
1266 }
1267 --totalReq;
1268 oTrans.PopStatus();
1269 }
1270
1271 numUOM = 0;
1272 jobBatchCount = 0;
1273 rowCounter = 0;
1274 castSpotCounter = 0;
1275 numOfEA = 0;
1276
1277 // set the new R parts castnumber to the newly created one
1278
1279 // add in existing casts used to the newCastCreated so R parts that use cast can use it
1280 DataRow[] addExistingReuseCasts = m_dtOrdersToBatch.Select("Calculated_OnHand_Cast_LotNum <> 'NEW CAST FROM JOB'");
1281
1282 foreach ( DataRow addRow in addExistingReuseCasts )
1283 {
1284 if ( addRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim().Length > 0 )
1285 {
1286 if ( !newCastsCreated.Contains( addRow["Calculated_PerConIDHide"].ToString().Trim() ))
1287 {
1288 newCastsCreated.Add(addRow["Calculated_PerConIDHide"].ToString().Trim(), addRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim());
1289
1290 }
1291 }
1292 }
1293
1294 DataRow[] setNewBatchRows = m_dtOrdersToBatch.Select("Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = 'NEW CAST FROM JOB'");
1295 foreach ( DataRow rRow in setNewBatchRows )
1296 {
1297
1298 if ( newCastsCreated.Contains( rRow["Calculated_PerConIDHide"].ToString().Trim() ))
1299 {
1300
1301 rRow["Calculated_OnHand_Cast_LotNum"] = newCastsCreated[rRow["Calculated_PerConIDHide"].ToString().Trim()].ToString().Trim();
1302 rRow["Calculated_OnHand_Cast"] = newCastsCreated[rRow["Calculated_PerConIDHide"].ToString().Trim()].ToString().Trim() + "xx";
1303
1304 }
1305
1306 }
1307
1308 existingCast = new System.Collections.Hashtable();
1309 foreach ( DataRow existRow in batchCastExistRows )
1310 {
1311 string theCast = existRow["Calculated_OnHand_Cast_LotNum"].ToString().Trim();
1312 if ( theCast != "NEW CAST FROM JOB" )
1313 {
1314 if ( !existingCast.Contains(theCast) )
1315 {
1316 existingCast.Add(theCast,Convert.ToInt32(existRow["Calculated_Qty"]));
1317 }
1318 else
1319 {
1320 existingCast[theCast] = Convert.ToInt32(existingCast[theCast]) + Convert.ToInt32(existRow["Calculated_Qty"]);
1321 }
1322 }
1323 else
1324 {
1325 bNewCastFromJobError = true;
1326 strNewCastFromJobError += "OrderNum: " + existRow["Calculated_OrderNum"].ToString() + " OrderLine: " + existRow["Calculated_OrderLine"].ToString() + "\n";
1327 }
1328 }
1329
1330 foreach ( System.Collections.DictionaryEntry dic in existingCast )
1331 {
1332 string theCast = dic.Key.ToString();
1333 DataRow[] castRows = m_dtOrdersToBatch.Select("Calculated_ProcessHide = 0 and Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = '" + theCast + "'");
1334 rowCounter = 0;
1335 // filter out to ensure same person is not on the same job
1336 while ( castRows.Length > 0 )
1337 {
1338 System.Collections.Hashtable personOnCast = new System.Collections.Hashtable();
1339
1340 rowCounter = 0;
1341 foreach ( DataRow batchRow in castRows )
1342 {
1343 bool bAddRowToCast = true;
1344 bool bAddingOneMore = false;
1345 if ( personOnCast.Contains(batchRow["Calculated_PerConIDHide"].ToString()))
1346 {
1347 //skip this row and do it in the next job
1348 bAddRowToCast = false;
1349 ClassPosition cp = (ClassPosition)personOnCast[batchRow["Calculated_PerConIDHide"].ToString()];
1350 if ( (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" && cp.bLeft == false) || (batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" && cp.bRight == false) )
1351 {
1352 bAddRowToCast = true;
1353 bAddingOneMore = true;
1354 cp.bLeft = true;
1355 cp.bRight = true;
1356
1357 }
1358 }
1359 if ( bAddRowToCast )
1360 {
1361
1362 batchRow["Calculated_ProcessHide"] = true;
1363
1364 if ( !personOnCast.Contains(batchRow["Calculated_PerConIDHide"].ToString()))
1365 {
1366 bool right = true;
1367 bool left = true;
1368 if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "left" )
1369 {
1370 right = false;
1371 }
1372 else if ( batchRow["Calculated_SalesUM"].ToString().Trim().ToLower() == "right" )
1373 {
1374 left = false;
1375 }
1376 personOnCast.Add(batchRow["Calculated_PerConIDHide"].ToString(),new ClassPosition(right, left));
1377 }
1378
1379 numOfEA = Convert.ToInt32(batchRow["Calculated_Qty"]);
1380 numUOM = numUOM + Convert.ToInt32(batchRow["Calculated_Qty"]);
1381 if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
1382 {
1383 numUOM += 1;
1384 }
1385 ++rowCounter;
1386 castSpotCounter += numOfEA;
1387 if ( Convert.ToInt32(batchRow["Calculated_Qty"]) == 1 )
1388 {
1389 castSpotCounter += 1;
1390 }
1391 oTrans.PushStatusText("Processing Order " + batchRow["Calculated_OrderNum"].ToString() + " Line " + batchRow["Calculated_OrderLine"].ToString() + "...", true);
1392 if ( rowCounter == 1 )
1393 {
1394 ++numJobs;
1395 jobBatchCount = castRows.Length;
1396
1397 dsJobEntry = new Erp.BO.JobEntryDataSet();
1398 boJobEntry.GetNextJobNum(out currentJob);
1399 boJobEntry.GetNewJobHead(dsJobEntry);
1400 if ( firstJob == "" )
1401 {
1402 firstJob = currentJob;
1403 }
1404 dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"] = currentJob;
1405 dsJobEntry.Tables["JobHead"].Rows[0]["Plant"] = ((Ice.Core.Session)oTrans.Session).PlantID;
1406 dsJobEntry.Tables["JobHead"].Rows[0]["PartNum"] = batchRow["Calculated_PartNum"];
1407 boJobEntry.ChangeJobHeadPartNum(dsJobEntry);
1408 dsJobEntry.Tables["JobHead"].Rows[0]["ReqDueDate"] = batchRow["Calculated_Need_By_Date"];
1409 //currentLotNum = CreateNewLotNumber( batchRow["Calculated_CastPartNumHide"].ToString(), currentJob, Convert.ToDateTime(batchRow["Calculated_Need_By_Date"]) );
1410 dsJobEntry.Tables["JobHead"].Rows[0]["CastLotNumber_c"] = theCast;
1411 boJobEntry.Update(dsJobEntry);
1412 string rev;
1413 if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
1414 {
1415 boJobEntry.GetDetails(currentJob, 0, "Method", 0, 0, "", 0, batchRow["Calculated_PartNum"].ToString(), rev, "", true, false, false, false);
1416 }
1417 // get job prod
1418 dsJobEntry = boJobEntry.GetByID(currentJob);
1419 // divide op qty by prod qty
1420
1421 if ( jobBatchCount != 0 )
1422 {
1423 foreach ( DataRow oprRow in dsJobEntry.Tables["JobOper"].Rows )
1424 {
1425 oprRow["RowMod"] = "U";
1426 oprRow["ProdStandard"] = Convert.ToDecimal(oprRow["ProdStandard"]) / Convert.ToDecimal(jobBatchCount);
1427 }
1428 boJobEntry.Update(dsJobEntry);
1429 }
1430
1431
1432 //set all material to fixedqty
1433 DataRow[] mtlRows = dsJobEntry.Tables["JobMtl"].Select("assemblyseq = 0 and fixedqty = 0");
1434 foreach ( DataRow mtlRow in mtlRows )
1435 {
1436 mtlRow["RowMod"] = "U";
1437 mtlRow["FixedQty"] = true;
1438 mtlRow["QtyPer"] = Convert.ToDecimal(mtlRow["QtyPer"]) * numOfEA;
1439 }
1440 boJobEntry.Update(dsJobEntry);
1441
1442 AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
1443 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"]));
1444
1445
1446
1447 dsJobEntry = boJobEntry.GetByID(currentJob);
1448
1449
1450 // add cast as a co-part - not for rework job
1451 //AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_CastPartNumHide"].ToString(),1,0, theCast, "");
1452
1453 // add the cast as a material - not for rework job
1454 /*boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
1455 string str1; string str2; bool b1; bool b2; bool b3;
1456 string partNum = batchRow["Calculated_CastPartNumHide"].ToString();
1457 DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
1458 // newMtlRow[0]["PartNum"] = partNum;
1459 // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
1460
1461 boJobEntry.ChangeJobMtlPartNum(dsJobEntry, true, ref partNum, new Guid("00000000-0000-0000-0000-000000000000"),"", "", out str1, out b1, out str2,out b2, out b3);
1462
1463 newMtlRow[0]["FixedQty"] = true;
1464 newMtlRow[0]["QtyPer"] = 1;
1465
1466 boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
1467
1468 boJobEntry.Update(dsJobEntry); */
1469
1470 }
1471
1472 else
1473 {
1474 DataRow[] jobPartExists = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1475 if ( jobPartExists.Length <= 0 )
1476 {
1477
1478 //MessageBox.Show("584 add " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1479 AddJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
1480 }
1481 else
1482 {
1483 //MessageBox.Show("589 update " + "PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1484 UpdateJobPart(ref boJobEntry,ref dsJobEntry, batchRow["Calculated_PartNum"].ToString().ToString(), Convert.ToInt32(batchRow["Calculated_Qty"]),1,"",batchRow["Calculated_Comment"].ToString());
1485 }
1486 DataRow[] jobPartRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + batchRow["Calculated_PartNum"].ToString() + "'");
1487
1488 // get job prod
1489 AddJobProd(ref boJobEntry, ref dsJobEntry, batchRow["Calculated_PartNum"].ToString(), Convert.ToInt32(batchRow["Calculated_OrderNum"]), Convert.ToInt32(batchRow["Calculated_OrderLine"]), Convert.ToInt32(batchRow["Calculated_OrderRelNumHide"]));
1490 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"]));
1491
1492 // add in operations for this part
1493 dsJobEntry = boJobEntry.GetByID(currentJob);
1494 string rev;
1495 bool bUpdate = false;
1496 if ( GetLatestRev(batchRow["Calculated_PartNum"].ToString(), out rev) )
1497 {
1498 System.Collections.Hashtable parameters = new System.Collections.Hashtable();
1499 parameters.Add("ppartnum", batchRow["Calculated_PartNum"].ToString() );
1500 parameters.Add("previsionnum", rev );
1501 DataTable dtNewOps = GetQueryData("CPEPartOpr", parameters);
1502 foreach ( DataRow newOper in dtNewOps.Rows )
1503 {
1504 DataRow[] jobOperRows = dsJobEntry.Tables["JobOper"].Select("assemblyseq = 0 and OpCode = '" + newOper["Calculated_OpCode"].ToString() + "'");
1505 if ( jobOperRows.Length > 0 )
1506 {
1507 jobOperRows[0]["RowMod"] = "U";
1508 jobOperRows[0]["ProdStandard"] = Convert.ToDecimal(jobOperRows[0]["ProdStandard"]) + (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
1509 bUpdate = true;
1510 }
1511 else
1512 {
1513 // add in the new operation
1514 if ( bUpdate )
1515 {
1516 boJobEntry.Update(dsJobEntry);
1517 bUpdate = false;
1518 }
1519 boJobEntry.GetNewJobOper(dsJobEntry, currentJob,0);
1520 string refresh;
1521 boJobEntry.ChangeJobOperOpCode(newOper["Calculated_OpCode"].ToString(), out refresh, dsJobEntry);
1522 DataRow[] newOperRow = dsJobEntry.Tables["JobOper"].Select("RowMod = 'A'");
1523
1524 boJobEntry.ChangeJobOperOpStdID(dsJobEntry);
1525 newOperRow[0]["ProdStandard"] = (Convert.ToDecimal(newOper["Calculated_ProdStandard"]) / Convert.ToDecimal(jobBatchCount));
1526 boJobEntry.ChangeJobOperProdStandard(dsJobEntry);
1527 boJobEntry.Update(dsJobEntry);
1528 bUpdate = false;
1529 }
1530 }
1531
1532 if ( bUpdate )
1533 {
1534 boJobEntry.Update(dsJobEntry);
1535 bUpdate = false;
1536 }
1537 DataTable dtNewMtl = GetQueryData("CPEPartMtl", parameters);
1538 bUpdate = false;
1539 foreach ( DataRow newMtl in dtNewMtl.Rows )
1540 {
1541 DataRow[] jobMtlRows = dsJobEntry.Tables["JobMtl"].Select("AssemblySeq = 0 and PartNum = '" + newMtl["Calculated_PartNum"].ToString() + "' and IUM = '" + newMtl["Calculated_UOM"].ToString() + "'");
1542
1543
1544 if ( jobMtlRows.Length > 0 )
1545 {
1546 //MessageBox.Show("653 increase mtl " + Convert.ToString(jobMtlRows[0]["QtyPer"]) + " + " + (Convert.ToString(newMtl["Calculated_QtyPer"]) + " * " + numOfEA.ToString()));
1547 jobMtlRows[0]["RowMod"] = "U";
1548 jobMtlRows[0]["QtyPer"] = Convert.ToDecimal(jobMtlRows[0]["QtyPer"]) + (Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA);
1549 bUpdate = true;
1550
1551 }
1552 else
1553 {
1554 // add in new material
1555 if ( bUpdate )
1556 {
1557 boJobEntry.Update(dsJobEntry);
1558 bUpdate = false;
1559 }
1560 loc = "577";
1561 boJobEntry.GetNewJobMtl(dsJobEntry, currentJob, 0);
1562 string str1; string str2; string str3; bool b1; bool b2; bool b3;
1563 string partNum = newMtl["Calculated_PartNum"].ToString();
1564 DataRow[] newMtlRow = dsJobEntry.Tables["JobMtl"].Select("RowMod = 'A'");
1565 // newMtlRow[0]["PartNum"] = partNum;
1566 // newMtlRow[0]["Description"] = newMtl["Calculated_Description"].ToString();
1567
1568 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);
1569 if ( newMtlRow[0]["IUM"].ToString() != newMtl["Calculated_UOM"].ToString())
1570 {
1571 boJobEntry.ChangeJobMtlIUM(newMtl["Calculated_UOM"].ToString(), dsJobEntry);
1572 }
1573 newMtlRow[0]["FixedQty"] = true;
1574 newMtlRow[0]["QtyPer"] = Convert.ToDecimal(newMtl["Calculated_QtyPer"]) * numOfEA;
1575
1576 boJobEntry.ChangeJobMtlQtyPer(dsJobEntry);
1577
1578 boJobEntry.Update(dsJobEntry);
1579 bUpdate = false;
1580 loc = "590";
1581 }
1582 }
1583 if ( bUpdate )
1584 {
1585 boJobEntry.Update(dsJobEntry);
1586 }
1587 // add in materials for this part
1588 }
1589
1590 }
1591 castRows = m_dtOrdersToBatch.Select("Calculated_ProcessHide = 0 and Calculated_Batch = true and Calculated_Use_Existing_Cast = true and Calculated_OnHand_Cast_LotNum = '" + theCast + "'");
1592 }// end of else
1593 } // end of foreach
1594 personOnCast.Clear();
1595 personOnCast = null;
1596 }// end while
1597 }
1598
1599
1600
1601
1602 string jobMessage = numJobs.ToString() + " jobs created from " + firstJob + " to " + currentJob;
1603 if ( bNewCastFromJobError )
1604 {
1605 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;
1606 }
1607 MessageBox.Show(jobMessage + message + m_plantLotSeqUpdate);
1608 if ( boJobEntry != null )
1609 {
1610 boJobEntry.Dispose();
1611 boJobEntry = null;
1612 }
1613 if ( dsJobEntry != null )
1614 dsJobEntry.Clear();
1615
1616 if ( boUD08 != null )
1617 {
1618 boUD08.Dispose();
1619 boUD08 = null;
1620 }
1621 GetData(false);
1622 }
1623 }catch ( Exception ex )
1624 {
1625 MessageBox.Show(loc + " < Create Jobs error: " + ex.Message);
1626 }
1627 }
1628
1629 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)
1630 {
1631 try
1632 {
1633 /*string leftOrRight = "Right";
1634 if ( salesUM.Trim().ToLower() == "right" )
1635 {
1636 leftOrRight = "Right";
1637 }*/
1638 //MessageBox.Show(mouldNum.ToString() + " <> " + numOfEA.ToString());
1639 for ( int count = 0; count < 2; ++count)//numOfEA; ++count)
1640 {
1641 Ice.BO.UD08DataSet dsUD08 = new Ice.BO.UD08DataSet();
1642
1643
1644 boUD08.GetaNewUD08(dsUD08);
1645 dsUD08.Tables["UD08"].Rows[0]["Key1"] = partNum;
1646 dsUD08.Tables["UD08"].Rows[0]["Key2"] = lotNum;
1647 dsUD08.Tables["UD08"].Rows[0]["Key3"] = mouldNum - count;
1648 dsUD08.Tables["UD08"].Rows[0]["Key4"] = orderNum.ToString();
1649 dsUD08.Tables["UD08"].Rows[0]["Key5"] = orderLine.ToString();
1650 dsUD08.Tables["UD08"].Rows[0]["Number01"] = Convert.ToInt32(mouldNum) - count;
1651 dsUD08.Tables["UD08"].Rows[0]["Number02"] = orderNum;
1652 dsUD08.Tables["UD08"].Rows[0]["Number03"] = orderLine;
1653 dsUD08.Tables["UD08"].Rows[0]["ShortChar01"] = perCon;
1654 dsUD08.Tables["UD08"].Rows[0]["ShortChar02"] = salesUM;
1655 if ((mouldNum - count) % 2 == 0)
1656 {
1657 dsUD08.Tables["UD08"].Rows[0]["ShortChar03"] = "Left";
1658 }
1659 else
1660 {
1661 dsUD08.Tables["UD08"].Rows[0]["ShortChar03"] = "Right";
1662 }
1663 try
1664 {
1665 boUD08.Update(dsUD08);
1666 }catch ( Exception ex1 )
1667 {
1668 if ( ex1.Message.Contains("uplicate") )
1669 {
1670
1671 }
1672 else
1673 {
1674 MessageBox.Show("CreateUD08Row inner error: " + ex1.Message);
1675 }
1676 }
1677
1678
1679 /* if ( leftOrRight == "Right" )
1680 {
1681 leftOrRight = "Left";
1682 }
1683 else
1684 {
1685 leftOrRight = "Right";
1686 }*/
1687 }
1688 }catch ( Exception ex )
1689 {
1690 MessageBox.Show("CreateUD08Row error: " + ex.Message);
1691 }
1692 }
1693
1694 private void UpdateJobPart(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int qty, int weight, string lotNum, string newcomment)
1695 {
1696 try
1697 {
1698
1699 DataRow[] newRows = dsJobEntry.Tables["JobPart"].Select("PartNum = '" + partNum + "'");
1700 if ( newRows.Length > 0 )
1701 {
1702 string comment = newRows[0]["Comment_c"].ToString();
1703 if ( comment.Length > 0 )
1704 {
1705 newRows[0]["Comment_c"] = comment + System.Environment.NewLine + newcomment;
1706 boJobEntry.Update(dsJobEntry);
1707 }
1708 }
1709
1710 }catch ( Exception ex )
1711 {
1712 MessageBox.Show("Add Job Part Error: " + ex.Message);
1713 }
1714 }
1715 private void AddJobPart(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int qty, int weight, string lotNum, string comment)
1716 {
1717 try
1718 {
1719 boJobEntry.GetNewJobPart(dsJobEntry, dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"].ToString());
1720 DataRow[] newRows = dsJobEntry.Tables["JobPart"].Select("RowMod = 'A'");
1721 newRows[0]["PartNum"] = partNum;
1722
1723 boJobEntry.ChangeJobPartPartNum(dsJobEntry);
1724 newRows[0]["LbrCostBase"] = weight;
1725 newRows[0]["MtlCostBase"] = weight;
1726 newRows[0]["CPE_CastNumber_c"] = lotNum;
1727 newRows[0]["Comment_c"] = comment;
1728 boJobEntry.Update(dsJobEntry);
1729 }catch ( Exception ex )
1730 {
1731 MessageBox.Show("Add Job Part Error: " + ex.Message);
1732 }
1733 }
1734 private void AddJobProd(ref Erp.Proxy.BO.JobEntryImpl boJobEntry, ref Erp.BO.JobEntryDataSet dsJobEntry, string partNum, int orderNum, int orderLine, int orderRelNum)
1735 {
1736 try
1737 {
1738 boJobEntry.GetNewJobProd(dsJobEntry, dsJobEntry.Tables["JobHead"].Rows[0]["JobNum"].ToString(), partNum, 0, 0, 0, "", "", 0);
1739 DataRow[] jobProdRows = dsJobEntry.Tables["JobProd"].Select("RowMod = 'A'");
1740 jobProdRows[0]["MakeToType"] = "ORDER";
1741 boJobEntry.ChangeJobProdMakeToType(dsJobEntry);
1742 jobProdRows[0]["OrderNum"] = orderNum;
1743 boJobEntry.ChangeJobProdOrderNum(dsJobEntry);
1744 jobProdRows[0]["OrderLine"] = orderLine;
1745 boJobEntry.ChangeJobProdOrderLine(dsJobEntry);
1746 jobProdRows[0]["OrderRelNum"] = orderRelNum;
1747 boJobEntry.ChangeJobProdOrderRelNum(dsJobEntry);
1748 boJobEntry.Update(dsJobEntry);
1749 }catch ( Exception ex )
1750 {
1751 MessageBox.Show("Add Job Part Error: " + ex.Message);
1752 }
1753 }
1754
1755 private string CreateNewPlantLotNumber(string partNum, string jobNum, DateTime mfgDate)
1756 {
1757 string newLotNum = "";
1758
1759 try
1760 {
1761 System.Collections.Hashtable parameters = new System.Collections.Hashtable();
1762 DataTable dt = GetQueryData("CPENextCastLot", parameters);
1763 int nextSequence = 1;
1764 if ( (dt.Rows[0]["PlantConfCtrl_CastLotSequence_c"]) != System.DBNull.Value )
1765 {
1766 nextSequence = Convert.ToInt32(dt.Rows[0]["PlantConfCtrl_CastLotSequence_c"]);
1767 }
1768 string plantIDentifier = "1";
1769 if ( dt.Rows[0]["PlantConfCtrl_CastLotPlantIdentifier_c"] != System.DBNull.Value )
1770 {
1771 plantIDentifier = Convert.ToString(dt.Rows[0]["PlantConfCtrl_CastLotPlantIdentifier_c"]);
1772 }
1773 string prefix = "AA";
1774 if ( dt.Rows[0]["PlantConfCtrl_CastLotPrefix_c"] != System.DBNull.Value )
1775 {
1776 prefix = Convert.ToString(dt.Rows[0]["PlantConfCtrl_CastLotPrefix_c"]);
1777 }
1778 newLotNum = string.Format("{0}{1}{2:00000}",prefix , plantIDentifier , nextSequence);
1779
1780 bool recSelected = false;
1781 string where = "partnum = '" + partNum + "' and lotnum = '" + newLotNum + "'";
1782 DataSet ds = SearchFunctions.listLookup(oTrans,"LotSelectUpdate", out recSelected, false, where);
1783 while ( recSelected )
1784 {
1785
1786 nextSequence += 1;
1787 if ( nextSequence >= 99999 )
1788 {
1789 nextSequence = 1;
1790 char[] bits = prefix.ToCharArray();
1791 if (bits.Length == 2)
1792 {
1793 switch (bits[1])
1794 {
1795 case 'Z':
1796 bits[1] = 'A';
1797 ++bits[0];
1798 if (bits[0] > 'Z')
1799 bits[0] = 'A';
1800 break;
1801 default:
1802 ++bits[1];
1803 break;
1804 }
1805 prefix = bits[0].ToString().Trim() + bits[1].ToString().Trim();
1806
1807 }
1808 }
1809 newLotNum = string.Format("{0}{1}{2:00000}",prefix , plantIDentifier , nextSequence);
1810
1811 where = "partnum = '" + partNum + "' and lotnum = '" + newLotNum + "'";
1812 ds = SearchFunctions.listLookup(oTrans,"LotSelectUpdate", out recSelected, false, where);
1813 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);
1814 }
1815 Erp.Proxy.BO.LotSelectUpdateImpl boLotSelectUpdate = null;
1816 boLotSelectUpdate = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.LotSelectUpdateImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/LotSelectUpdate.svc");
1817 Erp.BO.LotSelectUpdateDataSet dsLotSelectUpdate = new Erp.BO.LotSelectUpdateDataSet();
1818
1819 boLotSelectUpdate.GetNewPartLot(dsLotSelectUpdate, partNum);
1820
1821
1822 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["LotNum"] = newLotNum;
1823 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["Batch"] = jobNum;
1824 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["MfgDt"] = mfgDate;
1825 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["ExpirationDate"] = mfgDate.AddYears(5);
1826
1827 boLotSelectUpdate.Update(dsLotSelectUpdate);
1828 dsLotSelectUpdate.Clear();
1829 boLotSelectUpdate.Dispose();
1830
1831 }catch ( Exception ex )
1832 {
1833 MessageBox.Show("CreateNewLotNumber error: " + ex.Message);
1834 }
1835 return newLotNum;
1836 }
1837
1838
1839 private DataSet BOReaderData(string businessObject, string filter, string fieldList)
1840 {
1841 DataSet ds = new DataSet();
1842 Ice.Core.Session session = null;
1843 Ice.Proxy.Lib.BOReaderImpl boReader = null;
1844 try
1845 {
1846 session = (Ice.Core.Session)oTrans.Session;
1847 boReader = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>(session, "ice/lib/BOReader.svc");
1848 ds = boReader.GetRows("Erp:BO:" + businessObject, filter, fieldList);
1849 }
1850 catch (Exception ex)
1851 {
1852 MessageBox.Show("BOReader error: " + ex.Message);
1853 }
1854 finally
1855 {
1856 if (boReader != null)
1857 {
1858 boReader.Dispose();
1859 }
1860 }
1861 return ds;
1862 }
1863
1864
1865 private string IncrementLetters(string letters)
1866 {
1867
1868 char[] bits = letters.ToCharArray();
1869 if (bits.Length == 2)
1870 {
1871 switch (bits[1])
1872 {
1873 case 'Z':
1874 bits[1] = 'A';
1875 ++bits[0];
1876 if (bits[0] > 'Z')
1877 bits[0] = 'A';
1878 break;
1879 default:
1880 ++bits[1];
1881 break;
1882 }
1883 letters = bits[0].ToString() + bits[1].ToString();
1884 }
1885 return letters;
1886
1887 }
1888
1889 private string CreateNewStdLotNumber(string partNum, string jobNum, DateTime mfgDate)
1890 {
1891 string newLotNum = "";
1892 try
1893 {
1894 Erp.Proxy.BO.LotSelectUpdateImpl boLotSelectUpdate = null;
1895 boLotSelectUpdate = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.LotSelectUpdateImpl>((Ice.Core.Session)oTrans.Session, "erp/bo/LotSelectUpdate.svc");
1896 Erp.BO.LotSelectUpdateDataSet dsLotSelectUpdate = new Erp.BO.LotSelectUpdateDataSet();
1897 boLotSelectUpdate.GetNewPartLot(dsLotSelectUpdate, partNum);
1898
1899 boLotSelectUpdate.GenerateNewLotNum(partNum, out newLotNum);
1900 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["LotNum"] = newLotNum;
1901 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["Batch"] = jobNum;
1902 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["MfgDt"] = mfgDate;
1903 dsLotSelectUpdate.Tables["PartLot"].Rows[0]["ExpirationDate"] = mfgDate.AddYears(5);
1904
1905 boLotSelectUpdate.Update(dsLotSelectUpdate);
1906 dsLotSelectUpdate.Clear();
1907 boLotSelectUpdate.Dispose();
1908
1909 }catch ( Exception ex )
1910 {
1911 MessageBox.Show("CreateNewLotNumber error: " + ex.Message);
1912 }
1913 return newLotNum;
1914 }
1915
1916 private void grdMain_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args)
1917 {
1918 if ( args.Cell.Column.Key == "Calculated_Use_Existing_Cast" )
1919 {
1920 args.Cell.Row.Cells["Calculated_Batch"].Value = args.Cell.Row.Cells["Calculated_Use_Existing_Cast"].Value;
1921 grdMain.ActiveRow.Update();
1922 }
1923 if ( args.Cell.Column.Key == "Calculated_Batch" )
1924 {
1925 if ( args.Cell.Row.Cells["Calculated_PartNum"].Value.ToString().ToUpper().EndsWith("R") )
1926 {
1927
1928 if ( args.Cell.Row.Cells["Calculated_OnHand_Cast_LotNum"].Value.ToString().Trim().Length == 0 )
1929 {
1930 args.Cell.Row.Cells["Calculated_Use_Existing_Cast"].Value = true;
1931 args.Cell.Row.Cells["Calculated_OnHand_Cast_LotNum"].Value = "NEW CAST FROM JOB";
1932 args.Cell.Row.Cells["Calculated_OnHand_Cast"].Value = "NEW CAST FROM JOB";
1933 grdMain.ActiveRow.Update();
1934 }
1935 }
1936 }
1937 }
1938
1939 private void grdMain_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs args)
1940 {
1941 if ( args.Cell.Column.Key == "Calculated_Use_Existing_Cast" )
1942 {
1943 grdMain.ActiveRow.Update();
1944 }
1945 }
1946
1947 private void edvCallContextBpmData_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
1948 {
1949 // ** Argument Properties and Uses **
1950 // view.dataView[args.Row]["FieldName"]
1951 // args.Row, args.Column, args.Sender, args.NotifyType
1952 // NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
1953 if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
1954 {
1955 if ((args.Row > -1))
1956 {
1957
1958 }
1959 }
1960 }
1961
1962 private void epiButtonC1_Click(object sender, System.EventArgs args)
1963
1964 {
1965
1966 MessageBox.Show(CreateNewPlantLotNumber("CAST", "TESTCreate", DateTime.Now));
1967
1968
1969
1970 }
1971}