Ejemplo n.º 1
0
        public DetalleStockTienda stockActual(int id)
        {
            string sql = @"SELECT TOP 1 StockFinal FROM DetalleStockTienda WHERE idArticulo like @id ORDER BY idDetalleStockTienda DESC;";


            SqlConnection con = Conexion.Instancia().conectar();
            //SqlConnection con = new SqlConnection(Properties.Settings.Default.con);
            SqlCommand command = new SqlCommand(sql, con);

            //string hash = Helper.EncodePassword(string.Concat(usuario, password));
            //command.Parameters.AddWithValue("@password", hash);
            command.Parameters.AddWithValue("id", id);
            con.Open();

            DetalleStockTienda obj = new DetalleStockTienda();

            SqlDataReader dr = command.ExecuteReader();

            while (dr.Read())
            {
                if (dr["StockFinal"].ToString() == "")
                {
                    obj.StockFinal = 0;
                }
                else
                {
                    obj.StockFinal = (Int32)dr["StockFinal"];
                }
            }
            con.Close();
            return(obj);
        }
Ejemplo n.º 2
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text == "")
            {
                StockTienda c = new StockTienda();
                c.FechaIngresoTienda = dtpFechaIngreso.Value;
                //c.idCliente = codigoClienteSeleccionado;
                c.idUsuario = idUsuario;


                if (radActivo.Enabled == true)
                {
                    c.Estado = true;
                }
                else if (radInactivo.Enabled == true)
                {
                    c.Estado = false;
                }


                foreach (DataGridViewRow row in dgvDetalleStock.Rows)
                {
                    DetalleStockTienda de          = new DetalleStockTienda();
                    DetalleStockTienda dStockFinal = StockTiendaNEG.Instancia().ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value));


                    de.idArticulo = Convert.ToInt32(row.Cells["idArticulo"].Value);
                    DetalleIngresoAlmacen dPrecioActual = DetalleIngresoNEG.Instancia().obtenerPrecioVenta(de.idArticulo);
                    int cantidad = Convert.ToInt32(row.Cells["cantidad"].Value);
                    de.idDetalleIngresoAlmacen = dPrecioActual.idDetalleIngresoAlmacen;

                    de.StockInicial = Convert.ToInt32(row.Cells["cantidad"].Value);
                    de.StockFinal   = Convert.ToInt32(row.Cells["cantidad"].Value) + dStockFinal.StockFinal;
                    VentaNEG.Instancia().reducirStock(de.idArticulo, cantidad);
                    c.Lineas.Add(de);
                }



                StockTiendaNEG.RegistrarIngresoTienda(c);

                MessageBox.Show("El ingreso de Stock a Tienda fue exitoso.");
                this.Dispose();
            }

            else
            {
                if (radInactivo.Checked == true)
                {
                }

                this.Dispose();
            }
        }