/// <summary> /// Envia los cambios del tsy_ConceptosDataset.tsy_ConceptosDataTable a la base de datos. /// </summary> public static void Update(tsy_ConceptosDataset.tsy_ConceptosDataTable dataTable) { ApplicationAssert.Check(dataTable != null, "El argumento dataTable no debe ser nulo.", ApplicationAssert.LineNumber); ApplicationAssert.Check(dataTable.Rows.Count > 0, "El argumento dataTable debe poseer alguna fila.", ApplicationAssert.LineNumber); mz.erp.dataaccess.tsy_Conceptos.Update(dataTable); }
public static void Update(tsy_ConceptosDataset.tsy_ConceptosDataTable dataTable, SqlTransaction trx) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.TableMappings.AddRange( new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "tsy_Conceptos", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("IdConcepto", "IdConcepto"), new System.Data.Common.DataColumnMapping("Descripcion", "Descripcion"), new System.Data.Common.DataColumnMapping("IdTipoConcepto", "IdTipoConcepto"), new System.Data.Common.DataColumnMapping("Valor", "Valor"), new System.Data.Common.DataColumnMapping("IdEmpresa", "IdEmpresa") } ) } ); SqlCommand sqlCommandUpdate = new SqlCommand("Pr_tsy_Conceptos_Update", trx.Connection); sqlCommandUpdate.Transaction = trx; sqlCommandUpdate.CommandType = CommandType.StoredProcedure; sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdConcepto", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConcepto", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@Descripcion", SqlDbType.VarChar, 50, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Descripcion", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdTipoConcepto", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTipoConcepto", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@Valor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Valor", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdEmpresa", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEmpresa", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldIdConcepto", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConcepto", DataRowVersion.Original, null)); SqlCommand sqlCommandDelete = new SqlCommand("Pr_tsy_Conceptos_Delete", trx.Connection); sqlCommandDelete.Transaction = trx; sqlCommandDelete.CommandType = CommandType.StoredProcedure; sqlCommandDelete.Parameters.Add(new SqlParameter("@IdConcepto", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConcepto", DataRowVersion.Original, null)); sqlCommandDelete.Parameters.Add(new SqlParameter("@UltimaModificacion", SqlDbType.Timestamp, 8, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "UltimaModificacion", DataRowVersion.Original, null)); SqlCommand sqlCommandInsert = new SqlCommand("Pr_tsy_Conceptos_Insert", trx.Connection); sqlCommandInsert.Transaction = trx; sqlCommandInsert.CommandType = CommandType.StoredProcedure; sqlCommandInsert.Parameters.Add(new SqlParameter("@Descripcion", SqlDbType.VarChar, 50, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Descripcion", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdTipoConcepto", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTipoConcepto", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@Valor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Valor", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdEmpresa", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEmpresa", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdConcepto", SqlDbType.BigInt, 0, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConcepto", DataRowVersion.Current, null)); adapter.UpdateCommand = sqlCommandUpdate; adapter.DeleteCommand = sqlCommandDelete; adapter.InsertCommand = sqlCommandInsert; adapter.Update(dataTable); }