public void saveButton_Click(object sender, EventArgs e) { var document = new Document(); document.code = textBox1.Text; document.emission_local = textBox2.Text; document.emission_date = dateTimePicker2.Value; document.expiration_date = dateTimePicker1.Value; if (document.emission_date > document.expiration_date) { InfoForm info = new InfoForm(); info.Add("Aviso: Data de Emissao é maior do que data de Expiraçao !"); info.Enabled = false; info.Visible = true; } else { DocumentType doctype = documents.FirstOrDefault(d => d.Name.Equals(comboBox1.Text)); if (doctype == null) { return; } document.Type = doctype; serverClient.InsertPersonAsync(person); document.Person = person; try { SampleGenericDelegate <Document, int> del = new SampleGenericDelegate <Document, int>(serverClient.InsertDocument); IAsyncResult result = del.BeginInvoke(document, null, null); del.EndInvoke(result); Close(); } catch (Exception exception) { var info = new InfoForm(); info.Add(exception.Message); info.ShowDialog(this); info.Dispose(); } } }
private void SaveButton_Click(object sender, EventArgs e) { try { SetPerson(); serverClient.InsertPersonAsync(p); // _regist.AddPerson(p); SaveButton.Enabled = false; Close(); } catch (Exception exc) { var info = new InfoForm(); info.Add(exc.Message); info.ShowDialog(this); info.Dispose(); } }