private void button_Guardar_Click(object sender, EventArgs e) { String general = "0"; String baja = "0"; String fisico = "0"; if (checkBox_GG.Checked) { general = "-1"; comprueba_generales(); } if (checkBox_Desactivado.Checked) { baja = "-1"; } if (checkBox_fisico.Checked) { fisico = "-1"; } if (id_bloque != "0") { String sql = "UPDATE com_bloques SET Descripcion = '" + textBox_Bloque.Text + "', GG = " + general + ", Baja = " + baja + ", Fisica = " + fisico + ", IdTipoSubcuota =" + comboBox_tipoCalculo.SelectedValue + " WHERE com_bloques.IdBloque = " + id_bloque; Persistencia.SentenciasSQL.InsertarGenerico(sql); form_anterior.cargarBloques(); this.Close(); } else { String sql = "INSERT INTO com_bloques (IdComunidad, Descripcion, IdTipoBloque, GG, Baja, IdTipoSubcuota, Fisica) VALUES(" + id_comunidad_cargado + ",'" + textBox_Bloque.Text + "',1," + general + "," + baja + "," + comboBox_tipoCalculo.SelectedValue + ", " + fisico + ")"; Persistencia.SentenciasSQL.InsertarGenerico(sql); form_anterior.cargarBloques(); this.Close(); } }
private void button5_Click(object sender, EventArgs e) { button5.Enabled = true; if (label2.Visible) { for (int c = 0; c < dataGridView_DetallesBloque.Rows.Count; c++) { if (dataGridView_DetallesBloque.Rows[c].Cells[0].Value.ToString() != "0") { String sql = "UPDATE com_subcuotas SET Subcuota = " + (dataGridView_DetallesBloque.Rows[c].Cells["Subcuota"].Value.ToString()).Replace(",", ".") + ", Parte = '" + (dataGridView_DetallesBloque.Rows[c].Cells["Parte"].Value.ToString()).Replace(",", ".") + "' WHERE IdSubcuota = " + dataGridView_DetallesBloque.Rows[c].Cells[0].Value.ToString(); Persistencia.SentenciasSQL.InsertarGenerico(sql); //campoCalculo(); } } if (id_divisiones != null) { for (int a = 0; a < id_divisiones.Count; a++) { String subcuota_division = ""; for (int b = 0; b < dataGridView_DetallesBloque.Rows.Count; b++) { if (dataGridView_DetallesBloque.Rows[b].Cells["IdDivision"].Value.ToString() == id_divisiones[a]) { subcuota_division = (dataGridView_DetallesBloque.Rows[b].Cells["Subcuota"].Value.ToString()).Replace(",", "."); } } String sql = "INSERT INTO com_subcuotas (IdDivision, IdBloque, Subcuota) VALUES (" + id_divisiones[a] + "," + id_bloque + "," + subcuota_division + ")"; Persistencia.SentenciasSQL.InsertarGenerico(sql); campoCalculo(); } } form_anterior.cargarBloques(); button5.Enabled = true; this.Close(); } else { MessageBox.Show("No hay nada que guardar"); button5.Enabled = true; } }