private void btnNew_Click(object sender, EventArgs e) { _Item = null; cbActive.Checked = true; cbExpires.Checked = true; numExpiry.Value = 12; GotoEditable(); }
private void dgItems_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { _Item = senderGrid.Rows[e.RowIndex].DataBoundItem as CustomerDocumentType; if (_Item != null) { EditItem(); } } }
protected override async Task Handle(CustomerIdTypeCommand command) { FIL.Contracts.DataModels.CustomerDocumentType customerDocumentType = new CustomerDocumentType(); try { customerDocumentType.DocumentType = command.CustomerIdType; customerDocumentType.IsEnabled = false; customerDocumentType.CreatedUtc = DateTime.UtcNow; _customerDocumentTypeRepository.Save(customerDocumentType); } catch (Exception e) { } }
private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txDocumentType.Text)) { Controller.HandleError("Name is required", "Validation Error"); return; } if (_Item == null) { _Item = new CustomerDocumentType(); _Context.CustomerDocumentTypeSet.Add(_Item); } _Item.Name = txDocumentType.Text; _Item.IsActive = cbActive.Checked; _Item.SetExpiry = cbExpires.Checked; _Item.DefaultExpiryMonths = Convert.ToInt32(numExpiry.Value); try { bool isNew = _Item.id == 0; _Context.SaveChanges(); if (isNew) { _Data.Insert(0, _Item); } BindDataGrid(); GotoReadOnly(); } catch (DbUpdateException) { Controller.HandleError("Possible duplicate record detected", "Database Error"); } catch (Exception ex2) { Controller.HandleError(ex2.Message); } }