Пример #1
0
        private void ShowWaggonTypeEditDialog(int rowIndex)
        {
            if (rowIndex < 0)
            {
                return;
            }
            var n = 0;

            foreach (var wagtype in TypeDataKeeper.GetWaggonTypeItems().OrderBy(item => int.Parse(item.NType)))
            {
                if (n == rowIndex)
                {
                    using (var frm = new FormWaggonTypeDataEditor(true,
                                                                  wagtype.NType, wagtype.Diameter, wagtype.Throat,
                                                                  wagtype.Deflevel))
                    {
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            var resultwagtype = frm.GetValue;
                            if (resultwagtype != null)
                            {
                                TypeDataKeeper.Edit(resultwagtype.NType, resultwagtype.Diameter, resultwagtype.Throat,
                                                    resultwagtype.Deflevel);
                                var index = TypeDataKeeper.FindIndex(resultwagtype.NType);
                                UpdateWaggonTypesList(index);
                            }
                        }
                    }
                    break;
                }
                n++;
            }
        }
Пример #2
0
        private void ShowWaggonTypeDeleteDialog()
        {
            if (_rowIndex < 0)
            {
                return;
            }
            var ntype = TypeDataKeeper.GetWaggonType(_rowIndex);

            if (ntype == null || MessageBox.Show(@"Удалить запись о типе цистерны " + ntype + @" ?",
                                                 @"Подтверждение удаления", MessageBoxButtons.OKCancel,
                                                 MessageBoxIcon.Warning,
                                                 MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }
            TypeDataKeeper.Delete(ntype);
            UpdateWaggonTypesList();
        }
Пример #3
0
 private void ShowWaggonTypeInsertDialog()
 {
     using (var frm = new FormWaggonTypeDataEditor(false,
                                                   "", 0, 0, 0))
     {
         if (frm.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         var resultwagtype = frm.GetValue;
         if (resultwagtype == null)
         {
             return;
         }
         TypeDataKeeper.Add(resultwagtype.NType, resultwagtype.Diameter, resultwagtype.Throat,
                            resultwagtype.Deflevel);
         var index = TypeDataKeeper.FindIndex(resultwagtype.NType);
         UpdateWaggonTypesList(index);
     }
 }
Пример #4
0
        private void UpdateWaggonTypesList(int rowindex = -1)
        {
            var table = new DataTable();

            table.Columns.Add(new DataColumn("Тип"));
            table.Columns.Add(new DataColumn("Диаметр"));
            table.Columns.Add(new DataColumn("Высота горловины"));
            table.Columns.Add(new DataColumn("Взлив по умолчанию"));
            foreach (var wagtype in TypeDataKeeper.GetWaggonTypeItems().OrderBy(item => int.Parse(item.NType)))
            {
                table.Rows.Add(wagtype.NType, wagtype.Diameter, wagtype.Throat, wagtype.Deflevel);
            }
            dataGridView1.DataSource = table;

            if (rowindex >= 0 && dataGridView1.Rows.Count > 0 && rowindex < dataGridView1.Rows.Count)
            {
                dataGridView1.CurrentCell = dataGridView1[0, rowindex];
            }
            btnChangeType.Enabled = dataGridView1.Rows.Count > 0 && _rowIndex >= 0;
            btnDeleteType.Enabled = dataGridView1.Rows.Count > 0 && _rowIndex >= 0;
        }