Ejemplo n.º 1
0
        /// <summary>
        /// Envia los cambios del tpu_ComprobantesDeCompraDataset a la base de datos.
        /// </summary>
        public static void Update(tpu_ComprobantesDeCompraDataset dataSet)
        {
            ApplicationAssert.Check(dataSet != null, "El argumento dataSet no debe ser nulo.", ApplicationAssert.LineNumber);
            ApplicationAssert.Check(dataSet.tpu_ComprobantesDeCompra.Rows.Count > 0, "La tabla dataSet.tpu_ComprobantesDeCompraDataTable debe poseer alguna fila.", ApplicationAssert.LineNumber);

            mz.erp.dataaccess.tpu_ComprobantesDeCompra.Update(dataSet);
        }
        public static tpu_ComprobantesDeCompraDataset.tpu_ComprobantesDeCompraRow GetByPk(string IdComprobante)
        {
            tpu_ComprobantesDeCompraDataset data = new tpu_ComprobantesDeCompraDataset();

            SqlCommand cmd = new SqlCommand("Pr_tpu_ComprobantesDeCompra_GetByPk", dbhelper.Connection.GetConnection());

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@IdComprobante", SqlDbType.VarChar));
            cmd.Parameters["@IdComprobante"].Value = IdComprobante;

            SqlDataAdapter adapter = new SqlDataAdapter(cmd);

            adapter.TableMappings.Add("Table", "tpu_ComprobantesDeCompra");

            adapter.Fill(data);

            if (data.tpu_ComprobantesDeCompra.Rows.Count == 1)
            {
                return((tpu_ComprobantesDeCompraDataset.tpu_ComprobantesDeCompraRow)data.tpu_ComprobantesDeCompra.Rows[0]);
            }

            return(null);
        }
        public static tpu_ComprobantesDeCompraDataset GetList(string IdComprobante, string IdTipoDeComprobante, string Numero, DateTime Fecha, string IdProveedor, string IdResponsable, DateTime FechaDeRegistracion, string IdTipoMovimiento, string IdSubtipoMovimiento, DateTime FechaVencimiento, long MesImputacion, long AñoImputacion, /*, DateTime FechaRecepcionMercaderia, */ string CAI, string Leyenda)
        {
            tpu_ComprobantesDeCompraDataset data = new tpu_ComprobantesDeCompraDataset();

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.TableMappings.Add("Table", "tpu_ComprobantesDeCompra");

            SqlCommand cmd = new SqlCommand("Pr_tpu_ComprobantesDeCompra_Search", dbhelper.Connection.GetConnection());

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@IdComprobante", SqlDbType.VarChar));
            if (IdComprobante == null || IdComprobante.Equals(string.Empty))
            {
                cmd.Parameters["@IdComprobante"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdComprobante"].Value = IdComprobante;
            }

            cmd.Parameters.Add(new SqlParameter("@IdTipoDeComprobante", SqlDbType.VarChar));
            if (IdTipoDeComprobante == null || IdTipoDeComprobante.Equals(string.Empty))
            {
                cmd.Parameters["@IdTipoDeComprobante"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdTipoDeComprobante"].Value = IdTipoDeComprobante;
            }
            cmd.Parameters.Add(new SqlParameter("@Numero", SqlDbType.VarChar));
            if (Numero == null || Numero.Equals(string.Empty))
            {
                cmd.Parameters["@Numero"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@Numero"].Value = Numero;
            }

            cmd.Parameters.Add(new SqlParameter("@Fecha", SqlDbType.DateTime));
            if (Fecha.Equals(DateTime.MinValue))
            {
                cmd.Parameters["@Fecha"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@Fecha"].Value = Fecha;
            }
            cmd.Parameters.Add(new SqlParameter("@IdProveedor", SqlDbType.VarChar));
            if (IdProveedor == null || IdProveedor.Equals(string.Empty))
            {
                cmd.Parameters["@IdProveedor"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdProveedor"].Value = IdProveedor;
            }
            cmd.Parameters.Add(new SqlParameter("@IdResponsable", SqlDbType.VarChar));
            if (IdResponsable == null || IdResponsable.Equals(string.Empty))
            {
                cmd.Parameters["@IdResponsable"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdResponsable"].Value = IdResponsable;
            }
            cmd.Parameters.Add(new SqlParameter("@FechaDeRegistracion", SqlDbType.DateTime));
            if (FechaDeRegistracion.Equals(DateTime.MinValue))
            {
                cmd.Parameters["@FechaDeRegistracion"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@FechaDeRegistracion"].Value = FechaDeRegistracion;
            }
            cmd.Parameters.Add(new SqlParameter("@IdTipoMovimiento", SqlDbType.VarChar));
            if (IdTipoMovimiento == null || IdTipoMovimiento.Equals(string.Empty))
            {
                cmd.Parameters["@IdTipoMovimiento"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdTipoMovimiento"].Value = IdTipoMovimiento;
            }
            cmd.Parameters.Add(new SqlParameter("@IdSubtipoMovimiento", SqlDbType.VarChar));
            if (IdSubtipoMovimiento == null || IdSubtipoMovimiento.Equals(string.Empty))
            {
                cmd.Parameters["@IdSubtipoMovimiento"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@IdSubtipoMovimiento"].Value = IdSubtipoMovimiento;
            }
            cmd.Parameters.Add(new SqlParameter("@FechaVencimiento", SqlDbType.DateTime));
            if (FechaVencimiento.Equals(DateTime.MinValue))
            {
                cmd.Parameters["@FechaVencimiento"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@FechaVencimiento"].Value = FechaVencimiento;
            }
            cmd.Parameters.Add(new SqlParameter("@MesImputacion", SqlDbType.BigInt));
            if (MesImputacion.Equals(long.MinValue))
            {
                cmd.Parameters["@MesImputacion"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@MesImputacion"].Value = MesImputacion;
            }
            cmd.Parameters.Add(new SqlParameter("@AñoImputacion", SqlDbType.BigInt));
            if (AñoImputacion.Equals(long.MinValue))
            {
                cmd.Parameters["@AñoImputacion"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@AñoImputacion"].Value = AñoImputacion;
            }

            /*
             * cmd.Parameters.Add( new SqlParameter( "@FechaRecepcionMercaderia", SqlDbType.DateTime ) );
             * cmd.Parameters[ "@FechaRecepcionMercaderia" ].Value = FechaRecepcionMercaderia;
             */
            cmd.Parameters.Add(new SqlParameter("@CAI", SqlDbType.VarChar));
            if (CAI == null || CAI.Equals(string.Empty))
            {
                cmd.Parameters["@CAI"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@CAI"].Value = CAI;
            }
            cmd.Parameters.Add(new SqlParameter("@Leyenda", SqlDbType.VarChar));
            if (Leyenda == null || Leyenda.Equals(string.Empty))
            {
                cmd.Parameters["@Leyenda"].Value = System.DBNull.Value;
            }
            else
            {
                cmd.Parameters["@Leyenda"].Value = Leyenda;
            }
            adapter.SelectCommand = cmd;

            adapter.Fill(data);

            return(data);
        }
 public static void Update(tpu_ComprobantesDeCompraDataset dataSet)
 {
     Update(dataSet.tpu_ComprobantesDeCompra);
 }
        public static tpu_ComprobantesDeCompraDataset GetList()
        {
            tpu_ComprobantesDeCompraDataset data = new tpu_ComprobantesDeCompraDataset();

            return(( tpu_ComprobantesDeCompraDataset )GetList(data));
        }
Ejemplo n.º 6
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);
                                }
                            }
                        }
                    }
                }
            }
        }