void IEdmAddIn5.OnCmd(ref EdmCmd poCmd, ref System.Array ppoData) { try { BW.RunWorkerCompleted += BW_RunWorkerCompleted; BW.WorkerSupportsCancellation = true; Debug.Print("Command Type: " + poCmd.meCmdType.ToString() + "\n " + System.DateTime.Now.ToString()); IEdmVault5 edmVault = poCmd.mpoVault as IEdmVault5; EdmCmdData[] Temp = (EdmCmdData[])ppoData; IEdmVault7 vault = (IEdmVault7)poCmd.mpoVault; vault_ = vault; try { file_ = Temp[0]; } catch { } DataHelper helper = new DataHelper(); try { switch (poCmd.meCmdType) { case EdmCmdType.EdmCmd_Menu: switch (poCmd.mlCmdID) { case 1: #region Item Master foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) GetItemInfo(vault, file, ""); } #endregion break; case 2: #region Add Item/Rev/OOM/BOM string config; foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) { IEdmFile5 part = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); string selected_config = DetermineConfig(part, vault, file, ""); if (GetItemInfo(vault, file, selected_config) == DialogResult.Cancel) break; if (AddRevision(vault, file, selected_config) == DialogResult.Cancel) break; if (AddOOM(vault, file, selected_config) == DialogResult.Cancel) break; #region Bill Master BWForm = new Waiting("Retrieving Bill of Materials from SolidWorks..."); ParentNumber = ""; Area = 0; Weight = 0; Bill.Clear(); string sconfig; AddBill(vault, file, "", out sconfig); if (sconfig == null) break; Bill.Sort((x, y) => x.PartNumber.CompareTo(y.PartNumber)); CombineBill(); Bill_Master BM = new Bill_Master(Bill, ParentNumber, "", Weight, Area); #endregion if (BM.ShowDialog() == DialogResult.Cancel) break; if (CheckInPart(vault, file, selected_config) == DialogResult.Cancel) break; } } #endregion break; case 3: #region CheckOut_Master foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) CheckOutPart(vault, file); } #endregion break; case 4: #region Add Revision foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) AddRevision(vault, file, ""); } #endregion break; case 5: #region OOM_Master foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) AddOOM(vault, file, ""); } #endregion break; case 6: #region Bill Master BWForm = new Waiting("Retrieving Bill of Materials from SolidWorks..."); foreach (EdmCmdData file in Temp) { ParentNumber = ""; Area = 0; Weight = 0; try { //BW = null; //BW = new BackgroundWorker(); Bill.Clear(); string sconfig; AddBill(vault, file, "", out sconfig); if (sconfig == null) break; Bill.Sort((x, y) => x.PartNumber.CompareTo(y.PartNumber)); CombineBill(); Bill_Master BM = new Bill_Master(Bill, ParentNumber, "", Weight, Area); BM.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion break; case 7: #region CheckIn_Master foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) CheckInPart(vault, file, ""); } #endregion break; case 0: #region RevCompare BWForm = new Waiting("Retrieving Bill of Materials from SolidWorks..."); foreach (EdmCmdData file in Temp) { try { string file_ext = file.mbsStrData1.Substring(file.mbsStrData1.LastIndexOf('.') + 1).ToUpper(); if (file_ext == "SLDASM") { if (file.mlObjectID1 != null) { System.Data.DataSet DS = new System.Data.DataSet(); DS.Tables.Add("PartMtl"); DS.Tables[0].Columns.Add("MtlPartNum"); DS.Tables[0].Columns.Add("QtyPer"); Bill.Clear(); ParentNumber = ""; string rconfig; AddBill(vault, file, "", out rconfig); if (rconfig == null) break; try { Bill.Sort((x, y) => x.PartNumber.CompareTo(y.PartNumber)); CombineBill(); foreach (BillItem item in Bill) { System.Data.DataRow dr = DS.Tables[0].NewRow(); dr["MtlPartNum"] = item.PartNumber; dr["QtyPer"] = item.Qty; DS.Tables[0].Rows.Add(dr); } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { RevCompare RC = new RevCompare(DS, ParentNumber); RC.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { RevCompare RC = new RevCompare(); RC.ShowDialog(); } } else { MessageBox.Show("This function cannot be used on Parts.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; #endregion case -2: #region Op Minutes foreach (EdmCmdData file in Temp) { try { Mins[0] = 0; //Huck Mins[1] = 0; //Tec Mins[2] = 0; //Bolt Mins[3] = 0; //Rivet Mins[4] = 0; //Band Mins[5] = 0; //Heat Mins[6] = 0; //Spring Mins[7] = 0; //Zhooks BW = null; BW = new BackgroundWorker(); BW.WorkerSupportsCancellation = true; CalcMins(vault, file, ""); Epicor_Integration.Operations_Minutes OpsMins = new Operations_Minutes(Mins[0].ToString(), Mins[1].ToString(), Mins[2].ToString(), Mins[3].ToString(), Mins[4].ToString(), Mins[5].ToString(), Mins[6].ToString(), Mins[7].ToString()); OpsMins.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; #endregion case -1: Config conf = new Config(); conf.ShowDialog(); break; case -10: foreach (EdmCmdData file in Temp) { if (ValidSelection(file)) { Update_Properties Update = new Update_Properties(vault, file); Update.ShowDialog(); } } break; case -100: Template_Master TM = new Template_Master(); TM.ShowDialog(); break; case - 101: SearchPart SP = new SearchPart(); SP.ShowDialog(); break; default: break; } break; default: break; } } catch (COMException exp) { string errorName, errorDesc; edmVault.GetErrorString(exp.ErrorCode, out errorName, out errorDesc); edmVault.MsgBox(0, errorDesc, EdmMBoxType.EdmMbt_OKOnly, errorName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void bill_btn_Click(object sender, EventArgs e) { if (!legacy_chk.Checked) { if (filedir_txt.Text != null && filedir_txt.Text != "") SWHelper.GetBill(filedir_txt.Text, pnum_txt.Text); else browse_btn_Click(browse_btn, null); } else { Bill_Master BM = new Bill_Master(pnum_txt.Text, rev_txt.Text); BM.ShowDialog(); } }