private void btnGuardar_Click(object sender, EventArgs e) { if (txt_valor_actualizar.Text == "") { MessageBox.Show("Debe colocar un nuevo importe", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_valor_actualizar.Focus(); } else { string resultado; logConcepto objlogConcepto = new logConcepto(); frmConcepto objfrmConcepto = new frmConcepto(); logHistorial objlogHistorial = new logHistorial(); string fecha_actualizacion = DateTime.Today.ToString(("yyyy-MM-dd")); string fecha_ult_actualizacion; string fecha_hasta = DateTime.Today.ToString("yyyy-MM-dd"); decimal valor_nuevo = Convert.ToDecimal(txt_valor_actualizar.Text); if (valor_anterior == 0) { fecha_ult_actualizacion = fecha_inicio.ToString("yyyy - MM - dd"); } else { fecha_ult_actualizacion = fecha_actualizacion; } entConcepto objentConcepto = new entConcepto(); objentConcepto.CON_ID = Convert.ToInt32(id_concepto); objentConcepto.CON_FECHA_ACT = DateTime.Today; objentConcepto.CON_VALOR_ANTERIOR = valor_actual; objentConcepto.CON_FECHA_INI = fecha_inicio; objentConcepto.CON_VALOR_ACTUAL = valor_nuevo; entHistorial objentHistorial = new entHistorial(); objentHistorial.HIS_CON_ID = Convert.ToInt32(id_concepto); objentHistorial.HIS_VALOR_ANTERIOR = valor_actual; string his_desde; string his_hasta; if (valor_anterior == 0) { his_desde = fecha_inicio.ToString("yyyy - MM - dd"); } else { his_desde = fecha_ult_actualizacion; } his_hasta = fecha_actualizacion; resultado = objlogConcepto.ActualizarMonto(objentConcepto, fecha_hasta, fecha_ult_actualizacion); string resultado_historial = objlogHistorial.InsertarHistorialConceptos(objentHistorial, his_hasta, his_desde); MessageBox.Show(resultado, "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
public string InsertarHistorialConceptos(entHistorial historial, string phis_hasta, string phis_desde) { con = generarConexion(); string result; try { con.Open(); cmd = new SqlCommand("INSERT INTO T_HISTORIAL" + "(HIS_HASTA," + "HIS_CON_ID, " + "HIS_DESDE, " + " HIS_VALOR_ANTERIOR)" + "VALUES" + "(CAST ('" + phis_hasta + "' AS DATE), " + historial.HIS_CON_ID + ",CAST('" + phis_hasta + "' AS DATE)," + "" + historial.HIS_VALOR_ANTERIOR.ToString().Replace(",", ".") + " )", con); cmd.ExecuteNonQuery(); result = "SE CARGÓ HISTORIAL"; } catch (Exception ex) { result = "NO SE PUDO CARGAR EL HISTORIAL " + ex.ToString(); con.Close(); } return(result); }
public string InsertarHistorialConceptos(entHistorial historial, string phis_hasta, string phis_desd) { return(objHistorial.InsertarHistorialConceptos(historial, phis_hasta, phis_desd)); }