Esempio n. 1
0
        private void btPlus_Click(object sender, EventArgs e)
        {
            if (!tbPicture.Enabled)
                return;
            Line Line = null;
            if (tvCurve.SelectedNode == null)
                return;
            if (tvCurve.SelectedNode.Tag is Line)
                Line = tvCurve.SelectedNode.Tag as Line;

            if (CorniceType == 3)
            {

                if (tvCurve.SelectedNode.Tag is SplintComponent)
                    Line = (tvCurve.SelectedNode.Tag as SplintComponent).Line;

                if (Line == null)
                    return;

                SplintContourType SplintContourType = SplintContourType.PreCork;
                foreach (SplintComponent SptintCompontent in Line)
                    SplintContourType = SptintCompontent.FinishType;

                TfAddSplint f = new TfAddSplint() { Tag = this };
                f.lcb.Enabled = true;
                f.Text = "Новый элемент шины";
                f.StartType = SplintSections.ReverseSplintContourType(SplintContourType);
                f.tbComponentsBindingSource.DataSource = dsSplints;

                if (f.ComponentList() == "")
                {
                    MessageBox.Show("Карниз уже полностью собран или нет нужных деталей!");
                    return;
                }

                string sFilter = String.Format
                    ("[Код профиля]={0:G} AND [Код] IN ({1:G})", Line.ProfileId, f.ComponentList());
                dsSplints.tbComponentsRow[] rcComp = (dsSplints.tbComponentsRow[])
                    dsSplints.tbComponents.Select(sFilter);
                if (rcComp.Length <= 0)
                {
                    MessageBox.Show("Карниз уже полностью собран или нет нужных деталей!");
                    return;
                }
                f.tbComponentsBindingSource.Filter = sFilter;
                f.lcb_SelectedIndexChanged(f.lcb, null);

                if (f.ShowDialog() != DialogResult.OK)
                    return;

                dsLines.tbSplintSectionsRow rws = (dsLines.tbSplintSectionsRow)
                    dsLines.tbSplintSections.NewRow();
                rws.Код_компоненты = Convert.ToInt32(f.lcb.SelectedValue);
                rws.Код_линии = Line.ID;
                rws.Номер = Line.Count + 1;
                rws.Значение = Convert.ToDouble(f.edValue.Value);

                dsLines.tbSplintSections.Rows.Add(rws);
                dsLines.tbSplintSections.AcceptChanges();

                UpdateTVCurve();

                foreach (TreeNode ndf in tvCurve.Nodes)
                    foreach (TreeNode nd in ndf.Nodes)
                        if (nd.Tag is SplintComponent &&
                            (nd.Tag as SplintComponent).Numer == rws.Номер)
                            tvCurve.SelectedNode = nd;

                tvCurve.Focus();
                pnWall.Invalidate();
            }
            else
            {

            }
        }
Esempio n. 2
0
        private void btEdit_Click(object sender, EventArgs e)
        {
            if (!tbPicture.Enabled)
                return;

            if (tvCurve.SelectedNode == null)
                return;

            if (CorniceType == 3)
            {
                if (!(tvCurve.SelectedNode.Tag is SplintComponent))
                    return;

                SplintComponent Component =
                    (tvCurve.SelectedNode.Tag as SplintComponent);

                TfAddSplint f = new TfAddSplint() { Tag = this };
                f.lcb.Enabled = false;
                f.Text = "Редактирование элемента шины";
                f.StartType = Component.StartType;
                f.tbComponentsBindingSource.DataSource = dsSplints;
                f.tbComponentsBindingSource.Filter = "[Код]=" + Component.Id.ToString();
                f.lcb_SelectedIndexChanged(f.lcb, null);
                f.edValue.Value = Convert.ToDecimal(Component.Value);

                if (f.ShowDialog() != DialogResult.OK)
                    return;

                dsLines.tbSplintSectionsRow rws = (dsLines.tbSplintSectionsRow)
                    dsLines.tbSplintSections.Select("[Номер]=" + Component.Numer.ToString() +
                        " AND [Код линии]=" + Component.Line.ID.ToString())[0];
                rws.Значение = Convert.ToDouble(f.edValue.Value);

                dsLines.tbSplintSections.AcceptChanges();

                UpdateTVCurve();

                foreach (TreeNode ndf in tvCurve.Nodes)
                    foreach (TreeNode nd in ndf.Nodes)
                        if (nd.Tag is SplintComponent &&
                            (nd.Tag as SplintComponent).Numer == Component.Numer)
                            tvCurve.SelectedNode = nd;

                tvCurve.Focus();
                pnWall.Invalidate();
            }
            else
            {

            }
        }