public static void UpdateWithValidation(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row) { ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber); if (RowIsValid(row)) { Update(row); } }
public static void Update(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row) { if (row.RowState == DataRowState.Detached) { ((tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasDataTable)row.Table).Addtfi_ResponsablesCajasRow(row); } Update(row.Table); }
/// <summary> /// Obtiene un registro de la tabla tfi_ResponsablesCajas que luego puede ser persistido en la base de datos. /// </summary> public static tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow GetByPk(string IdCaja, string IdResponsable) { tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row = mz.erp.dataaccess.tfi_ResponsablesCajas.GetByPk(IdCaja, IdResponsable); foreach (DataColumn dc in row.Table.Columns) { if (row[dc] == System.DBNull.Value) { row[dc] = Util.DefaultValue(dc.DataType); } } return(row); }
/// <summary> /// Establece los valores por defecto de tfi_ResponsablesCajasRow. /// </summary> public static tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow SetRowDefaultValues(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row) { row.IdCaja = Util.NewStringId(); row.IdResponsable = Util.NewStringId(); row.FechaCreacion = mz.erp.businessrules.Sistema.DateTime.Now; row.IdConexionCreacion = Security.IdConexion; //row.UltimaModificacion = null; row.IdConexionUltimaModificacion = Security.IdConexion; row.IdReservado = 0; row.RowId = Guid.Empty; row.IdEmpresa = Security.IdEmpresa; row.IdSucursal = Security.IdSucursal; return(row); }
/// <summary> /// Valida un tfi_ResponsablesCajasRow. /// </summary> public static bool RowIsValid(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row) { ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber); bool isValid = true; string mensaje; if (!IdCajaIsValid(row.IdCaja, out mensaje)) { row.SetColumnError("IdCaja", mensaje); isValid = false; } if (!IdResponsableIsValid(row.IdResponsable, out mensaje)) { row.SetColumnError("IdResponsable", mensaje); isValid = false; } if (!FechaCreacionIsValid(row.FechaCreacion, out mensaje)) { row.SetColumnError("FechaCreacion", mensaje); isValid = false; } if (!IdConexionCreacionIsValid(row.IdConexionCreacion, out mensaje)) { row.SetColumnError("IdConexionCreacion", mensaje); isValid = false; } if (!UltimaModificacionIsValid(row.UltimaModificacion, out mensaje)) { row.SetColumnError("UltimaModificacion", mensaje); isValid = false; } if (!IdConexionUltimaModificacionIsValid(row.IdConexionUltimaModificacion, out mensaje)) { row.SetColumnError("IdConexionUltimaModificacion", mensaje); isValid = false; } if (!IdReservadoIsValid(row.IdReservado, out mensaje)) { row.SetColumnError("IdReservado", mensaje); isValid = false; } if (!RowIdIsValid(row.RowId, out mensaje)) { row.SetColumnError("RowId", mensaje); isValid = false; } if (!IdEmpresaIsValid(row.IdEmpresa, out mensaje)) { row.SetColumnError("IdEmpresa", mensaje); isValid = false; } if (!IdSucursalIsValid(row.IdSucursal, out mensaje)) { row.SetColumnError("IdSucursal", mensaje); isValid = false; } ; return(isValid); }
/// <summary> /// Envia los cambios del tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasDataTable a la base de datos. /// </summary> public static void Update(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasDataTable 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); if (TableIsValid(dataTable)) { string PerfilesSuperiores = mz.erp.businessrules.Variables.GetValueString("Seguridad.Perfiles.PerfilesSuperiores"); string IdCajaTemporalDefault = mz.erp.businessrules.Variables.GetValueString("Cajas.CajaTemporalDefault"); ArrayList PerfilesSuperioresList = mz.erp.systemframework.Util.Parse(PerfilesSuperiores); DataTable tableUsuariosSegunPerfiles = null; if (!PerfilesSuperioresList.Contains(mz.erp.businessrules.Security.IdPerfil.ToString())) { ArrayList CajasAAgregar = ObtenerCajasAAgregar(dataTable); tableUsuariosSegunPerfiles = mz.erp.businessrules.sy_Usuarios.GetUsuariosActivosSegunPerfiles(PerfilesSuperiores); foreach (DataRow rowU in tableUsuariosSegunPerfiles.Rows) { //Recupero las Cajas de la Base de datos para el usuario en cuestion ArrayList cajasUsuarioDB = mz.erp.businessrules.tfi_ResponsablesCajas.GetCajas(Convert.ToString(rowU["IdUsuario"])); foreach (string IdCaja in CajasAAgregar) { //Sino contiene la caja en la base de datos if (!cajasUsuarioDB.Contains(IdCaja)) { //Chequeo que ya no haya agregado la tupla en el dataset if (dataTable.FindByIdCajaIdResponsable(IdCaja, Convert.ToString(rowU["IdUsuario"])) == null) { tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow rowRC = dataTable.Newtfi_ResponsablesCajasRow(); mz.erp.businessrules.tfi_ResponsablesCajas.SetRowDefaultValues(rowRC); rowRC.IdResponsable = Convert.ToString(rowU["IdUsuario"]); rowRC.IdCaja = IdCaja; dataTable.Addtfi_ResponsablesCajasRow(rowRC); } } } } } mz.erp.dataaccess.tfi_ResponsablesCajas.Update(dataTable); //Elimina las filas del dataset asociadas a usuarios superiores siempre y cuando el que agrega no es un usuario superior ArrayList aux = new ArrayList(); if (!PerfilesSuperioresList.Contains(mz.erp.businessrules.Security.IdPerfil.ToString())) { foreach (DataRow row in dataTable.Rows) { foreach (DataRow rowU in tableUsuariosSegunPerfiles.Rows) { if (Convert.ToString(rowU["IdUsuario"]).Equals(Convert.ToString(row["IdResponsable"]))) { aux.Add(row); } } } foreach (DataRow rowAux in aux) { dataTable.Rows.Remove(rowAux); } } } }
/// <summary> /// Envia los cambios del tfi_ResponsablesCajasRow a la base de datos. /// </summary> public static void Update(tfi_ResponsablesCajasDataset.tfi_ResponsablesCajasRow row) { ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber); mz.erp.dataaccess.tfi_ResponsablesCajas.Update(row); }