/// <summary> /// Envia los cambios del tsh_LocalidadesDataset.tsh_LocalidadesDataTable a la base de datos. /// </summary> public static void Update(tsh_LocalidadesDataset.tsh_LocalidadesDataTable 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); SentenciasReplicacion replicacion = GenerateReplication(); mz.erp.dataaccess.tsh_Localidades.Update(dataTable, replicacion); }
public static void Update(tsh_LocalidadesDataset.tsh_LocalidadesDataTable dataTable, SqlTransaction trx) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.TableMappings.AddRange( new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "tsh_Localidades", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("IdLocalidad", "IdLocalidad"), new System.Data.Common.DataColumnMapping("Descripcion", "Descripcion"), new System.Data.Common.DataColumnMapping("CodigoPostal", "CodigoPostal"), new System.Data.Common.DataColumnMapping("FechaCreacion", "FechaCreacion"), new System.Data.Common.DataColumnMapping("IdConexionCreacion", "IdConexionCreacion"), new System.Data.Common.DataColumnMapping("UltimaModificacion", "UltimaModificacion"), new System.Data.Common.DataColumnMapping("IdConexionUltimaModificacion", "IdConexionUltimaModificacion"), new System.Data.Common.DataColumnMapping("IdReservado", "IdReservado"), new System.Data.Common.DataColumnMapping("RowId", "RowId"), new System.Data.Common.DataColumnMapping("IdEmpresa", "IdEmpresa"), new System.Data.Common.DataColumnMapping("IdSucursal", "IdSucursal"), new System.Data.Common.DataColumnMapping("IdGenerado", "IdGenerado"), new System.Data.Common.DataColumnMapping("RowIdGenerado", "RowIdGenerado") } ) } ); SqlCommand sqlCommandUpdate = new SqlCommand("Pr_tsh_Localidades_Update", trx.Connection); sqlCommandUpdate.Transaction = trx; sqlCommandUpdate.CommandType = CommandType.StoredProcedure; sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdLocalidad", SqlDbType.VarChar, 30, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdLocalidad", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@Descripcion", SqlDbType.VarChar, 30, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Descripcion", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@CodigoPostal", SqlDbType.VarChar, 10, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CodigoPostal", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@UltimaModificacion", SqlDbType.Timestamp, 8, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "UltimaModificacion", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdConexionUltimaModificacion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConexionUltimaModificacion", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdReservado", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdReservado", 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("@IdSucursal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdSucursal", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldIdLocalidad", SqlDbType.VarChar, 30, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdLocalidad", DataRowVersion.Original, null)); SqlCommand sqlCommandDelete = new SqlCommand("Pr_tsh_Localidades_Delete", trx.Connection); sqlCommandDelete.Transaction = trx; sqlCommandDelete.CommandType = CommandType.StoredProcedure; sqlCommandDelete.Parameters.Add(new SqlParameter("@IdLocalidad", SqlDbType.VarChar, 30, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdLocalidad", 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_tsh_Localidades_Insert", trx.Connection); sqlCommandInsert.Transaction = trx; sqlCommandInsert.CommandType = CommandType.StoredProcedure; sqlCommandInsert.Parameters.Add(new SqlParameter("@IdLocalidad", SqlDbType.VarChar, 30, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdLocalidad", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@Descripcion", SqlDbType.VarChar, 30, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Descripcion", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@CodigoPostal", SqlDbType.VarChar, 10, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CodigoPostal", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@FechaCreacion", SqlDbType.DateTime, 0, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "FechaCreacion", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdConexionCreacion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConexionCreacion", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdReservado", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdReservado", 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("@IdSucursal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdSucursal", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add("@IdGenerado", SqlDbType.VarChar, 300).Value = System.DBNull.Value; sqlCommandInsert.Parameters["@IdGenerado"].Direction = ParameterDirection.InputOutput; sqlCommandInsert.Parameters.Add("@RowIdGenerado", SqlDbType.UniqueIdentifier).Value = System.DBNull.Value; sqlCommandInsert.Parameters["@RowIdGenerado"].Direction = ParameterDirection.InputOutput; adapter.UpdateCommand = sqlCommandUpdate; adapter.DeleteCommand = sqlCommandDelete; adapter.InsertCommand = sqlCommandInsert; adapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated); adapter.Update(dataTable); }