Пример #1
0
        public TfMain(int orderId, string connectionString)
        {
            InitializeComponent();
            TfMain.OrderId = orderId;
            LocalService.ConnectionString = connectionString;

            DataTable tbOrder = LocalService.GetOrderInfo(orderId).Tables[0];
            if (tbOrder.Rows.Count <= 0)
            {
                MessageBox.Show("Данного заказа не существует. Приложение будет закрыто!", "Внимание",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TfMain.IsClose = true;
                return;
            }
            DataRow rwOrder = tbOrder.Rows[0];
            OrderType = Convert.ToInt32(rwOrder["Код типа гнутия"]);
            CorniceType = Convert.ToInt32(rwOrder["Код типа карниза"]);

            dsSplints.Clear();
            dsSplints.tbComponents.Load(LocalService.GetSplintComponents().Tables[0].CreateDataReader());
            dsSplints.tbContour.Load(LocalService.GetSplintContour().Tables[0].CreateDataReader());

            dsLines.tbLine.Clear();
            dsLines.tbLine.Load(LocalService.GetLinesList(orderId).Tables[0].CreateDataReader());

            foreach (dsLines.tbLineRow rwl in dsLines.tbLine.Rows)
            {
                DataColumn cl = new DataColumn(rwl.Номер_линии.ToString(), typeof(double));
                cl.DefaultValue = rwl.Отлет;
                dsLines.tbWallClearance.Columns.Add(cl);

                DataGridViewTextBoxColumn dbgcol = new DataGridViewTextBoxColumn();
                dbgcol.DataPropertyName = rwl.Номер_линии.ToString();
                dbgcol.HeaderText = rwl.Номер_линии.ToString();
                dbgcol.Width = 80;
                dbgcol.DefaultCellStyle.Format = "N3";
                dbgcol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dbgcol.ReadOnly = false;
                dbgClearance.Columns.Add(dbgcol);
                dbgClearanceCurve.Columns.Add(dbgcol.Clone() as DataGridViewTextBoxColumn);
            }

            tb.TabStop = false;
            tb.SizeMode = TabSizeMode.Fixed;
            tb.Appearance = TabAppearance.FlatButtons;
            tb.ItemSize = new Size(0, 1);

            Text = $"График карниза (Заказ №{orderId:G})";

            if (LocalService.OrderState(orderId) != 0)
            {
                btRLine.Enabled = false;
                btSave.Enabled = false;
                btWallToLine.Enabled = false;
                tbWall.Enabled = false;
                tbPicture.Enabled = false;
                Text += " - только просмотр";
            }

            if (!LocalService.IsWallExists(orderId))
                return;

            try
            {
                dsWall.tbWall.Load(LocalService.GetWallList(orderId).Tables[0].CreateDataReader());
                dsWall.tbWallDetail.Load(LocalService.GetWallDetail(orderId).Tables[0].CreateDataReader());
                dsWall.AcceptChanges();

                int i = 0;
                foreach (dsWall.tbWallRow rww in dsWall.tbWall)
                {
                    dsWall.tbWallSegmentRow rws;

                    if (Math.Abs(rww.Угол) > 0.001)
                    {
                        rws = (dsWall.tbWallSegmentRow)dsWall.tbWallSegment.NewRow();
                        rws.Длина = 0;
                        rws.Угол = rww.Угол;
                        rws.Номер = ++i;
                        dsWall.tbWallSegment.Rows.Add(rws);
                        dsWall.tbWallSegment.AcceptChanges();
                        rww.Код_сегмента = rws.Код;
                    }

                    foreach (dsWall.tbWallDetailRow rwwd in dsWall.tbWallDetail.Select
                        ("[Код стены]=" + rww.Код.ToString()))
                    {
                        rws = (dsWall.tbWallSegmentRow)dsWall.tbWallSegment.NewRow();
                        rws.Длина = rwwd.Длина;
                        rws.Угол = rwwd.Угол;
                        rws.Номер = ++i;
                        dsWall.tbWallSegment.Rows.Add(rws);
                        dsWall.tbWallSegment.AcceptChanges();
                        rwwd.Код_сегмента = rws.Код;
                    }
                }

                dsWall.tbAgregate.Load(LocalService.GetAgregate(orderId).Tables[0].CreateDataReader());
                dsWall.tbMeasure.Load(LocalService.GetMeasure(orderId).Tables[0].CreateDataReader());

                dsWall.AcceptChanges();
                dsLines.tbClearance.Load(LocalService.GetLineClearance(orderId).Tables[0].CreateDataReader());

                foreach (dsWall.tbWallRow rwwd in dsWall.tbWall)
                {
                    dsLines.tbWallClearanceRow rwwc = (dsLines.tbWallClearanceRow)
                        dsLines.tbWallClearance.NewRow();
                    rwwc.Код_стены = rwwd.Код;
                    rwwc.Стена = (new Wall(dsWall, rwwd.Код)).Name;
                    foreach (dsLines.tbLineRow rwl in dsLines.tbLine)
                    {
                        DataRow[] rwcc = dsLines.tbClearance.Select
                            (String.Format("[Код стены]={0:G} AND [Код линии]={1:G}",
                            rwwd.Код, rwl.Код));
                        if (rwcc.Length <= 0)
                            rwwc[rwl.Номер_линии.ToString()] = rwl.Отлет;
                        else
                            rwwc[rwl.Номер_линии.ToString()] =
                                (rwcc[0] as dsLines.tbClearanceRow).Отлет;
                    }
                    dsLines.tbWallClearance.Rows.Add(rwwc);
                }

                dsLines.tbStartLine.Load(LocalService.GetLineStartPosition(orderId).Tables[0].CreateDataReader());
                dsLines.tbLineSections.Load(LocalService.GetCorniceLineSection(orderId).Tables[0].CreateDataReader());
                dsLines.tbSplintSections.Load(LocalService.GetLineSplint(orderId).Tables[0].CreateDataReader());
                dsLines.tbSide.Load(LocalService.GetCorniceSide(orderId).Tables[0].CreateDataReader());

                dsLines.AcceptChanges();
                DataRow rwv =
                    LocalService.GetCorniceView(orderId).Tables[0].Rows[0];

                btAutoSize_Click(null, null);

                tb.Selecting -= tb_Selecting;
                tb.SelectedTab = tsCurve;
                tb.Selecting += tb_Selecting;

                UpdateTVCurve();

                edStartX.Value = Convert.ToDecimal(rwv["X"]);
                edStartY.Value = Convert.ToDecimal(rwv["Y"]);
                edRotate.Value = Convert.ToDecimal(rwv["Поворот"]);
                edZoom.Value = Convert.ToDecimal(rwv["Масштаб"]);
                cbMirrow.Checked = Convert.ToBoolean(rwv["Отражение"]);
                pnWall.Invalidate();
                tvCurve.Focus();

            }
            catch
            {
                int SelectedId = 0;
                UpdateTreeView(ref SelectedId);
                pnWall.Invalidate();
            }
        }
Пример #2
0
        private void setupDGV()
        {
            dgvTM.Columns.Clear(); dgvHM.Columns.Clear();
            DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
            {
                dgvIndex.HeaderText = "Index";
                dgvIndex.DisplayIndex = 0;
                dgvIndex.Width = 45;
                dgvIndex.ReadOnly = true;
                dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgvIndex.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            DataGridViewComboBoxColumn dgvMove = new DataGridViewComboBoxColumn();
            {
                dgvMove.HeaderText = "Move";
                dgvMove.DisplayIndex = 1;
                foreach (string t in movelist)
                    dgvMove.Items.Add(t); // add only the Names

                dgvMove.Width = 133;
                dgvMove.FlatStyle = FlatStyle.Flat;
                dgvIndex.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            dgvTM.Columns.Add(dgvIndex);
            dgvTM.Columns.Add(dgvMove);
            dgvHM.Columns.Add((DataGridViewColumn)dgvIndex.Clone());
            dgvHM.Columns.Add((DataGridViewColumn)dgvMove.Clone());
        }