예제 #1
0
        void edit_element()
        {
            arxDs.ds = dataSet1;

            if (dataGridView1.CurrentRow == null) return;

            Class_element.InOut = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            Class_element.Category = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            Class_element.Date = DateTime.ParseExact(dataGridView1.CurrentRow.Cells[2].Value.ToString(), "dd.MM.yyyy H:mm:ss", CultureInfo.CreateSpecificCulture("ru-RU"));
            Class_element.Sum = Convert.ToDouble(dataGridView1.CurrentRow.Cells[3].Value);
            Class_element.Comment = dataGridView1.CurrentRow.Cells[4].Value.ToString();

            using (var addEdit = new Form_AddEdit("Редактирование элемента"))
            {
                addEdit.ShowDialog();

                if (addEdit.DialogResult == DialogResult.OK)
                {
                    var editRow = ((DataRowView)dataGridView1.CurrentRow.DataBoundItem).Row;

                    editRow["InOut"] = Class_element.InOut;
                    editRow["Category"] = Class_element.Category;
                    editRow["DateTime"] = Class_element.Date;
                    editRow["Sum"] = Class_element.Sum;
                    editRow["Comment"] = Class_element.Comment;
                }

                saveData();
            }
        }
예제 #2
0
        void add_element()
        {
            arxDs.ds = dataSet1;

            using (var addEdit = new Form_AddEdit("Новый элемент"))
            {
                addEdit.ShowDialog();

                if (addEdit.DialogResult == DialogResult.OK)
                {
                    dataSet1.Tables["CashInOut"].Rows.Add(Class_element.InOut, Class_element.Category, Class_element.Date,
                        Class_element.Sum, Class_element.Comment);
                }

                saveData();
            }
        }