protected void btnTodos_Click(object sender, EventArgs e) { try { DataTable dt = new DataTable(); dt = objCtrMoldura.ListarTodoMoldura(objDtoMoldura); string Image1; string HtmlRepeater = ""; string cs = ConfigurationManager.ConnectionStrings["conexion"].ConnectionString; foreach (DataRow row in dt.Rows) { string PK_IM_Cod = row["PK_IM_Cod"].ToString(); string DM_Medida = row["DM_Medida"].ToString(); string VTM_UnidadMetrica = row["VTM_UnidadMetrica"].ToString(); string DM_Precio = row["DM_Precio"].ToString(); string VM_Descripcion = row["VM_Descripcion"].ToString(); _log.CustomWriteOnLog("BaquetonC", "PK_IM_Cod : " + PK_IM_Cod); _log.CustomWriteOnLog("BaquetonC", "DM_Medida : " + DM_Medida); _log.CustomWriteOnLog("BaquetonC", "VTM_UnidadMetrica : " + VTM_UnidadMetrica); _log.CustomWriteOnLog("BaquetonC", "DM_Precio : " + DM_Precio); _log.CustomWriteOnLog("BaquetonC", "VM_Descripcion : " + VM_Descripcion); objDtoMoldura.PK_IM_Cod = int.Parse(PK_IM_Cod); using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("SP_GetImageById", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramId = new SqlParameter() { ParameterName = "@Id", Value = int.Parse(PK_IM_Cod) }; _log.CustomWriteOnLog("BaquetonC", "id" + int.Parse(PK_IM_Cod)); cmd.Parameters.Add(paramId); con.Open(); byte[] bytes = (byte[])cmd.ExecuteScalar(); con.Close(); string strbase64 = Convert.ToBase64String(bytes); Image1 = "data:Image/png;base64," + strbase64; } HtmlRepeater += " <li>" + "<div class=tipo-moldura>" + "<img loading='lazy' src='" + Image1 + "' alt=''>" + "<p>Mide: " + DM_Medida + "</p>" + "<p>Precio: S./" + DM_Precio + "</p>" + "<button id='btnSave' class='btn btn-primary nextBtn-2' onClick='cargarInformacion(" + PK_IM_Cod + ")'>Detalles</asp:button>" + "</div>" + "<button id='btnSave' class='btn btn-primary nextBtn-2' onClick='cargarListaDeseo(" + PK_IM_Cod + ")'>Agregar lista de deseos</asp:button>" + "</div>" + " </li>"; ListaMoldura.InnerHtml = HtmlRepeater; } } catch (Exception ex) { _log.CustomWriteOnLog("Baqueton", "Error :" + ex.Message + "StackTrace" + ex.StackTrace); throw; } }
//Muestra listado de todas las molduras con su imagen, descripcion, precio y boton detalle public void mostrarTodos() { DataTable dt = new DataTable(); dt = objCtrMoldura.ListarTodoMoldura(objDtoMoldura); string Image1; string HtmlRepeater = ""; //string cs = ConfigurationManager.ConnectionStrings["conexion"].ConnectionString; foreach (DataRow row in dt.Rows) { string PK_IM_Cod = row["PK_IM_Cod"].ToString(); //string DM_Medida = row["DM_Medida"].ToString(); //string VTM_UnidadMetrica = row["VTM_UnidadMetrica"].ToString(); string DM_Precio = row["DM_Precio"].ToString(); string VTM_Nombre = row["VTM_Nombre"].ToString(); string VM_Descripcion = row["VM_Descripcion"].ToString(); _log.CustomWriteOnLog("Codigo", "PK_IM_Cod : " + PK_IM_Cod); //_log.CustomWriteOnLog("BaquetonC", "DM_Medida : " + DM_Medida); //_log.CustomWriteOnLog("BaquetonC", "VTM_UnidadMetrica : " + VTM_UnidadMetrica); _log.CustomWriteOnLog("Precio", "DM_Precio : " + DM_Precio); _log.CustomWriteOnLog("Descripcion", "VM_Descripcion : " + VM_Descripcion); objDtoMoldura.PK_IM_Cod = int.Parse(PK_IM_Cod); objCtrMoldura.ObtenerMoldura(objDtoMoldura, objDtoTipoMoldura); //using (SqlConnection con = new SqlConnection(cs)) //{ // SqlCommand cmd = new SqlCommand("SP_GetImageById", con); // cmd.CommandType = CommandType.StoredProcedure; // SqlParameter paramId = new SqlParameter() // { // ParameterName = "@Id", // Value = int.Parse(PK_IM_Cod) // }; // _log.CustomWriteOnLog("Codigo baqueton", "id" + int.Parse(PK_IM_Cod)); // cmd.Parameters.Add(paramId); // con.Open(); // byte[] bytes = (byte[])cmd.ExecuteScalar(); // con.Close(); // string strbase64 = Convert.ToBase64String(bytes); // Image1 = "data:Image/png;base64," + strbase64; //} Image1 = "data:Image/png;base64," + Convert.ToBase64String(objDtoMoldura.VBM_Imagen); HtmlRepeater += "<div class='col-sm-6 col-xl-3 filter-item all web illustrator'>" + "<div class=gal-box>" + "<a src = '" + Image1 + "' class='image-popup' title='Baqueton-1'>" + "<img src = '" + Image1 + "' class='img-fluid' alt=Baqueton 01' width='550px' height='412px'>" + "</a>" + "<div class='gall-info'>" + "<h4 class='font-16 mt-0'>" + VTM_Nombre + " - #" + PK_IM_Cod + "</h4>" + "<h4 class='font-16 mt-0'>" + " S/. " + DM_Precio + "</h4>" + "<a href = javascript: void(0);>" + "<input type='button' value='Detalles' id='btnSave' class='text-muted ml-1' onClick='cargarInformacion(" + PK_IM_Cod + ")'>" + "</asp:input>" + "</a>" + "<a href = javascript:mostrarMensaje(); OnClick='btnAgregarCarrito_Click' class='gal-like-btn'><i class='mdi mdi-cart'></i></a>" + "</div>" + "</div>" + "</div>"; ListaMoldura.InnerHtml = HtmlRepeater; } }