Exemplo n.º 1
0
        /// <summary>
        /// Figure out where an item is used, and select the last one the user had selected.
        /// </summary>
        private void UpdateCutlistBox()
        {
            DataSet ds = cd.GetWherePartUsed(propertySet.PartName);
            int     s  = 1;

            cbCutlist.DataSource    = ds.Tables[(int)CutlistData.WhereUsedRes.CLID];
            cbCutlist.DisplayMember = "PARTNUM";
            cbCutlist.ValueMember   = "CLID";

            cbCutlist.Text = string.Empty;

            cbCutlist.SelectedValue = Properties.Settings.Default.CurrentCutlist;

            if (cbCutlist.SelectedItem != null)
            {
                cbCutlist.SelectedText  = (cbCutlist.SelectedItem as DataRowView)[(int)CutlistData.WhereUsedRes.PARTNUM].ToString();
                cbCutlist.SelectedValue = Properties.Settings.Default.CurrentCutlist;

                if (cbCutlist.SelectedItem != null && int.TryParse((cbCutlist.SelectedItem as DataRowView)[(int)CutlistData.WhereUsedRes.STATEID].ToString(), out s))
                {
                    nudQ.Enabled           = true;
                    cbStatus.Enabled       = true;
                    cbStatus.SelectedValue = s;
                    cbStatus.Text          = cd.GetStateByID(s);
                }
            }
            else
            {
                cbStatus.Text    = string.Empty;
                nudQ.Enabled     = false;
                cbStatus.Enabled = false;
                nudQ.Value       = 1;
            }

            if (cbCutlist.SelectedItem != null && int.TryParse((cbCutlist.SelectedItem as DataRowView)[(int)CutlistData.WhereUsedRes.QTY].ToString(), out s))
            {
                nudQ.Value = s;
            }

            if (cbCutlist.Text == string.Empty)
            {
                propertySet.CutlistID = 0;
                bRemove.Enabled       = false;
            }
            else
            {
                int sv = 0;
                if (int.TryParse(cbCutlist.SelectedValue.ToString(), out sv))
                {
                    propertySet.CutlistID = sv;
                }
                bRemove.Enabled = true;
            }
        }