Example #1
0
        public bool Guardar(SqlConnection cnBD, SqlTransaction trx, AsignarAlmacenBE obe)
        {
            bool   rpta     = false;
            string msjError = "";

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Almacen_AsignarAlmacen_Guardar]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Transaction    = trx;
                cmd.Parameters.Add("@Id", SqlDbType.Int).Value                       = obe.Id;
                cmd.Parameters.Add("@IdAlmacen", SqlDbType.Int).Value                = obe.IdAlmacen;
                cmd.Parameters.Add("@BoletaCompra", SqlDbType.VarChar, 20).Value     = obe.BoletaCompra;
                cmd.Parameters.Add("@RazonCompra", SqlDbType.VarChar, 250).Value     = obe.RazonCompra;
                cmd.Parameters.Add("@RucCompra", SqlDbType.VarChar, 11).Value        = obe.RucCompra;
                cmd.Parameters.Add("@DireccionCompra", SqlDbType.VarChar, 250).Value = obe.DireccionCompra;
                cmd.Parameters.Add("@loProducto", SqlDbType.Structured).Value        = CrearEstructura(obe.loProducto);
                cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value       = obe.UsrCreador;

                int    counterMarker = 0;
                object objRes        = cmd.ExecuteScalar();
                int.TryParse(objRes.ToString(), out counterMarker);
                if (counterMarker > 0)
                {
                    rpta = true;
                }
                else
                {
                    msjError = objRes.ToString();
                    rpta     = false;
                }
            }
            return(rpta);
        }
Example #2
0
        public bool GuardarTienda(SqlConnection cnBD, SqlTransaction trx, AsignarAlmacenBE obe)
        {
            bool   rpta     = false;
            string msjError = "Productos no tienen Stock en Almacén:\n";

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Almacen_AsignarAlmacen_GuardarTienda]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Transaction    = trx;
                cmd.Parameters.Add("@Id", SqlDbType.Int).Value                 = obe.Id;
                cmd.Parameters.Add("@IdAlmacen", SqlDbType.Int).Value          = obe.IdAlmacen;
                cmd.Parameters.Add("@IdTienda", SqlDbType.Int).Value           = obe.IdTienda;
                cmd.Parameters.Add("@NroGuia", SqlDbType.VarChar, 50).Value    = obe.NroGuia;
                cmd.Parameters.Add("@FechaGuia", SqlDbType.DateTime).Value     = obe.FechaGuia;
                cmd.Parameters.Add("@isCostoProduccion", SqlDbType.Bit).Value  = obe.isCostoProduccion;
                cmd.Parameters.Add("@loProducto", SqlDbType.Structured).Value  = CrearEstructura(obe.loProducto);
                cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = obe.UsrCreador;

                using (SqlDataReader drd = cmd.ExecuteReader())
                {
                    if (drd.HasRows)
                    {
                        #region parametros
                        int pos_Codigo            = drd.GetOrdinal("Codigo");
                        int pos_Stock             = drd.GetOrdinal("Stock");
                        int pos_CantidadTienda    = drd.GetOrdinal("CantidadTienda");
                        int pos_IdProductoAlmacen = drd.GetOrdinal("IdProductoAlmacen");
                        int pos_Nombre            = drd.GetOrdinal("Nombre");
                        int pos_PrecioCosto       = drd.GetOrdinal("PrecioCosto");
                        #endregion parametros
                        while (drd.Read())
                        {
                            int Codigo = drd.GetInt32(pos_Codigo);
                            if (Codigo == 1)
                            {
                                rpta = true;
                            }
                            else
                            {
                                msjError = "Nombre: " + drd.GetString(pos_Nombre) + " - Precio Unitario: " + drd.GetDecimal(pos_PrecioCosto) + "\n";
                                rpta     = false;
                            }
                        }
                    }
                }
            }
            return(rpta);
        }
        public bool GuardarTienda(AsignarAlmacenBE obe)
        {
            bool           rpta = false;
            SqlTransaction sqltrans;

            using (SqlConnection con = new SqlConnection(strCnx))
            {
                con.Open();
                sqltrans = con.BeginTransaction();
                rpta     = oAsignarAlmacenDA.GuardarTienda(con, sqltrans, obe);
                if (rpta)
                {
                    sqltrans.Commit();
                }
                else
                {
                    sqltrans.Rollback();
                }
            }
            return(rpta);
        }
Example #4
0
        public async Task <IHttpActionResult> GuardarTienda(AsignarAlmacenBE obe)
        {
            try
            {
                bool             rpta = false;
                AsignarAlmacenBL oAsignarAlmacenBL = new AsignarAlmacenBL(obe.IdCliente);
                rpta = oAsignarAlmacenBL.GuardarTienda(obe);

                if (rpta)
                {
                    return(Ok(Models.Util.GetBodyResponse(200, "OK")));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, "Ocurrió un error al guardar.")));
                }
            }
            catch (Exception ex)
            {
                //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex);
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
Example #5
0
        public List <AsignarAlmacenBE> ListarDatosIniciales(SqlConnection cnBD, string usuario, List <ListaComboBE> loAlmacen)
        {
            List <AsignarAlmacenBE> lobe = new List <AsignarAlmacenBE>();
            AsignarAlmacenBE        obe  = new AsignarAlmacenBE();

            List <AsignarAlmacen_ProductoBE> lobeP = new List <AsignarAlmacen_ProductoBE>();
            AsignarAlmacen_ProductoBE        obeP  = new AsignarAlmacen_ProductoBE();

            using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Almacen_AsignarAlmacen_Lista]", cnBD))
            {
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;
                cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value = usuario;

                using (SqlDataReader drd = cmd.ExecuteReader())
                {
                    if (drd.HasRows)
                    {
                        #region parametros
                        int pos_Id              = drd.GetOrdinal("Id");
                        int pos_IdAlmacen       = drd.GetOrdinal("IdAlmacen");
                        int pos_UsrCreador      = drd.GetOrdinal("UsrCreador");
                        int pos_FchCreacion     = drd.GetOrdinal("FchCreacion");
                        int pos_UsrModificador  = drd.GetOrdinal("UsrModificador");
                        int pos_FchModificacion = drd.GetOrdinal("FchModificacion");
                        #endregion parametros
                        lobe = new List <AsignarAlmacenBE>();
                        while (drd.Read())
                        {
                            #region variables
                            obe                 = new AsignarAlmacenBE();
                            obe.Id              = drd.GetInt32(pos_Id);
                            obe.IdAlmacen       = drd.GetInt32(pos_IdAlmacen);
                            obe.Nombre          = "";
                            obe.UsrCreador      = drd.GetString(pos_UsrCreador);
                            obe.FchCreacion     = drd.GetString(pos_FchCreacion);
                            obe.UsrModificador  = drd.GetString(pos_UsrModificador);
                            obe.FchModificacion = drd.GetString(pos_FchModificacion);
                            obe.loProducto      = new List <AsignarAlmacen_ProductoBE>();

                            int index = loAlmacen.FindIndex(det => det.codigo == obe.IdAlmacen);
                            if (index != -1)
                            {
                                obe.Nombre = loAlmacen[index].descripcion;
                                lobe.Add(obe);
                            }
                            //lobe.Add(obe);
                            #endregion variables
                        }
                    }

                    /*drd.NextResult();
                     * if (drd.HasRows)
                     * {
                     #region parametros
                     *  int pos_Id = drd.GetOrdinal("Id");
                     *  int pos_Nombre = drd.GetOrdinal("Nombre");
                     *  int pos_Cantidad = drd.GetOrdinal("Cantidad");
                     *  int pos_IdTipo = drd.GetOrdinal("IdTipo");
                     *  int pos_CantidadCaja = drd.GetOrdinal("CantidadCaja");
                     *  int pos_PrecioCosto = drd.GetOrdinal("PrecioCosto");
                     *  int pos_Selec = drd.GetOrdinal("Selec");
                     *  int pos_IdAlmacen = drd.GetOrdinal("IdAlmacen");
                     *  int pos_CantidadTienda = drd.GetOrdinal("CantidadTienda");
                     *  int pos_Precio = drd.GetOrdinal("Precio");
                     *  int pos_isBase = drd.GetOrdinal("isBase");
                     #endregion parametros
                     *  while (drd.Read())
                     *  {
                     #region variables
                     *      obeP = new AsignarAlmacen_ProductoBE();
                     *      int idAlmacen = drd.GetInt32(pos_IdAlmacen);
                     *      obeP.Id = drd.GetInt32(pos_Id);
                     *      obeP.Nombre = drd.GetString(pos_Nombre);
                     *      obeP.Cantidad = drd.GetInt32(pos_Cantidad);
                     *      obeP.CantidadTienda = drd.GetInt32(pos_CantidadTienda);
                     *      obeP.Precio = drd.GetDecimal(pos_Precio);
                     *      obeP.OldPrecio = drd.GetDecimal(pos_Precio);
                     *      obeP.Selec = drd.GetBoolean(pos_Selec);
                     *      obeP.PrecioCosto = drd.GetDecimal(pos_PrecioCosto);
                     *      obeP.idTipo = drd.GetInt32(pos_IdTipo);
                     *      obeP.CantidadCaja = drd.GetInt32(pos_CantidadCaja);
                     *      obeP.loTipoProducto = new List<ListaComboBE>();
                     *
                     *      obeP.isTipoBase = drd.GetBoolean(pos_isBase);
                     *      obeP.isTipoProducto = false;
                     *      obeP.isFechaVenProd = false;
                     *      obeP.isCostoProduccion = false;
                     #endregion variables
                     *      int index = lobe.FindIndex(det => det.IdAlmacen == idAlmacen);
                     *      if (index != -1)
                     *      {
                     *          lobe[index].loProducto.Add(obeP);
                     *      }
                     *  }
                     * }*/
                }
            }
            return(lobe);
        }