/* private void BSeleccionarPlantilla_Click_1(object sender, EventArgs e) * { * ConsultarBorrador consultarBorrador = new ConsultarBorrador(); * consultarBorrador.ShowDialog(); * * ClearTextBoxes(this); * * Fill(consultarBorrador.CpPlantilla); * }*/ private void BPlantilla_Click_2(object sender, EventArgs e) { int id = 0; int id_empresa = 0; int id_anexo = 0; double precioInstalacion = 0; double precioMantenimiento = 0; if (c != null) { id = c.getId(); } if (eEmpresa != null) { id_empresa = eEmpresa.IId; } if (!tInstalacion.Text.Equals("")) { precioInstalacion = Convert.ToDouble(tInstalacion.Text); } if (!tMantenimiento.Text.Equals("")) { precioMantenimiento = Convert.ToDouble(tMantenimiento.Text); } if (aAnexo != null) { id_anexo = aAnexo.IId; } try { if (contratoPlantilla == null) { NombreBorrador form9 = new NombreBorrador(id, id_empresa, tNAbonado.Text, tNContrato.Text, Data.formatearFecha(tFechaContrato.Text), cbInstalacion.Checked, cbMantenimiento.Checked, Data.formatearFecha(dtpFechaVigor.Text), 12, precioInstalacion, tFPInstalacion.Text, precioMantenimiento, tFPMantenimiento.Text, cMensualidad.SelectedItem.ToString(), tLugar.Text, tCalle.Text, tCpCondiciones.Text, cbMunicipiosCondiciones.Text, cbProvinciasCondiciones.Text, tPersonaContacto.Text, tTelefonoCondiciones.Text, cRobo.Checked, cCctv.Checked, tAnexo.Text, cInstalar.Checked, cMantener.Checked, cbCustodia.Checked, cbIban.Text, id_anexo, tFechaVisado.Text, tCC.Text, tCS.Text); form9.ShowDialog(); for (int i = 0; i < dgElementos.RowCount - 1; i++) { ElementoPlantilla.create(form9.ContratoPlantilla.Id, Convert.ToInt32(dgElementos.Rows[i].Cells["id"].Value), Convert.ToInt32(dgElementos.Rows[i].Cells["Cantidad"].Value)); } this.Close(); } else { ContratoPlantilla.actualizar(contratoPlantilla.Id, id_empresa, id, contratoPlantilla.SNombrePlantilla, tNAbonado.Text, tNContrato.Text, Data.formatearFecha(tFechaContrato.Text), cbInstalacion.Checked, cbMantenimiento.Checked, Data.formatearFecha(dtpFechaVigor.Text), Convert.ToInt32(nudDuracion.Value), precioInstalacion, tFPInstalacion.Text, precioMantenimiento, tFPMantenimiento.Text, tLugar.Text, tCalle.Text, tCpCondiciones.Text, cbMunicipiosCondiciones.Text, cbProvinciasCondiciones.Text, tPersonaContacto.Text, tTelefonoCondiciones.Text, cRobo.Checked, cCctv.Checked, tAnexo.Text, cInstalar.Checked, cMantener.Checked, cbCustodia.Checked, cbIban.Items[cIban.SelectedIndex].ToString() , tFechaVisado.Text, tCC.Text, tCS.Text); ElementoPlantilla.delete(contratoPlantilla.Id); for (int i = 0; i < dgElementos.RowCount - 1; i++) { ElementoPlantilla.create(contratoPlantilla.Id, Convert.ToInt32(dgElementos.Rows[i].Cells["id"].Value), Convert.ToInt32(dgElementos.Rows[i].Cells["Cantidad"].Value)); } MessageBox.Show("Plantilla actualizada.", "Operación realizada correctamente"); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de formulario", MessageBoxButtons.OK, MessageBoxIcon.Error); } }