コード例 #1
0
        private void ShowWaggonEditDialog(int rowIndex)
        {
            if (rowIndex < 0)
            {
                return;
            }
            int factlevel;
            var number = dataGridView1[0, _rowIndex].Value.ToString();
            var ntype  = dataGridView1[1, _rowIndex].Value.ToString();

            int.TryParse(dataGridView1[2, _rowIndex].Value.ToString(), out factlevel);
            using (var frm = new FormWaggonDataEditor(true, number, ntype, factlevel))
            {
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                var resultwag = frm.GetValue;
                if (resultwag == null)
                {
                    return;
                }
                if (!WaggonDataKeeper.Edit(resultwag.Number, resultwag.Ntype, resultwag.FactHeight))
                {
                    return;
                }
                UpdateWaggonsList(_rowIndex);
            }
        }
コード例 #2
0
 private void ShowWaggonInsertDialog()
 {
     using (var frm = new FormWaggonDataEditor(false, "", "", 0))
     {
         if (frm.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         var resultwag = frm.GetValue;
         if (resultwag == null)
         {
             return;
         }
         var index = WaggonDataKeeper.Find(resultwag.Number);
         if (index >= 0)
         {
             MessageBox.Show(this, @"Вагон с номером " + resultwag.Number + @" уже существует!",
                             @"Новый вагон", MessageBoxButtons.OK, MessageBoxIcon.Error);
             vScrollBar1.Value = index;
             UpdateWaggonsList(0);
             return;
         }
         if (!WaggonDataKeeper.Add(resultwag.Number, resultwag.Ntype, resultwag.FactHeight))
         {
             return;
         }
         var count = WaggonDataKeeper.Count();
         vScrollBar1.Maximum = count > 0 ? count - 1 : 0;
         index = WaggonDataKeeper.Find(resultwag.Number);
         if (index < 0)
         {
             return;
         }
         vScrollBar1.Value = index;
         UpdateWaggonsList(0);
     }
 }