public static void UpdateWithValidation(tpu_ComprobantesDataset.tpu_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            if (RowIsValid(row))
            {
                Update(row);
            }
        }
        public RelacionesComprobanteDeCompraOrigenDestino(ArrayList IdComprobantes)
        {
            string IdTipoDeComprobanteGral = String.Empty;

            ArrayList lista = new ArrayList(IdComprobantes);

            for (int i = 0; i < lista.Count; i++)
            {
                string IdComprobante = lista[i].ToString();
                tpu_ComprobantesDataset.tpu_ComprobantesRow CompOrigen = tpu_Comprobantes.GetByPk(IdComprobante);

                //Datos comunes a todos los items de un mismo comprobante
                string   IdTipoDeComprobante = CompOrigen.IdTipoDeComprobante;
                string   Numero         = CompOrigen.Numero;
                long     OrdinalOrigen  = -1;
                decimal  CantidadOrigen = 0;
                string   IdProducto     = String.Empty;
                string   Descripcion    = String.Empty;
                long     IdSucursal     = Security.IdSucursal;
                long     IdEmpresa      = Security.IdEmpresa;
                DateTime Fecha          = CompOrigen.Fecha;
                Decimal  PrecioDeCosto  = 0;
                this.IdProveedor   = CompOrigen.IdProveedor;
                this.IdResponsable = CompOrigen.IdResponsable;

                if (IdTipoDeComprobanteGral == String.Empty)
                {
                    IdTipoDeComprobanteGral = IdTipoDeComprobante;
                }

                //Si el tipo de Comprobante actual es distinto al tipo de comprobante del primer comprobante no hace nada (por ahora)
                if (IdTipoDeComprobante == IdTipoDeComprobanteGral)
                {
                    //Para cada IdComprobante tengo que obtener los ítems
                    //Datos del item del comprobante
                    tpu_ComprobantesDetDataset Items = businessrules.tpu_ComprobantesDet.GetByPk(IdComprobante);

                    foreach (tpu_ComprobantesDetDataset.tpu_ComprobantesDetRow row in Items.tpu_ComprobantesDet)
                    {
                        OrdinalOrigen  = row.Ordinal;
                        CantidadOrigen = row.Cantidad;

                        //Por ahora estoy tomando en CantidadOrigen la cantidad original del item. Luego tengo que hacer aparecer lo que está en tsa_ComprobantesRelacionOrigenDestino
                        IdProducto    = row.IdProducto;
                        Descripcion   = tsh_Productos.GetByPk(row.IdProducto).Descripcion;
                        PrecioDeCosto = row.PrecioDeCosto;
                        IdSucursal    = row.IdSucursal;
                        IdEmpresa     = row.IdEmpresa;
                        RelacionComprobanteDeCompraOrigenDestino ItemOrigen = new RelacionComprobanteDeCompraOrigenDestino(IdComprobante, IdTipoDeComprobante, Numero, OrdinalOrigen, CantidadOrigen, IdProducto, Descripcion, PrecioDeCosto, IdSucursal, IdEmpresa);
                        this.Add(ItemOrigen);
                    }
                }
            }
            //
            // TODO: agregar aquí la lógica del constructor
            //
        }
        public static void Update(tpu_ComprobantesDataset.tpu_ComprobantesRow row)
        {
            if (row.RowState == DataRowState.Detached)
            {
                ((tpu_ComprobantesDataset.tpu_ComprobantesDataTable)row.Table).Addtpu_ComprobantesRow(row);
            }

            Update(row.Table);
        }
 /// <summary>
 /// Obtiene un registro de la tabla tpu_Comprobantes que luego puede ser persistido en la base de datos.
 /// </summary>
 public static tpu_ComprobantesDataset.tpu_ComprobantesRow GetByPk(string IdComprobante)
 {
     tpu_ComprobantesDataset.tpu_ComprobantesRow row = mz.erp.dataaccess.tpu_Comprobantes.GetByPk(IdComprobante);
     if (row != null)
     {
         foreach (DataColumn dc in row.Table.Columns)
         {
             if (row[dc] == System.DBNull.Value)
             {
                 row[dc] = Util.DefaultValue(dc.DataType);
             }
         }
     }
     return(row);
 }
        public static tpu_ComprobantesDataset.tpu_ComprobantesRow SetRowDefaultValues(tpu_ComprobantesDataset.tpu_ComprobantesRow row)
        {
            row.IdComprobante       = Util.NewStringId();
            row.IdSucursal          = 0;
            row.IdEmpresa           = 0;
            row.IdInstanciaCaja     = string.Empty;
            row.IdTipoDeComprobante = string.Empty;
            row.Numero                       = string.Empty;
            row.Fecha                        = mz.erp.businessrules.Sistema.DateTime.Now;
            row.IdProveedor                  = string.Empty;
            row.IdResponsable                = string.Empty;
            row.Total                        = 0;
            row.IdCotizacionCierre           = string.Empty;
            row.IdMonedaCierre               = string.Empty;
            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.Proveedor                = string.Empty;
            row.Domicilio                = string.Empty;
            row.TipoDocumento            = string.Empty;
            row.Documento                = string.Empty;
            row.Observaciones            = string.Empty;
            row.Aux1                     = string.Empty;
            row.Aux2                     = string.Empty;
            row.Aux3                     = string.Empty;
            row.Aux4                     = 0;
            row.FechaDeRegistracion      = mz.erp.businessrules.Sistema.DateTime.Now;
            row.FechaRecepcionMercaderia = mz.erp.businessrules.Sistema.DateTime.Now;
            row.Estado                   = string.Empty;
            row.IdCondicionDeCompra      = string.Empty;
            row.IdAutorizacion           = string.Empty;


            return(row);
        }
        /// <summary>
        /// Valida un tpu_ComprobantesRow.
        /// </summary>
        public static bool RowIsValid(tpu_ComprobantesDataset.tpu_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);
            bool   isValid = true;
            string mensaje;


            if (!IdComprobanteIsValid(row.IdComprobante, out mensaje))
            {
                row.SetColumnError("IdComprobante", 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;
            }

            if (!IdInstanciaCajaIsValid(row.IdInstanciaCaja, out mensaje))
            {
                row.SetColumnError("IdInstanciaCaja", mensaje);
                isValid = false;
            }

            if (!IdTipoDeComprobanteIsValid(row.IdTipoDeComprobante, out mensaje))
            {
                row.SetColumnError("IdTipoDeComprobante", mensaje);
                isValid = false;
            }

            if (!NumeroIsValid(row.Numero, out mensaje))
            {
                row.SetColumnError("Numero", mensaje);
                isValid = false;
            }

            if (!FechaIsValid(row.Fecha, out mensaje))
            {
                row.SetColumnError("Fecha", mensaje);
                isValid = false;
            }

            if (!IdProveedorIsValid(row.IdProveedor, out mensaje))
            {
                row.SetColumnError("IdProveedor", mensaje);
                isValid = false;
            }

            if (!IdResponsableIsValid(row.IdResponsable, out mensaje))
            {
                row.SetColumnError("IdResponsable", mensaje);
                isValid = false;
            }

            if (!TotalIsValid(row.Total, out mensaje))
            {
                row.SetColumnError("Total", mensaje);
                isValid = false;
            }


            if (!IdMonedaCierreIsValid(row.IdMonedaCierre, out mensaje))
            {
                row.SetColumnError("IdMonedaCierre", mensaje);
                isValid = false;
            }

            if (!IdCotizacionCierreIsValid(row.IdCotizacionCierre, out mensaje))
            {
                row.SetColumnError("IdCotizacionCierre", mensaje);
                isValid = false;
            }
            if (!FechaRecepcionMercaderiaIsValid(row.FechaRecepcionMercaderia, out mensaje))
            {
                row.SetColumnError("FechaRecepcionMercaderia", 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;
             *
             * }
             * ;*/

            return(isValid);
        }
        /// <summary>
        /// Envia los cambios del tpu_ComprobantesRow a la base de datos.
        /// </summary>
        public static void Update(tpu_ComprobantesDataset.tpu_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            mz.erp.dataaccess.tpu_Comprobantes.Update(row);
        }
Beispiel #8
0
        public void Commit()
        {
            _dataComprobante                = new tpu_ComprobantesDataset();
            _dataComprobanteDeCompra        = new tpu_ComprobantesDeCompraDataset();
            _dataComprobanteDetalleDeuda    = new tpu_ComprobanteDetalleDeudaDataset();
            _dataComprobantesDet            = new tpu_ComprobantesDetDataset();
            _dataComprobantesDetalleDePagos = new tpu_ComprobanteDetalleDePagosDataset();

            foreach (string _idComprobanteAAnular in _idComprobantesAAnular)
            {
                if (_idComprobanteAAnular != null && _idComprobanteAAnular != string.Empty)
                {
                    tpu_ComprobantesDataset.tpu_ComprobantesRow rowAux = businessrules.tpu_Comprobantes.GetByPk(_idComprobanteAAnular);
                    if (rowAux != null)
                    {
                        string IdTipoDeComprobante = rowAux.IdTipoDeComprobante;
                        if (_tableComprobantesAnulacion.ContainsKey(IdTipoDeComprobante))
                        {
                            string IdTipoDeComprobanteAnula = Convert.ToString(_tableComprobantesAnulacion[IdTipoDeComprobante]);

                            /*tpu_Comprobantes*/
                            tpu_ComprobantesDataset.tpu_ComprobantesRow rowC = mz.erp.businessrules.tpu_Comprobantes.GetByPk(_idComprobanteAAnular);
                            rowC.IdTipoDeComprobante = IdTipoDeComprobanteAnula;
                            _dataComprobante.tpu_Comprobantes.ImportRow((DataRow)rowC);

                            /*tpu_ComprobantesDeCompra*/
                            tpu_ComprobantesDeCompraDataset.tpu_ComprobantesDeCompraRow rowCC = mz.erp.businessrules.tpu_ComprobantesDeCompra.GetByPk(_idComprobanteAAnular);
                            if (rowCC != null)
                            {
                                rowCC["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
                                _dataComprobanteDeCompra.tpu_ComprobantesDeCompra.ImportRow(rowCC);
                            }

                            /*tpu_ComprobantesDet*/
//							tpu_ComprobantesDetDataset  dataCD = mz.erp.businessrules.tpu_ComprobantesDet.GetByPk(_idComprobanteAAnular);
//							foreach (DataRow row in dataCD.tpu_ComprobantesDet.Rows)
//							{
//								if (row != null)
//								{
//									row["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
//									_dataComprobantesDet.tpu_ComprobantesDet.ImportRow(row);
//								}
//							}



                            /*tpu_ComprobanteDetalleDePagos*/
                            tpu_ComprobanteDetalleDePagosDataset dataCDP = mz.erp.businessrules.tpu_ComprobanteDetalleDePagos.GetList(null, null, _idComprobanteAAnular, null, decimal.MinValue);
                            foreach (DataRow row in dataCDP.tpu_ComprobanteDetalleDePagos.Rows)
                            {
                                if (row != null)
                                {
                                    row["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
                                    _dataComprobantesDetalleDePagos.tpu_ComprobanteDetalleDePagos.ImportRow(row);
                                }
                            }


                            /*tpu_ComprobanteDetalleDeuda*/
                            //tpu_ComprobanteDetalleDeudaDataset dataCDD = mz.erp.businessrules.tpu_ComprobanteDetalleDeuda.GetList(_idComprobanteAAnular, null, null);
                            DataSet dataCDD = mz.erp.businessrules.tpu_ComprobanteDetalleDeuda.GetList(_idComprobanteAAnular, null, null);
                            foreach (DataRow row in dataCDD.Tables[0].Rows) //foreach(DataRow row in dataCDD.tpu_ComprobanteDetalleDeuda.Rows)
                            {
                                if (row != null)
                                {
                                    row["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
                                    _dataComprobanteDetalleDeuda.tpu_ComprobanteDetalleDeuda.ImportRow(row);
                                }
                            }
                        }
                    }
                }
            }
        }