public static tfi_InstanciasCajaExDataset GuardarArqueoCaja(tfi_InstanciasCajaExDataset data) { tfi_InstanciasCajaExDataset.Pr_tfi_InstanciasCaja_CierreCajaDataTable table = data.Pr_tfi_InstanciasCaja_CierreCaja; tfi_InstanciasCajaExDataset.tfi_InstanciasCajaCierresDataTable tableInsCajaCierre = data.tfi_InstanciasCajaCierres; if (table.Rows.Count > 0) { foreach (tfi_InstanciasCajaExDataset.Pr_tfi_InstanciasCaja_CierreCajaRow row in table.Rows) { tfi_InstanciasCajaExDataset.tfi_InstanciasCajaCierresRow rowCajaCierre = data.tfi_InstanciasCajaCierres.Newtfi_InstanciasCajaCierresRow(); // mz.erp.businessrules.tfi_InstanciasCajaCierres.NewRow(); // mz.erp.businessrules.tfi_InstanciasCajaCierres.SetRowDefaultValues(rowCajaCierre); rowCajaCierre.IdInstanciaCaja = row.IdInstanciaCaja; rowCajaCierre.IdTDCompTesoreria = row.IdTDCompTesoreria; rowCajaCierre.IdMonedaCierre = row.IdMoneda; rowCajaCierre.IdCotizacionCierre = row.IdCotizacionMoneda; rowCajaCierre.Total = row.Neto; tableInsCajaCierre.Addtfi_InstanciasCajaCierresRow(rowCajaCierre); } } else { System.Windows.Forms.MessageBox.Show("No se han realizado pagos en esta Caja hasta el momento"); } tfi_InstanciasCajaExDataset.tfi_InstanciasCajaRow rowInsCaja = (tfi_InstanciasCajaExDataset.tfi_InstanciasCajaRow)data.tfi_InstanciasCaja.Rows[0]; rowInsCaja.Cierre = mz.erp.businessrules.Sistema.DateTime.Now; Update(data); return(data); }
public static void Update(tfi_InstanciasCajaExDataset.tfi_InstanciasCajaCierresDataTable dataTable) { SqlConnection cnx = dbhelper.Connection.GetConnection();; cnx.Open(); SqlTransaction trx = cnx.BeginTransaction(IsolationLevel.Serializable); try { Update(dataTable, trx); trx.Commit(); } catch { trx.Rollback(); } finally { cnx.Close(); } }
public static void Update(tfi_InstanciasCajaExDataset.tfi_InstanciasCajaCierresDataTable dataTable, SqlTransaction trx) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.TableMappings.AddRange( new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "tfi_InstanciasCajaCierres", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("IdInstanciaCaja", "IdInstanciaCaja"), new System.Data.Common.DataColumnMapping("IdTDCompTesoreria", "IdTDCompTesoreria"), new System.Data.Common.DataColumnMapping("Total", "Total"), new System.Data.Common.DataColumnMapping("IdMonedaCierre", "IdMonedaCierre"), new System.Data.Common.DataColumnMapping("IdCotizacionCierre", "IdCotizacionCierre"), 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") } ) } ); SqlCommand sqlCommandUpdate = new SqlCommand("Pr_tfi_InstanciasCajaCierres_Update", trx.Connection); sqlCommandUpdate.Transaction = trx; sqlCommandUpdate.CommandType = CommandType.StoredProcedure; sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdInstanciaCaja", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdInstanciaCaja", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdTDCompTesoreria", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTDCompTesoreria", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@Total", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Total", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdMonedaCierre", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdMonedaCierre", DataRowVersion.Current, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdCotizacionCierre", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdCotizacionCierre", 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("@OldIdInstanciaCaja", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdInstanciaCaja", DataRowVersion.Original, null)); sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldIdTDCompTesoreria", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTDCompTesoreria", DataRowVersion.Original, null)); SqlCommand sqlCommandDelete = new SqlCommand("Pr_tfi_InstanciasCajaCierres_Delete", trx.Connection); sqlCommandDelete.Transaction = trx; sqlCommandDelete.CommandType = CommandType.StoredProcedure; sqlCommandDelete.Parameters.Add(new SqlParameter("@IdInstanciaCaja", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdInstanciaCaja", DataRowVersion.Original, null)); sqlCommandDelete.Parameters.Add(new SqlParameter("@IdTDCompTesoreria", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTDCompTesoreria", 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_tfi_InstanciasCajaCierres_Insert", trx.Connection); sqlCommandInsert.Transaction = trx; sqlCommandInsert.CommandType = CommandType.StoredProcedure; sqlCommandInsert.Parameters.Add(new SqlParameter("@IdInstanciaCaja", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdInstanciaCaja", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdTDCompTesoreria", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdTDCompTesoreria", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@Total", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Total", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdMonedaCierre", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdMonedaCierre", DataRowVersion.Current, null)); sqlCommandInsert.Parameters.Add(new SqlParameter("@IdCotizacionCierre", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdCotizacionCierre", 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)); adapter.UpdateCommand = sqlCommandUpdate; adapter.DeleteCommand = sqlCommandDelete; adapter.InsertCommand = sqlCommandInsert; adapter.Update(dataTable); }