Beispiel #1
0
        public void doInsert()
        {
            Field        field;
            List <Field> fields = new List <Field>();

            for (int i = 0; i < dataGridView.ColumnCount; i++)
            {
                field = new Field(dataGridView.Columns[i].Name, "");
                fields.Add(field);
            }

            if (fields.Count > 0)
            {
                Form         w            = new WindowFields("¬вед≥ть новий запис", fields.ToArray());
                DialogResult dialogResult = w.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    Console.Error.WriteLine("doIns: к≥льк≥сть пол≥в: '{0}' ", fields.Count);
                    statStrip.Items[0].Text = string.Format("¬ставити п≥сл¤ {0} запису", dataGridView.CurrentRow.Index);
                    string[] fs = new string[fields.Count];

                    for (int j = 0; j < fields.Count; j++)
                    {
                        fs[j] = fields[j].value;
                    }

                    dataGridView.Rows.Insert(dataGridView.CurrentRow.Index, fs);
                }
            }
            else
            {
                statStrip.Items[1].Text = string.Format("Ќ≥чого вставл¤ти!");
            }
        }
Beispiel #2
0
        public void doEdit()
        {
            string answer = "";

            if (dataGridView.RowCount > 0)
            {
                DataGridViewRow            dataGridViewRow = dataGridView.Rows[dataGridView.CurrentRow.Index];
                DataGridViewCellCollection row             = dataGridViewRow.Cells;

                List <Field> fields = new List <Field>();
                Field        field;

                for (int i = 0; i < dataGridView.ColumnCount; i++)
                {
                    field = new Field(dataGridView.Columns[i].Name, (row[i]).Value.ToString());
                    fields.Add(field);
                }

                if (fields.Count > 0)
                {
                    WindowFields w = new WindowFields("«м≥нити вибраний запис", fields.ToArray());

                    DialogResult rc = w.ShowDialog();

                    if (rc == DialogResult.OK)
                    {
                        for (int i = 0; i < fields.Count; i++)
                        {
                            dataGridViewRow.Cells[i].Value = fields[i].value;
                        }
                    }
                }
            }
            else
            {
                answer = "Ќ≥чого зм≥нювати!";
            }

            Console.WriteLine("«м≥нено: '{0}'", answer);
            statStrip.Items[0].Text = answer;
        }