public override void Edit() { if (this.CurrentId != 0) { PersonProfession personProfession = Databases.Tables.PersonProfessions[this.CurrentId]; frmPersonProfession form = new frmPersonProfession(personProfession); form.ShowDialog(this); Init(); } }
public frmPersonProfession(PersonProfession personProfession) { InitializeComponent(); this.Text = "Изменение квалификации сотрудника."; this._PersonProfession = personProfession; this._Person = personProfession.Person; this.bProfessionCode.Text = personProfession.Profession.Code.ToString(); this.bProfessionCode.Tag = personProfession.Profession; this.tbProfessionTitle.Text = personProfession.Profession.Title; this.cbRank.Text = personProfession.Rank.ToString(); }
public override void Delete() { if (this.CurrentId != 0) { if (MessageBox.Show("Вы действительно хотите удалить запись?", "Удаление записи", MessageBoxButtons.OKCancel).Equals(DialogResult.OK)) { PersonProfession personProfession = Databases.Tables.PersonProfessions[this.CurrentId]; personProfession.Delete(); Init(); } } }
private void bSave_Click(object sender, EventArgs e) { if (Check()) { int PersonId = this._Person.Id; int ProfessionId = (this.bProfessionCode.Tag as Profession).Id; byte Rank = Convert.ToByte(cbRank.Text); PersonProfession personProfession = new PersonProfession(PersonId, ProfessionId, Rank); if (this._PersonProfession == null) { Databases.Tables.PersonProfessions.Insert(personProfession); } else { this._PersonProfession.Update(personProfession); } this.Close(); } }
private void dgvExecutors_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { DataGridView grid = (DataGridView)sender; DataGridViewColumn column = grid.Columns[e.ColumnIndex]; DataGridViewRow row = grid.Rows[e.RowIndex]; DataGridViewCell cell = grid[e.ColumnIndex, e.RowIndex]; switch (column.Name) { case "PersonCode": frmBrigadePersons fbp = new frmBrigadePersons(); fbp.CatalogMode = CatalogMode.Select; fbp.ctrlBrigadePersons.BrigadeId = this.BrigadeId; List <BrigadePerson> deletions = new List <BrigadePerson>(); List <short> deletionsCodes = new List <short>(); foreach (DataGridViewRow r in this.dgvItems.Rows) { deletionsCodes.Add(Convert.ToInt16(r.Cells["PersonCode"].Value)); } foreach (short deletionCode in deletionsCodes) { deletions.AddRange(Databases.Tables.BrigadePersons.Active.Where(r => r.Person.Code == deletionCode).AsEnumerable()); } fbp.ctrlBrigadePersons.Deletions = deletions; fbp.ShowDialog(); if (fbp.ctrlBrigadePersons.SelectedId != 0) { BrigadePerson brigadePerson = Databases.Tables.BrigadePersons[fbp.ctrlBrigadePersons.SelectedId]; DataGridViewButtonCell button = (DataGridViewButtonCell)cell; button.Value = brigadePerson.Person.Code.ToString(); button.Tag = brigadePerson.Person; row.Cells["PersonLastName"].Value = brigadePerson.Person.LastName; row.Cells["PersonFirstName"].Value = brigadePerson.Person.FirstName; row.Cells["PersonMiddleName"].Value = brigadePerson.Person.MiddleName; } break; case "ProfessionCode": if (row.Cells["PersonCode"].Value != null) { frmPersonProfessions ppf = new frmPersonProfessions(); Person p = ((DataGridViewButtonCell)row.Cells["PersonCode"]).Tag as Person; ppf.ctrlPersonProfessions.PersonId = p.Id; ppf.ShowDialog(); if (ppf.SelectedId != 0) { PersonProfession pp = Databases.Tables.PersonProfessions[ppf.SelectedId]; DataGridViewButtonCell b = (DataGridViewButtonCell)cell; b.Tag = pp; b.Value = pp.Profession.Code.ToString(); grid.CurrentCell = row.Cells["Rank"]; grid.BeginEdit(true); DataGridViewTextBoxEditingControl rankControl = (DataGridViewTextBoxEditingControl)grid.EditingControl; rankControl.Text = pp.Rank.ToString(); grid.EndEdit(); } } break; default: break; } } }