public void Guardar(object sender, EventArgs e)//Guardar { DataTable dt = Session["Tabla"] as DataTable; if (dt.Rows.Count == 0) { txtahora.InnerText = "La tabla no continiene ningun items"; } else { try { var registrosapruebaasig = Controlasql.ccreaaprueba_asignac(txtidacta.Text, SelectProveedor.Value, OBSERVACIONG.Value, FECHAMANT.Value, Session["USUARIO"].ToString(), "", "", Session["BD"].ToString()); if (registrosapruebaasig > 0) { foreach (GridViewRow row in GridViewdetalle.Rows) { string clasemante = row.Cells[10].Text; if (clasemante == "ACTIVOS FIJOS") { string serialtemp = row.Cells[2].Text; string tipomant = row.Cells[3].Text; string detallemant = row.Cells[4].Text.Trim(); int mano_obra = Convert.ToInt32(row.Cells[5].Text); string r_utilizados = row.Cells[6].Text.Trim(); string nexterno = row.Cells[7].Text.Trim(); int v_repuestos = Convert.ToInt32(row.Cells[8].Text); string garant = row.Cells[9].Text; string dat = ahora; string test = serialtemp; string[] palabras = test.Split('/'); string serial = palabras[0]; string nombrearticulo = palabras[1]; try { var registros3 = Controlasql.Ccrea_detalles_mant_conArticulo(txtidacta.Text, serial, r_utilizados, mano_obra, v_repuestos, detallemant, tipomant, clasemante, garant, nexterno, Session["BD"].ToString()); string script = @"<script type='text/javascript'> alert('Acta de Mantenimiento OK'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } catch (Exception Ex) { throw Ex; } } else { string serialtemp = row.Cells[2].Text; string tipomant = row.Cells[3].Text; string detallemant = row.Cells[4].Text.Trim(); int mano_obra = Convert.ToInt32(row.Cells[5].Text); string r_utilizados = row.Cells[6].Text.Trim(); string nexterno = row.Cells[7].Text.Trim(); int v_repuestos = Convert.ToInt32(row.Cells[8].Text); string garant = row.Cells[9].Text; string dat = ahora; string test = serialtemp; try { var registros3 = Controlasql.ccreadeta_Act_Mant_Na(txtidacta.Text, r_utilizados, mano_obra , v_repuestos, detallemant, tipomant, clasemante, garant, nexterno, Session["BD"].ToString()); if (registros3 > 0) { string script = @"<script type='text/javascript'> alert('Acta de Mantenimiento OK'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } catch (Exception exp) { throw exp; } } //aqui creamos el acta de mantenimiento } imprimir(); } } catch (Exception ex) { alerta.MessageBox(this, $"Excepcion Interna: {ex}"); } } }