public void addAccountBtn_Click(object sender, EventArgs e) { _view = (ChartofAccountsForm)((Button)sender).FindForm(); int row = _view.Grid().Rows.Count; if (!System.Text.RegularExpressions.Regex.IsMatch(_view.Name, "^[a-zA-Z0-9]")) { _view.showErrorMessage("Invalid group name"); } else { var parentGroup = systemModel.Groups.Find(Convert.ToInt32(_view.getGroupID())); MasterAccount account = new MasterAccount(); account.name = _view.getMasterAccountName(); account.openingAmount = _view.openingAmount; account.closingAmount = 0; account.Group = parentGroup; systemModel.MasterAccounts.Add(account); systemModel.SaveChanges(); _view.addRow(row, account.ID, account.name, (double)account.openingAmount, (double)account.closingAmount, parentGroup.ID); } }
public void changNameItem_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection theRow = _view.Grid().SelectedRows; int count = theRow.Count; if (count == 0) { _view.showErrorMessage("No rows selected"); } else { _view = (ChartofAccountsForm)((ContextMenuStrip)(((ToolStripMenuItem)sender).Owner)).SourceControl.FindForm(); _view.Grid().CurrentCell = theRow[0].Cells["name"]; _view.Grid().BeginEdit(true); } }
public void removeAccountToolStripMenuItem_Click(object sender, EventArgs e) { _view = (ChartofAccountsForm)((ContextMenuStrip)(((ToolStripMenuItem)sender).Owner)).SourceControl.FindForm(); DataGridViewSelectedRowCollection theRow = _view.Grid().SelectedRows; int count = theRow.Count; if (count == 0) { _view.showErrorMessage("No rows selected"); } else { var theAccount = systemModel.MasterAccounts.Find(Convert.ToInt32(theRow[0].Cells["acNo"].Value)); systemModel.MasterAccounts.Remove(theAccount); systemModel.SaveChanges(); _view.removeRow(theRow); } }