private void UpdateData() { int nowRow = dgv.CurrentRow.Index; DateTime oldDate = DateTime.Parse(dgv.Rows[nowRow].Cells[0].Value.ToString()); string oldCategory = dgv.Rows[nowRow].Cells[1].Value.ToString(); string oldItem = dgv.Rows[nowRow].Cells[2].Value.ToString(); int oldMoney = int.Parse(dgv.Rows[nowRow].Cells[3].Value.ToString()); string oldRemarks = dgv.Rows[nowRow].Cells[4].Value.ToString(); ItemForm frmItem = new ItemForm(categoryDataSet1, oldDate, oldCategory, oldItem, oldMoney, oldRemarks); DialogResult drRet = frmItem.ShowDialog(); if (drRet == DialogResult.OK) { dgv.Rows[nowRow].Cells[0].Value = frmItem.monthCalendar.SelectionRange.Start; dgv.Rows[nowRow].Cells[1].Value = frmItem.cmbCategory.Text; dgv.Rows[nowRow].Cells[2].Value = frmItem.txtItem.Text; dgv.Rows[nowRow].Cells[3].Value = int.Parse(frmItem.mtxtMoney.Text); dgv.Rows[nowRow].Cells[4].Value = frmItem.txtRemarks.Text; } }
private void AddData() { ItemForm frmItem = new ItemForm(categoryDataSet1); DialogResult drRet = frmItem.ShowDialog(); if (drRet == DialogResult.OK) { moneyDataSet.moneyDateTable.AddmoneyDateTableRow( frmItem.monthCalendar.SelectionRange.Start, frmItem.cmbCategory.Text, frmItem.txtItem.Text, int.Parse(frmItem.mtxtMoney.Text), frmItem.txtRemarks.Text); } }