public TFlexSpecSectionTypeDialog(SEPO_TFLEX_SECTION_TYPES type) : this(new Repository <SEPO_TFLEX_SECTION_TYPES>()) { dialogType = DialogType.Edit; TFlexSectionType = type; TFlexSpecSection = type.ID_SECTION; signBox.SelectedItem = type.SIGN; nameBox.Text = type.NAME; }
private DataGridViewRow AddTypeRow(SEPO_TFLEX_SECTION_TYPES item) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(typesScene, item.SIGN, item.NAME); row.Tag = item.ID; typesScene.Rows.Add(row); return(row); }
private void OkButton_Click(object sender, EventArgs e) { if (dialogType == DialogType.Add) { SEPO_TFLEX_SECTION_TYPES type = new SEPO_TFLEX_SECTION_TYPES { ID_SECTION = TFlexSpecSection, SIGN = (int)signBox.SelectedValue, NAME = nameBox.Text }; using (UnitOfWork transaction = new UnitOfWork()) { try { typesRepo.Create(type); transaction.Commit(); TFlexSectionType = type; DialogResult = DialogResult.OK; } catch (Exception) { transaction.Rollback(); throw; } } } else { TFlexSectionType.SIGN = (int)signBox.SelectedValue; TFlexSectionType.NAME = nameBox.Text; using (UnitOfWork transaction = new UnitOfWork()) { try { typesRepo.Update(TFlexSectionType); transaction.Commit(); DialogResult = DialogResult.OK; } catch (Exception) { transaction.Rollback(); throw; } } } }
protected void OnEditSectionTypeClick(object sender, EventArgs e) { DataGridViewRow row = typesScene.SelectedRows[0]; int id = (int)row.Tag; SEPO_TFLEX_SECTION_TYPES type = sectionTypesRepo.GetById(id); TFlexSpecSectionTypeDialog dialog = new TFlexSpecSectionTypeDialog(type); if (dialog.ShowDialog() == DialogResult.OK) { UpdateTypeRow(row, type); } }
protected void OnDeleteSectionTypeClick(object sender, EventArgs e) { DataGridViewRow row = typesScene.SelectedRows[0]; int id = (int)row.Tag; using (UnitOfWork transaction = new UnitOfWork()) { SEPO_TFLEX_SECTION_TYPES type = sectionTypesRepo.GetById(id); try { sectionTypesRepo.Delete(type); transaction.Commit(); typesScene.Rows.Remove(row); } catch (Exception) { transaction.Rollback(); throw; } } }
private void UpdateTypeRow(DataGridViewRow row, SEPO_TFLEX_SECTION_TYPES item) { row.Cells[0].Value = item.SIGN; row.Cells[1].Value = item.NAME; }