public void Edit(Database.tblContact contact) { if (contact == null) { return; } dataContext = new Database.ContactDataContext(modulData.SqlConnection); tlkpContactPrefixBindingSource.DataSource = dataContext.tlkpContactPrefix; tlkpContactCommunicationTypeBindingSource.DataSource = dataContext.tlkpContactCommunicationType; tlkpCityBindingSource.DataSource = dataContext.tlkpCity; tlkpFederalStateBindingSource.DataSource = dataContext.tlkpFederalState; tlkpCountryBindingSource.DataSource = dataContext.tlkpCountry; tlkpContactCommunicationCategoryBindingSource.DataSource = dataContext.tlkpContactCommunicationCategory; tblContactBindingSource.DataSource = from row in dataContext.tblContact where row.PKContact == contact.PKContact select row; tblContactCommunicationBindingSource.DataSource = dataContext.tblContactCommunication; LoadImageComboBoxItems(); gridView1.BestFitColumns(true); tblContactBindingSource.MoveFirst(); }
private void btnContactDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { Database.tblContact c = (Database.tblContact)tblContactBindingSource.Current; if (c != null) { dataContext.tblContact.DeleteOnSubmit(c); dataContext.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict); } } catch (SqlException exception) { if (exception.Number == 547) { DevExpress.XtraEditors.XtraMessageBox.Show("Datensatz wird noch von anderer Stelle referenziert und kann daher nicht gelöscht werden.", "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DevExpress.XtraEditors.XtraMessageBox.Show(exception.ToString(), "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } finally { LoadData(); } }
private void pictureEdit1_EditValueChanged(object sender, EventArgs e) { if (((PictureEdit)sender).EditValue is Image) { Database.tblContact c = (Database.tblContact)tblContactBindingSource.Current; c.Picture = Wookie.Tools.Image.Converter.GetBinaryFromImage(((PictureEdit)sender).EditValue as Image); } }
/// <summary> /// Adds a new contact to the datasource. /// </summary> private void AddContact() { this.ucDefault1.PostEditor(); Database.tblContact contact = new Database.tblContact(); contact.FKContactData = this.modulData.FKExternal; int datasourceindex = this.tblContactBindingSource.Add(contact); gridView2.FocusedRowHandle = gridView2.GetRowHandle(datasourceindex); }
private void EditContact() { Database.tblContact c = (Database.tblContact)tblContactBindingSource.Current; if (c == null) { return; } navigationFrame1.SelectedPage = navEdit; ucContactEdit.Edit(c); }
public void New() { dataContext = new Database.ContactDataContext(modulData.SqlConnection); tlkpContactPrefixBindingSource.DataSource = dataContext.tlkpContactPrefix; tlkpContactCommunicationTypeBindingSource.DataSource = dataContext.tlkpContactCommunicationType; tblContactCommunicationBindingSource.DataSource = dataContext.tblContactCommunication; tlkpCityBindingSource.DataSource = dataContext.tlkpCity; tlkpFederalStateBindingSource.DataSource = dataContext.tlkpFederalState; tlkpCountryBindingSource.DataSource = dataContext.tlkpCountry; LoadImageComboBoxItems(); Database.tblContact c = new Database.tblContact(); c.FKContactData = modulData.FKExternal; tblContactBindingSource.DataSource = c; dataContext.tblContact.InsertOnSubmit(c); gridView1.BestFitColumns(true); tblContactBindingSource.MoveFirst(); }
private void RefreshDataOnScreen() { Database.tblContact c = (Database.tblContact)tblContactBindingSource.Current; if (c != null) { if (this.gridView1.GetSelectedRows().Count() > 0) { this.gridView1.RefreshRow(this.gridView1.GetSelectedRows()[0]); } this.lblName.Text = ((string)(c.Surname + " " + c.Middlename)).Trim() + " " + c.Name; this.lblTitel.Text = ((string)(c.Title)); tblContactCommunicationBindingSource.DataSource = c; gridView2.BestFitColumns(true); } else { this.lblName.Text = "Name"; this.lblTitel.Text = "Title"; tblContactCommunicationBindingSource.DataSource = null; } }