Inheritance: System.Windows.Forms.Form
Esempio n. 1
0
        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); }
        }
Esempio n. 2
0
        public Bill_Master(List<BillItem>Bill , string ParentNumber, string Rev, decimal weight_val, decimal area_val)
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

            try
            {
                weight.Value = weight_val;

                area.Value = area_val;
            }
            catch { }

            BillDataGrid.AutoGenerateColumns = false;

            gid_txt.Text = Properties.Settings.Default.ecogroup;

            if (Rev == "")
                parentrev_txt.Text = DataList.GetCurrentRev(ParentNumber);
            else
                parentrev_txt.Text = Rev;

            partnum_txt.Leave += partnum_txt_Leave;

            mtlseq_txt.Text = GetNextSeq().ToString();

            parent_txt.Text = ParentNumber;

            try
            {
                EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);

                BillDataGrid.DataSource = EngWBDS.Tables["ECOMtl"];
            }
            catch
            {
                try
                {
                    MessageBox.Show("You must check part out before continuing.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    CheckOut_Master CO_M = new CheckOut_Master(parent_txt.Text);

                    DialogResult dr = CO_M.ShowDialog();

                    if (dr != DialogResult.Cancel)
                    {
                        EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);

                        BillDataGrid.DataSource = EngWBDS.Tables["ECOMtl"];
                    }
                    else
                        this.Close();
                }
                catch (Exception ex1) {MessageBox .Show (ex1.Message + "\n\nThis process will now close","Error!",MessageBoxButtons.OK,MessageBoxIcon.Error); }
            }

            this.FormClosing += Bill_Master_FormClosing;

            BW.RunWorkerAsync(Bill);

            try
            {
                BWForm.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"Bill Master Error!",MessageBoxButtons.OK,MessageBoxIcon.Error);

                BWForm.Dispose();

                BWForm = new Waiting("Loading Bill of Materials into Epicor...");

                BWForm.ShowDialog();
            }
        }