Ejemplo n.º 1
0
        /// <summary>
        /// Редактировать выбранный фиттинг.
        /// </summary>
        private void EditFittingOfProject()
        {
            object idProject     = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
            object idAccessories = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "Id");
            object fittingCount  = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "FittingCount");
            object fittingId     = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "FittingID");

            if (idAccessories == null)
            {
                return;
            }

            FittingCard fittingCard = new FittingCard(
                int.Parse(idProject.ToString()),
                int.Parse(idAccessories.ToString()),
                int.Parse(fittingId.ToString()),
                double.Parse(fittingCount.ToString()),
                true);

            fittingCard.Owner = this;
            fittingCard.ShowDialog();

            if (fittingCard.DialogResult == DialogResult.OK)
            {
                //int oldIndex = gridView2.FocusedRowHandle; // Индекс до обновления.
                LoadFittings(idProject);
                //gridView2.FocusedRowHandle = oldIndex;

                //int idNewProject = projectCard.IdAddedProject;
                for (int i = 0; i < gridView2.DataRowCount; i++)
                {
                    object b = gridView2.GetRowCellValue(i, "Id");
                    if (b != null && b.Equals(idAccessories))
                    {
                        gridView2.FocusedRowHandle = i;
                        continue;
                    }
                }

                // Обновляем строку с проектом.
                DataTable dt = new SqlMethods().LoadProjects(String.Format("exec ShowTheOneProjects {0}", idProject));
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "FittingSum", dt.Rows[0]["FittingSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TransportSum", dt.Rows[0]["TransportSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "LaborIntencity", dt.Rows[0]["LaborIntencity"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "UnexpectedExpenses", dt.Rows[0]["UnexpectedExpenses"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TotalSum", dt.Rows[0]["TotalSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TotalSumWithPercent2", dt.Rows[0]["TotalSumWithPercent2"]);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Добавление фиттинга к проекту.
        /// </summary>
        private void AddFitting()
        {
            object idProject = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");

            FittingCard fittingCard = new FittingCard()
            {
                ProjectID = int.Parse(idProject.ToString())
            };

            fittingCard.Owner = this;
            fittingCard.ShowDialog();

            if (fittingCard.DialogResult == DialogResult.OK)
            {
                LoadFittings(idProject);

                // Обновляем строку с проектом.
                DataTable dt = new SqlMethods().LoadProjects(String.Format("exec ShowTheOneProjects {0}", idProject));
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "FittingSum", dt.Rows[0]["FittingSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TransportSum", dt.Rows[0]["TransportSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "LaborIntencity", dt.Rows[0]["LaborIntencity"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "UnexpectedExpenses", dt.Rows[0]["UnexpectedExpenses"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TotalSum", dt.Rows[0]["TotalSum"]);
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "TotalSumWithPercent2", dt.Rows[0]["TotalSumWithPercent2"]);

                // Выделяем строку с новым фиттингом.
                int idNewFitting = fittingCard.IdAddedAccessories;
                for (int i = 0; i < gridView2.DataRowCount; i++)
                {
                    object b = gridView2.GetRowCellValue(i, "Id");
                    if (b != null && b.Equals(idNewFitting))
                    {
                        gridView2.FocusedRowHandle = i;
                        return;
                    }
                }
            }
        }