public ActionResult updateUbicacion(Ubicacion ubic) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE UBICACION SET UBIC_DES =@DESC WHERE UBIC_CONSEC = @CONSEC AND REST_ID =@REST", myConnection); command.Parameters.AddWithValue("@REST", ubic.rest_id); command.Parameters.AddWithValue("@CONSEC", ubic.ubic_consec); command.Parameters.AddWithValue("@DESC", ubic.ubic_des); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE COMPLETO LA ACTUALIZACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult getUbicaciones(ReqUbicacion ubic) { Ubicaciones respUbicaciones = new Ubicaciones(); SqlDataReader reader = null; SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("SELECT * FROM UBICACION WHERE REST_ID = @REST", myConnection); command.Parameters.AddWithValue("@REST", ubic.rest_id); reader = command.ExecuteReader(); List<Ubicacion> listaUbic = new List<Ubicacion>(); while (reader.Read()) { Ubicacion ubicacion = new Ubicacion(); ubicacion.rest_id = Convert.ToInt32(reader["rest_id"].ToString()); ubicacion.ubic_consec = Convert.ToInt32(reader["ubic_consec"].ToString()); ubicacion.ubic_des = reader["ubic_des"].ToString(); listaUbic.Add(ubicacion); } respUbicaciones.ubicaciones = listaUbic; } catch (Exception ex) { respUbicaciones.success = false; respUbicaciones.message = "ERROR " + ex.Message; return Json(respUbicaciones); } finally { myConnection.Close(); } respUbicaciones.success = true; respUbicaciones.message ="OK"; return Json(respUbicaciones); }