public void Alimentar(IEnumerable <CsTypeServicioManto> TblServicioManto) { DataTable table = new DataTable(); table.Columns.Add("IdSrvManto", typeof(int)); table.Columns.Add("CodServicioManto", typeof(string)); table.Columns.Add("CodPatronManto", typeof(string)); table.Columns.Add("Descripcion", typeof(string)); table.Columns.Add("NroDocumento", typeof(string)); table.Columns.Add("CodCapitulo", typeof(string)); table.Columns.Add("BadPlan", typeof(string)); table.Columns.Add("Bandera", typeof(string)); table.Columns.Add("BanTipoSrv", typeof(int)); table.Columns.Add("Usu", typeof(string)); table.Columns.Add("NroEtapas", typeof(int)); table.Columns.Add("EtapaActual", typeof(int)); table.Columns.Add("SubAta", typeof(string)); table.Columns.Add("ConsecutivoAta", typeof(int)); table.Columns.Add("IdTipoSrv", typeof(int)); table.Columns.Add("AD", typeof(int)); table.Columns.Add("SB", typeof(int)); table.Columns.Add("HorizonteApertura", typeof(double)); table.Columns.Add("Referencia", typeof(string)); table.Columns.Add("CodModeloSM", typeof(string)); table.Columns.Add("PnMayor", typeof(string)); table.Columns.Add("SubComponenteSM", typeof(int)); table.Columns.Add("CodTaller", typeof(string)); table.Columns.Add("CodReferenciaSrv", typeof(string)); table.Columns.Add("Catalogo", typeof(string)); table.Columns.Add("ValidarRecurso", typeof(int)); table.Columns.Add("VisualizarStatus", typeof(int)); table.Columns.Add("ServicioMayor", typeof(string)); table.Columns.Add("Accion", typeof(string)); table.Columns.Add("Aplicabilidad", typeof(string)); foreach (var Campos in TblServicioManto) { table.Rows.Add(new object[] { Campos.IdSrvManto, Campos.CodServicioManto, Campos.CodPatronManto, Campos.Descripcion, Campos.NroDocumento, Campos.CodCapitulo, Campos.BadPlan, Campos.Bandera, Campos.BanTipoSrv, Campos.Usu, Campos.NroEtapas, Campos.EtapaActual, Campos.SubAta, Campos.ConsecutivoAta, Campos.IdTipoSrv, Campos.AD, Campos.SB, Campos.HorizonteApertura, Campos.Referencia, Campos.CodModeloSM, Campos.PnMayor, Campos.SubComponenteSM, Campos.CodTaller, Campos.CodReferenciaSrv, Campos.Catalogo, Campos.ValidarRecurso, Campos.VisualizarStatus, Campos.ServicioMayor, Campos.Accion, Campos.Aplicabilidad, }); } Cnx.SelecBD(); using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex())) { sqlCon.Open(); using (SqlTransaction transaction = sqlCon.BeginTransaction()) { string VBQuery = "SP_InsUpd_ServicioManto"; using (SqlCommand sqlCmd = new SqlCommand(VBQuery, sqlCon, transaction)) { try { sqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter Prmtrs = sqlCmd.Parameters.AddWithValue("@CurVD", table); SqlParameter Prmtrs2 = sqlCmd.Parameters.AddWithValue("@IdConfigCia", HttpContext.Current.Session["!dC!@"].ToString()); Prmtrs.SqlDbType = SqlDbType.Structured; //sqlCmd.ExecuteNonQuery(); var Id = sqlCmd.ExecuteScalar(); if (Id != null) { VbID = Convert.ToInt32(Id.ToString()); } transaction.Commit(); } catch (Exception Ex) { string VbUsu, VbPantalla, VbcatVer, VbcatAct; VbUsu = System.Web.HttpContext.Current.Session["C77U"].ToString(); VbPantalla = "FrmServicioManto"; VbcatVer = System.Web.HttpContext.Current.Session["77Version"].ToString(); VbcatAct = System.Web.HttpContext.Current.Session["77Act"].ToString(); Cnx.UpdateErrorV2(VbUsu, VbPantalla, "CsTypeServicioManto", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct); transaction.Rollback(); } } } } }
public void Alimentar(IEnumerable <CsTypContaSrvMant> TblContaSrvManto) { DataTable table = new DataTable(); table.Columns.Add("CodIdContaSrvManto", typeof(int)); table.Columns.Add("CodAeronave", typeof(int)); table.Columns.Add("CodElemento", typeof(int)); table.Columns.Add("CodServicioManto", typeof(string)); table.Columns.Add("Frecuencia", typeof(double)); table.Columns.Add("Extension", typeof(double)); table.Columns.Add("FechaVencimiento", typeof(DateTime)); table.Columns.Add("NroDias", typeof(double)); table.Columns.Add("ExtensionDias", typeof(double)); table.Columns.Add("BanOrdenTrabajo", typeof(int)); table.Columns.Add("Usu", typeof(string)); table.Columns.Add("banUnicoCumplimiento", typeof(int)); table.Columns.Add("CodOt", typeof(int)); table.Columns.Add("Compensacion", typeof(double)); table.Columns.Add("Resetear", typeof(int)); table.Columns.Add("FrecuenciaInicial", typeof(double)); table.Columns.Add("FrecuenciaInicalEjecutada", typeof(int)); table.Columns.Add("CodContador", typeof(string)); table.Columns.Add("CodElem", typeof(string)); table.Columns.Add("PN", typeof(string)); table.Columns.Add("Accion", typeof(string)); table.Columns.Add("Aplicabilidad", typeof(string)); table.Columns.Add("CrearHistorico", typeof(string)); table.Columns.Add("Historico", typeof(string)); foreach (var Campos in TblContaSrvManto) { table.Rows.Add(new object[] { Campos.CodIdContaSrvManto, Campos.CodAeronave, Campos.CodElemento, Campos.CodServicioManto, Campos.Frecuencia, Campos.Extension, Campos.FechaVencimiento, Campos.NroDias, Campos.ExtensionDias, Campos.BanOrdenTrabajo, Campos.Usu, Campos.banUnicoCumplimiento, Campos.CodOt, Campos.Compensacion, Campos.Resetear, Campos.FrecuenciaInicial, Campos.FrecuenciaInicalEjecutada, Campos.CodContador, Campos.CodElem, Campos.PN, Campos.Accion, Campos.Aplicabilidad, Campos.CrearHistorico, Campos.Historico, }); } Cnx.SelecBD(); using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex())) { sqlCon.Open(); using (SqlTransaction transaction = sqlCon.BeginTransaction()) { string VBQuery = "SP_InsUpd_ContaSrvManto"; using (SqlCommand sqlCmd = new SqlCommand(VBQuery, sqlCon, transaction)) { try { sqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter Prmtrs = sqlCmd.Parameters.AddWithValue("@CurVD", table); SqlParameter Prmtrs1 = sqlCmd.Parameters.AddWithValue("@IdConfigCia", HttpContext.Current.Session["!dC!@"].ToString()); Prmtrs.SqlDbType = SqlDbType.Structured; sqlCmd.ExecuteNonQuery(); transaction.Commit(); } catch (Exception Ex) { string VbUsu, VbPantalla, VbcatVer, VbcatAct; VbUsu = System.Web.HttpContext.Current.Session["C77U"].ToString(); VbPantalla = "FrmServicioManto"; VbcatVer = System.Web.HttpContext.Current.Session["77Version"].ToString(); VbcatAct = System.Web.HttpContext.Current.Session["77Act"].ToString(); Cnx.UpdateErrorV2(VbUsu, VbPantalla, "CsTypContaSrvMant", Ex.StackTrace.Substring(Ex.StackTrace.Length - 300, 300), Ex.Message, VbcatVer, VbcatAct); transaction.Rollback(); } } } } }