Exemple #1
0
        private void UpdateCutlist(string itemNo, string rev)
        {
            int    itpSetup  = int.Parse(cbSetupBy.SelectedValue.ToString());
            ushort itpState  = 0;
            ushort itpCust   = 0;
            double dtpLength = 0.0f;
            double dtpWidth  = 0.0f;
            double dtpHeight = 0.0f;

            try {
                if (!ushort.TryParse(CutlistData.GetCutlistData(itemNo, rev).Tables[0].
                                     Rows[0][(int)CutlistData.CutlistDataFields.STATEID].ToString(), out itpState))
                {
                    itpState = 0;
                }
            } catch (IndexOutOfRangeException ioore) {
                System.Diagnostics.Debug.Print(string.Format(@"{0}, but it's OK.", ioore.Message));
            } catch (Exception ex) {
                RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex, CutlistData);
                em.Show();
            }

            if (!ushort.TryParse(cbCustomer.SelectedValue.ToString(), out itpCust))
            {
                itpCust = 0;
            }

            dtpLength = ParseFloat(tbL.Text);
            dtpWidth  = ParseFloat(tbW.Text);
            dtpHeight = ParseFloat(tbH.Text);

            if (table != null)
            {
                CutlistData.EmptyCutlist(itemNo, rev);
                CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text,
                                          itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, table.GetParts());
            }
            else if (part != null)
            {
                Dictionary <string, Part> d = new Dictionary <string, Part>();
                d.Add(part.PartNumber, part);
                CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text,
                                          itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, d);
            }
            else
            {
                DrawingPropertySet.SwApp.SendMsgToUser2("Failed to read table or part.",
                                                        (int)SolidWorks.Interop.swconst.swMessageBoxIcon_e.swMbStop,
                                                        (int)SolidWorks.Interop.swconst.swMessageBoxBtn_e.swMbOk);
            }
        }