예제 #1
0
 protected void btnActualizar_Click(object sender, EventArgs e)
 {
     try
     {
         if (true)
         {
             int ValorDevuelto = int.Parse(lblId.Text);
             if (txtAncho.Text == "" | txtLargo.Text == "")
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Complete las MEDIDAS!!'})", true);
                 return;
             }
             else if (txtDescripcion.Text == "")
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Inserte una DESCRIPCIÓN!!'})", true);
                 return;
             }
             else if (txtPrecio.Text.Contains("e"))
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'No se admiten letras en el Precio!!'})", true);
                 return;
             }
             else if (txtAncho.Text.Contains("e") | txtLargo.Text.Contains("e"))
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'No se admiten letras en las medidas!!'})", true);
                 return;
             }
             else if (double.Parse(txtPrecio.Text) <= 0)
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Inserte un PRECIO VALIDO!!'})", true);
                 return;
             }
             else if (double.Parse(txtAncho.Text) <= 0 | double.Parse(txtLargo.Text) <= 0)
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Inserte un Medidas VALIDAS!!'})", true);
                 return;
             }
             else if (txtPrecio.Text == "")
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Inserte un PRECIO!!'})", true);
                 return;
             }
             else if (txtStock.Text == "")
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Inserte STOCK!!'})", true);
                 return;
             }
             else if (ddlEstadoMoldura.Text == "--Seleccione--" | ddlTipoMoldura.SelectedValue.ToString() == "0")
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type:'error',title:'ERROR!',text:'Selecciones un TIPO DE MOLDURA o ESTADO!!'})", true);
                 return;
             }
             _log.CustomWriteOnLog("ActualizarMoldura", "La función es de creación");
             objDtoMoldura.PK_IM_Cod = ValorDevuelto;
             _log.CustomWriteOnLog("ActualizarMoldura", "PK_IM_Cod valor ingresado " + objDtoMoldura.PK_IM_Cod);
             objDtoMoldura.DM_Precio = double.Parse(txtPrecio.Text);
             _log.CustomWriteOnLog("ActualizarMoldura", "DM_Precio valor ingresado " + objDtoMoldura.DM_Precio);
             objDtoMoldura.IM_Estado = int.Parse(ddlEstadoMoldura.SelectedValue);
             _log.CustomWriteOnLog("ActualizarMoldura", "IM_Estado valor ingresado " + objDtoMoldura.IM_Estado);
             objDtoMoldura.IM_Stock = int.Parse(txtStock.Text);
             _log.CustomWriteOnLog("ActualizarMoldura", "IM_Stock valor ingresado " + objDtoMoldura.IM_Stock);
             objDtoMoldura.FK_ITM_Tipo = int.Parse(ddlTipoMoldura.SelectedValue);
             _log.CustomWriteOnLog("ActualizarMoldura", "FK_ITM_Tipo valor ingresado " + objDtoMoldura.FK_ITM_Tipo);
             objDtoMoldura.VM_Descripcion = txtDescripcion.Text;
             _log.CustomWriteOnLog("ActualizarMoldura", "VM_Descripcion valor ingresado " + objDtoMoldura.VM_Descripcion);
             objDtoMoldura.DM_Largo = Double.Parse(txtLargo.Text);
             _log.CustomWriteOnLog("ActualizarMoldura", "DM_Largo valor ingresado " + objDtoMoldura.DM_Largo);
             objDtoMoldura.DM_Ancho = Double.Parse(txtAncho.Text);
             _log.CustomWriteOnLog("ActualizarMoldura", "DM_Ancho valor ingresado " + objDtoMoldura.DM_Ancho);
             objCtrMoldura.ActulizarMoldura(objDtoMoldura);
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type: 'success',title: 'Moldura Actualizada!',text: 'Datos MODIFICADOS!!'}).then(function(){window.location.href='Gestionar_Catalogo.aspx'})", true);
             if (hftxtimg.Value.ToString() != "vacio")
             {
                 string      cadena  = hftxtimg.Value.ToString();
                 List <byte> imagen  = Array.ConvertAll(cadena.Split(','), byte.Parse).ToList();
                 byte[]      bimagen = imagen.ToArray();
                 objDtoMoldura.VBM_Imagen = bimagen;
                 objCtrMoldura.registrarImgMoldura(bimagen, ValorDevuelto);
             }
         }
     }
     catch (Exception ex)
     {
         _log.CustomWriteOnLog("ActualizarMoldura", "Error  = " + ex.Message + "posicion" + ex.StackTrace);
         throw;
     }
 }