private void InitControlsWithPart(Part p, CutlistData cd) { Text = "Add to cutlist..."; for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbRev.Enabled = false; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); // Not classy, but it makes the boxes update the first time around. clicked = true; CurrentCutlist = Properties.Settings.Default.CurrentCutlist; if (CurrentCutlist != 0) { cbItemNo.SelectedIndex = cbItemNo.FindString( cd.GetCutlistData(CurrentCutlist).Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString()); } }
private void xInitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); DataSet dr = CutlistData.GetCutlistData(itemNo, Rev); cbCustomer.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.CUSTID].ToString()); cbItemNo.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString(); cbDescription.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DESCR].ToString(); tbL.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.LENGTH].ToString(); tbW.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.WIDTH].ToString(); tbH.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.HEIGHT].ToString(); cbDrawingReference.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DRAWING].ToString(); cbSetupBy.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.SETUP_BY].ToString()); }
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); } }
private void xInitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) cbRev.Items.Add(i.ToString()); cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); DataSet dr = CutlistData.GetCutlistData(itemNo, Rev); cbCustomer.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.CUSTID].ToString()); cbItemNo.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString(); cbDescription.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DESCR].ToString(); tbL.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.LENGTH].ToString(); tbW.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.WIDTH].ToString(); tbH.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.HEIGHT].ToString(); cbDrawingReference.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DRAWING].ToString(); cbSetupBy.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.SETUP_BY].ToString()); }
private void InitControlsWithPart(Part p, CutlistData cd) { Text = "Add to cutlist..."; for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) cbRev.Items.Add(i.ToString()); cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbRev.Enabled = false; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); // Not classy, but it makes the boxes update the first time around. clicked = true; CurrentCutlist = Properties.Settings.Default.CurrentCutlist; if (CurrentCutlist != 0) { cbItemNo.SelectedIndex = cbItemNo.FindString( cd.GetCutlistData(CurrentCutlist).Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString()); } }
private void AddECRItem(DrawingRev r) { ModelDoc2 md = (ModelDoc2)r.SwApp.ActiveDoc; string partpath = md.GetPathName(); string partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath); if (md.GetPathName() == string.Empty) { md.Extension.RunCommand((int)swCommands_e.swCommands_SaveAs, md.GetTitle()); if (md.GetPathName() == string.Empty) { throw new Exception("Unsaved drawings cannot be added to an ECR."); } partpath = md.GetPathName(); partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath); } string[] partarr = partfilename.Split(new string[] { "REV" }, StringSplitOptions.RemoveEmptyEntries); string partno = partarr[0].Trim(); string rv = revision.Value; if (partarr.Length > 1) { rv = partarr[1].Trim(); } string question = string.Format(Properties.Resources.InsertIntoEcrItems, System.IO.Path.GetFileName(partno), r.Eco.Value); swMessageBoxResult_e mbr = swMessageBoxResult_e.swMbHitNo; int en = 0; if (int.TryParse(r.Eco.Value, out en) && !cutlist_data.ECRIsBogus(r.Eco.Value) && !cutlist_data.ECRItemExists(en, partno, revision.Value)) { mbr = (swMessageBoxResult_e)r.SwApp.SendMsgToUser2(question, (int)swMessageBoxIcon_e.swMbQuestion, (int)swMessageBoxBtn_e.swMbYesNo); } if (mbr == swMessageBoxResult_e.swMbHitYes) { OnAdded(EventArgs.Empty); ArchivePDF.csproj.ArchivePDFWrapper apw = new ArchivePDF.csproj.ArchivePDFWrapper(r.SwApp); apw.Archive(); int parttype = 7; // M2M M2MData m = new M2MData(); if (m.GetPartCount(partno, revision.Value) > 0) { parttype = m.GetPartType(partno, revision.Value); } else { // Cutlist int prtid = 0; if (int.TryParse( cutlist_data.GetCutlistData(partno, revision.Value).Tables[0].Columns["CLID"].ToString(), out prtid)) { if (prtid > 0) { parttype = 5; } } else { if (cutlist_data.PartUsed(partno)) { parttype = 6; } } } cutlist_data.InsertECRItem(en, partno, rv, parttype, r.Revision.Value, partpath, r.Eco.Value); } OnAddedLvl(new EventArgs()); }