private void button2_Click(object sender, EventArgs e) { int opt = searchclcmb.SelectedIndex; List <Client> all = cdb.read(); switch (opt) { default: { updateClients(all); return; } case 0: { List <Client> list = new List <Client> { cdb.QueryByID(Int32.Parse(searchclientField.Text)) }; updateClients(list); break; } case 1: { var list = (from Client x in all where x.cedula.Equals(searchclcmb.Text) select x).ToList(); updateClients(list); break; } case 2: { var list = (from Client x in all where x.surname.Equals(searchclcmb.Text) select x).ToList(); updateClients(list); break; } } }
private void okbtn_Click(object sender, EventArgs e) { foreach (var comp in fieldpanel.Controls) { TextBox txt = comp as TextBox; if (txt != null) { if (txt.Text == "") { MessageBox.Show("No estan llenos todos los campos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } Client aux = cdb.QueryByID(Int32.Parse(clfield.Text)); if (aux == null) { MessageBox.Show("El cliente ingresado no existe", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("El cliente seleccionado es: " + aux.pair(), "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel) { return; } Extinguisher nw = new Extinguisher(ext.id, Char.Parse(catcmb.SelectedItem.ToString()), brandfield.Text, typecmb.SelectedIndex, float.Parse(qtyfield.Text), unitcmb.SelectedItem.ToString(), placefield.Text, datefield.Value, aux); if (isModify) { if (edb.update(nw)) { MessageBox.Show("Se ha actualizado correctamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (edb.create(nw)) { MessageBox.Show("Se ha guardado correctamente correctamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } Close(); }