public TFlexSpecSectionTypeDialog(SEPO_TFLEX_SPEC_SECTIONS section) : this(new Repository <SEPO_TFLEX_SECTION_TYPES>()) { dialogType = DialogType.Add; TFlexSpecSection = section; }
public TFlexSpecSectionDialog(SEPO_TFLEX_SPEC_SECTIONS section) : this(new Repository <SEPO_TFLEX_SPEC_SECTIONS>()) { dialogType = DialogType.Edit; TFlexSpecSection = section; sectionBox.Text = section.SECTION_; }
private DataGridViewRow AddRow(SEPO_TFLEX_SPEC_SECTIONS item) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(scene, item.SECTION_); row.Tag = item.ID; scene.Rows.Add(row); return(row); }
protected void OnEditItemClick(object sender, EventArgs e) { DataGridViewRow row = scene.SelectedRows[0]; int id = (int)row.Tag; SEPO_TFLEX_SPEC_SECTIONS section = sectionsRepo.GetById(id); TFlexSpecSectionDialog dialog = new TFlexSpecSectionDialog(section); if (dialog.ShowDialog() == DialogResult.OK) { UpdateRow(row, section); } }
private void OkButton_Click(object sender, EventArgs e) { if (dialogType == DialogType.Add) { SEPO_TFLEX_SPEC_SECTIONS section = new SEPO_TFLEX_SPEC_SECTIONS { SECTION_ = sectionBox.Text }; using (UnitOfWork transaction = new UnitOfWork()) { try { sectionsRepo.Create(section); transaction.Commit(); TFlexSpecSection = section; DialogResult = DialogResult.OK; } catch (Exception) { transaction.Rollback(); throw; } } } else { TFlexSpecSection.SECTION_ = sectionBox.Text; using (UnitOfWork transaction = new UnitOfWork()) { try { sectionsRepo.Update(TFlexSpecSection); transaction.Commit(); DialogResult = DialogResult.OK; } catch (Exception) { transaction.Rollback(); throw; } } } }
protected void OnAddSectionTypeClick(object sender, EventArgs e) { int id_section = (int)scene.SelectedRows[0].Tag; SEPO_TFLEX_SPEC_SECTIONS section = sectionsRepo.GetQuery() .Where(x => x.ID == id_section) .FirstOrDefault(); TFlexSpecSectionTypeDialog dialog = new TFlexSpecSectionTypeDialog(section); if (dialog.ShowDialog() == DialogResult.OK) { AddTypeRow(dialog.TFlexSectionType); } }
private void OnTFlexSectionChanged(object sender, EventArgs e) { if (sectionBox.SelectedValue == null) { return; } SEPO_TFLEX_SPEC_SECTIONS section = _repoSections.GetById((int)sectionBox.SelectedValue); typeObjBox.DisplayMember = "NAME"; typeObjBox.ValueMember = "ID"; var list = _repoSectionTypes.GetQuery() .Where(x => x.ID_SECTION == section) .Select(x => new { ID = x.ID, NAME = x.NAME }) .ToList(); list.Add(new { ID = 0, NAME = string.Empty }); typeObjBox.DataSource = list; }
protected void OnDeleteItemClick(object sender, EventArgs e) { DataGridViewRow row = scene.SelectedRows[0]; int id = (int)row.Tag; using (UnitOfWork transaction = new UnitOfWork()) { SEPO_TFLEX_SPEC_SECTIONS section = sectionsRepo.GetById(id); try { sectionsRepo.Delete(section); transaction.Commit(); scene.Rows.Remove(row); } catch (Exception) { transaction.Rollback(); throw; } } }
private void UpdateRow(DataGridViewRow row, SEPO_TFLEX_SPEC_SECTIONS item) { row.Cells[0].Value = item.SECTION_; }