public ActionResult updateEmpleado(NuevoEmpleado emp) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE EMPLEADO SET EMPL_APM = @APM, EMPL_APP =@APP, EMPL_NOM =@NOM, EMPL_TIPO =@TIPO WHERE EMPL_COD = @COD", myConnection); command.Parameters.AddWithValue("@APM", emp.empl_apm); command.Parameters.AddWithValue("@COD", emp.empl_cod); command.Parameters.AddWithValue("@NOM", emp.empl_nom); command.Parameters.AddWithValue("@TIPO", emp.empl_tipo); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO HUBO ACTUALIZACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult newEmpleado(NuevoEmpleado emp) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO EMPLEADO (EMPL_NOM, EMPL_APP, EMPL_APM, EMPL_COD, EMPL_STAT, EMPL_TIPO, SUCC_ID) "+ "VALUES (@NOM, @PAT, @MAT, @COD, 'ALTA', @TIPO, @SUCC )", myConnection); command.Parameters.AddWithValue("@NOM", emp.empl_nom); command.Parameters.AddWithValue("@PAT", emp.empl_app); command.Parameters.AddWithValue("@MAT", emp.empl_apm); command.Parameters.AddWithValue("@COD", emp.empl_cod); command.Parameters.AddWithValue("@TIPO", emp.empl_tipo); command.Parameters.AddWithValue("@SUCC", emp.succ_id); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO OCURRIO INSERT"; } command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }