//--Edit Relative private void RelativesLV_DoubleClick(object sender, EventArgs e) { var item = _lviews[0].SelectedItems[0]; sqlmgr.Reconnect(); view_data = sqlmgr.GetRelativesTypes(); var ptypes = sqlmgr.GetPhonesTypes(); sqlmgr.Disconnect(); AddEditRelativeForm aerf = new AddEditRelativeForm(_conn_str); aerf.SetCaption("Редактирование объекта"); aerf.SetRelativesTypesDS(view_data, "Name"); aerf.SetPhonesTypesDS(ptypes, "Name"); aerf.SetItemForEditing(item.Tag); var dr = aerf.ShowDialog(); if (dr == DialogResult.OK) { Relative rel = (aerf.EditableItem as Relative); var selitem = (_lviews[0].SelectedItems[0]); (selitem.Tag as Relative).Name = rel.Name; (selitem.Tag as Relative).Phone = rel.Phone; (selitem.Tag as Relative).RelativeType = rel.RelativeType; (selitem.Tag as Relative).PhoneType = rel.PhoneType; (selitem.Tag as Relative).Zakazchik = rel.Zakazchik; _lviews[0].RefreshDataSource(); sqlmgr.Reconnect(); sqlmgr.UpdateRelative(rel); sqlmgr.Disconnect(); } }
private void AddRelativeClick(object sender, EventArgs e) { sqlmgr.Reconnect(); view_data = sqlmgr.GetRelativesTypes(); var ptypes = sqlmgr.GetPhonesTypes(); sqlmgr.Disconnect(); AddEditRelativeForm aerf = new AddEditRelativeForm(_conn_str); aerf.SetRelativesTypesDS(view_data,"Name"); aerf.SetPhonesTypesDS(ptypes, "Name"); aerf.CreateNewItem(); //aerf.FormState = anvlib.Enums.AddEditFormState.Add; var dr = aerf.ShowDialog(); if (dr == DialogResult.OK) { Relative rel = (aerf.EditableItem as Relative); sqlmgr.Reconnect(); sqlmgr.AddRelative(_card_id, rel); sqlmgr.Disconnect(); (_lviews[0].DataSource as Relatives).Add(rel); _lviews[0].RefreshDataSource(); } }