protected bool GetProduct(int id, SqlConnection conn = null, SqlTransaction transac = null) { bool result = false; try { SqlCommand cmd; if (conn != null) { cmd = new SqlCommand("SP_GET_PRODUCT", conn); } else { cmd = new SqlCommand("SP_GET_PRODUCT", Sistem.GetSqlConnection()); } if (transac != null) { cmd.Transaction = transac; } cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (!dr.IsDBNull(dr.GetOrdinal("id"))) { Id = Convert.ToInt32(dr.GetInt32(dr.GetOrdinal("id"))); } if (!dr.IsDBNull(dr.GetOrdinal("price"))) { Price = Convert.ToDecimal(dr.GetInt32(dr.GetOrdinal("price"))); } if (!dr.IsDBNull(dr.GetOrdinal("id_categ"))) { Id_categ = Convert.ToInt32(dr.GetInt32(dr.GetOrdinal("id_categ"))); } if (!dr.IsDBNull(dr.GetOrdinal("name"))) { Name = Convert.ToString(dr.GetInt32(dr.GetOrdinal("name"))); } if (!dr.IsDBNull(dr.GetOrdinal("description"))) { Description = Convert.ToString(dr.GetInt32(dr.GetOrdinal("description"))); } if (!dr.IsDBNull(dr.GetOrdinal("presentation"))) { Presentation = Convert.ToString(dr.GetInt32(dr.GetOrdinal("presentation"))); } Estado = (int)Sistem.EnumEstados.NA; } result = true; } catch (Exception ex) { Sistem.WriteLog(ex, "Product.GetProduct(int id)", true); } return(result); }