Beispiel #1
0
        /// <summary>
        /// Редактируем трубку
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.SelectedRows != null)
                {
                    if (dataGridView1.SelectedRows.Count > 0)
                    {
                        DataGridViewRow selected = dataGridView1.SelectedRows[0];
                        if (selected != null && selected.Tag != null)
                        {
                            tubeInfo sel_tube = selected.Tag as tubeInfo;
                            if (sel_tube != null)
                            {
                                int sel_index = selected.Index;
                                if (sel_index > -1 && sel_index < dataGridView1.Rows.Count)
                                {
                                    if (sel_index == 0)
                                    {
                                        // -------- редактируем выбранную трубку

                                        DrillingShaftTubeForm frm = new DrillingShaftTubeForm();

                                        frm.textBoxLenght.Text = selected.Cells[1].Value.ToString();
                                        frm.textBoxNumber.Text = selected.Cells[2].Value.ToString();

                                        frm.textBoxComment.Text = selected.Cells[3].Value.ToString();

                                        if (frm.ShowDialog(this) == DialogResult.OK)
                                        {
                                            selected.Cells[1].Value = frm.textBoxLenght.Text;
                                            selected.Cells[2].Value = frm.textBoxNumber.Text;
                                            selected.Cells[3].Value = frm.textBoxComment.Text;
                                            selected.Cells[4].Value = frm.textBoxLenght.Text;

                                            calc_data_grid();
                                        }
                                    }
                                    else
                                    {
                                        int f_index = sel_index - 1;
                                        DataGridViewRow f_row = dataGridView1.Rows[f_index];

                                        if (f_row != null)
                                        {
                                            float len = SgtApplication.ParseSingle(f_row.Cells[1].Value.ToString());
                                            if (len <= 0)
                                            {
                                                MessageBox.Show(this, "Текущую трубку нельзя редактировать, потому что не определенна предыдущая трубка", "Сообщение",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                            }
                                            else
                                            {
                                                // -------- редактируем выбранную трубку

                                                DrillingShaftTubeForm frm = new DrillingShaftTubeForm();

                                                frm.textBoxLenght.Text = selected.Cells[1].Value.ToString();

                                                if (sel_tube.Lenght <= 0)
                                                {
                                                    frm.textBoxNumber.Text = f_row.Cells[2].Value.ToString();
                                                }
                                                else
                                                    frm.textBoxNumber.Text = selected.Cells[2].Value.ToString();

                                                frm.textBoxComment.Text = selected.Cells[3].Value.ToString();

                                                if (frm.ShowDialog(this) == DialogResult.OK)
                                                {
                                                    selected.Cells[1].Value = frm.textBoxLenght.Text;
                                                    selected.Cells[2].Value = frm.textBoxNumber.Text;
                                                    selected.Cells[3].Value = frm.textBoxComment.Text;

                                                    calc_data_grid();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Редактируем трубку
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.SelectedRows != null)
                {
                    if (dataGridView1.SelectedRows.Count > 0)
                    {
                        DataGridViewRow selected = dataGridView1.SelectedRows[0];
                        if (selected != null && selected.Tag != null)
                        {
                            tubeInfo sel_tube = selected.Tag as tubeInfo;
                            if (sel_tube != null)
                            {
                                int sel_index = selected.Index;
                                if (sel_index > -1 && sel_index < dataGridView1.Rows.Count)
                                {
                                    if (sel_index == 0)
                                    {
                                        // -------- редактируем выбранную трубку

                                        DrillingShaftTubeForm frm = new DrillingShaftTubeForm();

                                        frm.textBoxLenght.Text = selected.Cells[1].Value.ToString();
                                        frm.textBoxNumber.Text = selected.Cells[2].Value.ToString();

                                        frm.textBoxComment.Text = selected.Cells[3].Value.ToString();

                                        if (frm.ShowDialog(this) == DialogResult.OK)
                                        {
                                            selected.Cells[1].Value = frm.textBoxLenght.Text;
                                            selected.Cells[2].Value = frm.textBoxNumber.Text;
                                            selected.Cells[3].Value = frm.textBoxComment.Text;
                                            selected.Cells[4].Value = frm.textBoxLenght.Text;

                                            calc_data_grid();
                                        }
                                    }
                                    else
                                    {
                                        int             f_index = sel_index - 1;
                                        DataGridViewRow f_row   = dataGridView1.Rows[f_index];

                                        if (f_row != null)
                                        {
                                            float len = SgtApplication.ParseSingle(f_row.Cells[1].Value.ToString());
                                            if (len <= 0)
                                            {
                                                MessageBox.Show(this, "Текущую трубку нельзя редактировать, потому что не определенна предыдущая трубка", "Сообщение",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                            }
                                            else
                                            {
                                                // -------- редактируем выбранную трубку

                                                DrillingShaftTubeForm frm = new DrillingShaftTubeForm();

                                                frm.textBoxLenght.Text = selected.Cells[1].Value.ToString();

                                                if (sel_tube.Lenght <= 0)
                                                {
                                                    frm.textBoxNumber.Text = f_row.Cells[2].Value.ToString();
                                                }
                                                else
                                                {
                                                    frm.textBoxNumber.Text = selected.Cells[2].Value.ToString();
                                                }

                                                frm.textBoxComment.Text = selected.Cells[3].Value.ToString();

                                                if (frm.ShowDialog(this) == DialogResult.OK)
                                                {
                                                    selected.Cells[1].Value = frm.textBoxLenght.Text;
                                                    selected.Cells[2].Value = frm.textBoxNumber.Text;
                                                    selected.Cells[3].Value = frm.textBoxComment.Text;

                                                    calc_data_grid();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }