private void ImportClick(object sender, EventArgs e) { try { if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string file = this.openFileDialog1.FileName; string error = string.Empty; ReadOnlyCollection <PropertyInfo> collection = new ContactDO().GetOrderedProperties(); DataTable data = ExcelHelper.Import(file, collection, ref error); this.ShowErrorIfNotEmpty(error); error = string.Empty; List <ContactDO> contacts = DomainObjectHelper.GetDomainObjectFromDataTable <ContactDO>(data, ref error); this.ShowErrorIfNotEmpty(error); foreach (ContactDO record in contacts) { error = string.Empty; DataBaseHelper.Insert(Program.ConnectionString, ContactDO.TableName, record, ref error); this.ShowErrorIfNotEmpty(error); } this.ReloadContacts(); } } catch (Exception ex) { MessageBox.Show("Error while trying to import data: " + ex.Message); } }
public ContactControl(ContactDO record, NslDbForm parentForm) { this.InitializeComponent(); this.record = record; this.parentForm = parentForm; }
public ContactDetailView(ContactDO record = null) { this.InitializeComponent(); this.record = record ?? new ContactDO(); }