/// <summary> ///</summary> /// <param name="CALLE"> Object CALLE added to List</param> public override int AddCALLE(CALLEEntity entity_CALLE) { int result = 0; using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.CALLE.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_CALLEAdd", connection); AssingParameter(comandoSql, "@Clv_Calle", null, pd: ParameterDirection.Output, IsKey: true); AssingParameter(comandoSql, "@Nombre", entity_CALLE.Nombre); try { if (connection.State == ConnectionState.Closed) { connection.Open(); } result = ExecuteNonQuery(comandoSql); } catch (Exception ex) { throw new Exception("Error adding CALLE " + ex.Message, ex); } finally { connection.Close(); } result = (int)comandoSql.Parameters["@Clv_Calle"].Value; } return(result); }
/// <summary> /// Edits a CALLE ///</summary> /// <param name="CALLE"> Objeto CALLE a editar </param> public override int EditCALLE(CALLEEntity entity_CALLE) { int result = 0; using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.CALLE.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_CALLEEdit", connection); AssingParameter(comandoSql, "@Clv_Calle", entity_CALLE.Clv_Calle); AssingParameter(comandoSql, "@Nombre", entity_CALLE.Nombre); try { if (connection.State == ConnectionState.Closed) { connection.Open(); } result = int.Parse(ExecuteNonQuery(comandoSql).ToString()); } catch (Exception ex) { throw new Exception("Error updating CALLE " + ex.Message, ex); } finally { if (connection != null) { connection.Close(); } } } return(result); }
public ActionResult GetCalleByColonia(int colonia, int plaza) { ConexionController c = new ConexionController(); SqlCommand comandoSql; List <CALLEEntity> lista = new List <CALLEEntity>(); SqlConnection conexionSQL = new SqlConnection(c.DameConexion(plaza)); try { conexionSQL.Open(); } catch { } comandoSql = new SqlCommand("select x3.Clv_Calle,x3.Nombre,x2.Clv_Colonia from CVECAROL x1 join COLONIAS x2 on x1.Clv_Colonia=x2.Clv_Colonia join CALLES x3 on x3.Clv_Calle=x1.Clv_Calle where x2.Clv_Colonia=" + colonia + " order by x3.Nombre"); comandoSql.Connection = conexionSQL; SqlDataReader reader = comandoSql.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CALLEEntity calle = new CALLEEntity(); calle.Clv_Calle = Int32.Parse(reader[0].ToString()); calle.Nombre = reader[1].ToString(); lista.Add(calle); } } return(Json(lista, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Converts data from reader to entity /// </summary> protected virtual CALLEEntity GetCALLEFromReader(IDataReader reader) { CALLEEntity entity_CALLE = null; try { entity_CALLE = new CALLEEntity(); entity_CALLE.Clv_Calle = (int?)(GetFromReader(reader, "Clv_Calle")); entity_CALLE.Nombre = (String)(GetFromReader(reader, "Nombre", IsString: true)); } catch (Exception ex) { throw new Exception("Error converting CALLE data to entity", ex); } return(entity_CALLE); }
public static CALLEEntity GetOneDeep(int?Clv_Calle) { CALLEEntity result = ProviderSoftv.CALLE.GetCALLEById(Clv_Calle); if (result.Clv_Calle != null) { result.CLIENTE = ProviderSoftv.CLIENTE.GetCLIENTEById(result.Clv_Calle); } if (result.Clv_Calle != null) { result.CVECAROL = ProviderSoftv.CVECAROL.GetCVECAROLByCalle(result.Clv_Calle); } return(result); }
/// <summary> /// Gets CALLE by ///</summary> public override CALLEEntity GetCALLEById(int?Clv_Calle) { using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.CALLE.ConnectionString)) { SqlCommand comandoSql = CreateCommand("Softv_CALLEGetById", connection); CALLEEntity entity_CALLE = null; AssingParameter(comandoSql, "@Clv_Calle", Clv_Calle); IDataReader rd = null; try { if (connection.State == ConnectionState.Closed) { connection.Open(); } rd = ExecuteReader(comandoSql, CommandBehavior.SingleRow); if (rd.Read()) { entity_CALLE = GetCALLEFromReader(rd); } } catch (Exception ex) { throw new Exception("Error getting data CALLE " + ex.Message, ex); } finally { if (connection != null) { connection.Close(); } if (rd != null) { rd.Close(); } } return(entity_CALLE); } }
public static int Edit(CALLEEntity objCALLE) { int result = ProviderSoftv.CALLE.EditCALLE(objCALLE); return(result); }
public static int Add(CALLEEntity objCALLE) { int result = ProviderSoftv.CALLE.AddCALLE(objCALLE); return(result); }
/// <summary> /// Abstract method to update CALLE /// </summary> public abstract int EditCALLE(CALLEEntity entity_CALLE);
/// <summary> /// Abstract method to add CALLE /// /summary> /// <param name="CALLE"></param> /// <returns></returns> public abstract int AddCALLE(CALLEEntity entity_CALLE);
public int UpdateCALLE(CALLEEntity objCALLE) { return(CALLE.Edit(objCALLE)); }
public int AddCALLE(CALLEEntity objCALLE) { return(CALLE.Add(objCALLE)); }