Пример #1
0
        private static int AddData(object [,] info)
        {
            int count = 0;

            try
            {
                for (int i = 1; i <= info.GetLength(0); i++)
                {
                    if (info[i, 2] == null)
                    {
                        info[i, 2] = string.Empty;
                    }
                    string[] ascriptors = info[i, 8].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    bool     b          = info[i, 4] is double;
                    double[] ints       = new double[] { (double)info[i, 4], (double)info[i, 5], (double)info[i, 6], (double)info[i, 7],
                                                         (double)info[i, 10], (double)info[i, 11], (double)info[i, 12], (double)info[i, 13], };
                    DBQueries   db = new DBQueries();
                    ReturnState rs = db.AddDescriptor(info[i, 1].ToString(),
                                                      (int)ints[0], (int)ints[1], (int)ints[2], (int)ints[3],
                                                      info[i, 9].ToString(),
                                                      (int)ints[4], (int)ints[5], (int)ints[6], (int)ints[7], ascriptors,
                                                      info[i, 2].ToString());
                    if (rs == ReturnState.Success)
                    {
                        count++;
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
            return(count);
        }
Пример #2
0
        private void Add()
        {
            DBQueries   db = new DBQueries();
            ReturnState rs = db.AddDescriptor(descriptorBox.Text,
                                              Int32.Parse(startLineD.Text), Int32.Parse(StartCharD.Text), Int32.Parse(EndLineD.Text), Int32.Parse(EndCharD.Text),
                                              DefinitionBox.Text,
                                              Int32.Parse(StartLineBox.Text), Int32.Parse(StartCharBox.Text), Int32.Parse(EndLineBox.Text), Int32.Parse(EndCharBox.Text),
                                              RelatorBox.Text);

            if (rs == ReturnState.Success)
            {
                MessageBox.Show("Определение изменено!");
            }
            else if (rs == ReturnState.UniqueConstraintError)
            {
                MessageBox.Show("Такое определение уже существует в базе данных");
            }
            else
            {
                MessageBox.Show("Ошибка подключения к базе данных");
            }
        }