private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == dataGridView1.Columns["Save"].Index) { if (!Access.Instance.CanProceed(Modules.Inventory, Actions.Edit)) { return; } DataAccess.Models.Customer record = (DataAccess.Models.Customer)dataGridView1.Rows[e.RowIndex].DataBoundItem; record.CompanyId = Session.Instance.AuthUser.CompanyId; record.RegisteredDate = DateTime.Now; CustomerBS.AddCustomer(record); PopulateCustomers(); return; } if (e.ColumnIndex == dataGridView1.Columns["Delete"].Index) { if (!Access.Instance.CanProceed(Modules.Inventory, Actions.Edit)) { return; } CustomerBS.DeleteCustomer(((DataAccess.Models.Customer)dataGridView1.Rows[e.RowIndex].DataBoundItem).CustomerId); PopulateCustomers(); return; } }
private void Save(object sender, RoutedEventArgs e) { if (Validation()) { Customer c = CreateObject(); if (add == true && controller.AddCustomer(c)) { AddCustomer(c); } if (modify == true && controller.ModifyCustomer(c)) { ModifyCustomer(c); } } }