コード例 #1
0
 public void AddStock(Stock stock)
 {
     if (!(Stocks.Exists(s => s.Symbol == stock.Symbol)))            //If doesn't exist, add stock to list.
     {
         Stocks.Add(stock);
     }
 }
コード例 #2
0
        public IHttpActionResult PutStocks(int id, Stocks stocks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stocks.BranchOfficesID)
            {
                return(BadRequest());
            }

            db.Entry(stocks).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StocksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public void RemoveProduct(int productId)
        {
            FileStream locker = _FileLocker.LockObj(_productAndStockLockerFile);

            var product = FindProductInner(productId);

            try
            {
                if (product != null)
                {
                    GetStocks();

                    var stock = Stocks.FirstOrDefault(s => s.ProductId == productId);

                    if (stock != null)
                    {
                        throw new InvalidOperationException("Cannot remove product which is still in stock.");
                    }
                    if (!Products.ProductList.Remove(product))
                    {
                        throw new InvalidOperationException("Unknow problem.");
                    }
                }
                else
                {
                    throw new IndexOutOfRangeException($"Product {productId} does not exist.");
                }

                _jsonHandler.SaveRecords(_productFile, Products);
            }
            finally
            {
                _FileLocker.UnlockObj(locker);
            }
        }
コード例 #4
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
                return;

            IsBusy = true;

            try
            {
                Stocks.Clear();
                var stocks = await StockDataStore.GetStocksAsync();
                foreach (var stock in stocks)
                {
                    Stocks.Add(stock);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #5
0
        private void StockPost()
        {
            string dr        = Request["directsupplier"];
            int    kioskid   = Convert.ToInt32(Request["kioskid"]);
            int    stocklist = Convert.ToInt32(Request["stocklist"]);
            int    prodid    = Convert.ToInt32(Request["prodid"]);
            string checkby   = Request["checkby"];


            bool isUpdate = true;
            JsonBridge <String> StocksUpdated = new JsonBridge <String>();

            try
            {
                Stocks.SetStocksByRefKiosdidProdid(dr, kioskid, stocklist, prodid, checkby);
            }
            catch (Exception)
            {
                isUpdate = false;
            }

            StocksUpdated.Valid = isUpdate == true ? 1 : 0;
            string output = JsonConvert.SerializeObject(StocksUpdated);

            Response.Write(output);
        }
コード例 #6
0
        /// <summary>
        /// Insert Stocks
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>Message</returns>
        public async Task <string> InsertStocks(Stocks entity)
        {
            var result = string.Empty;

            try
            {
                StockDetails stockdetail = new StockDetails();
                var          dataProduct = new StocksRepository(logger).GetAll().Result.FirstOrDefault(c => c.ProductId.Equals(entity.ProductId));
                stockdetail.StockQuantity     = dataProduct.Quantity;
                stockdetail.TransQuantity     = decimal.Subtract(dataProduct.Quantity, entity.Quantity);
                stockdetail.TotalQuantity     = entity.Quantity;
                stockdetail.Date              = entity.Date;
                stockdetail.PurcheaseId       = entity.PurcheaseId;
                stockdetail.SalesId           = entity.SalesId;
                stockdetail.PurcheaseReturnId = entity.PurcheaseReturnId;
                stockdetail.SalesReturnId     = entity.SalesReturnId;
                stockdetail.StockStutes       = entity.StockStutes;
                result = await new StockDetailsBL(logger).InsertStockDetails(stockdetail);
                result = await new StocksRepository(logger).Insert(entity);
                return(result);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                throw ex;
            }
        }
コード例 #7
0
        public IHttpActionResult PostStocks(Stocks stocks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            foreach (Stocks s in db.Stocks)
            {
                // Check if symbol already present
                if (s.Symbol == stocks.Symbol)
                {
                    return(Ok(new { response = "false", error = "Symbol already exists." }));
                }


                // Check if same name stock already present
                if (s.Name == stocks.Name)
                {
                    return(Ok(new { response = "false", error = "Stock Name already exists." }));
                }
            }

            db.Stocks.Add(stocks);
            db.SaveChanges();

            return(Ok(new { response = "true" }));
        }
コード例 #8
0
        /// <summary>
        /// 修改【---事务---】
        /// </summary>
        /// <param name="dp"></param>
        /// <returns></returns>
        public static int EdiStocks(Stocks dp, List <StockDetail> list)
        {
            PSSEntities db = new PSSEntities();
            int         fg = 1;

            ///以下开始事务操作
            using (var tx = db.Database.BeginTransaction())
            {
                try
                {
                    //将要修改的创建人找回来,避免修改时没有创建人
                    Stocks st = db.Stocks.FirstOrDefault(p => p.StockID == dp.StockID);
                    st.PPID        = dp.PPID;
                    st.StockDate   = dp.StockDate;
                    st.StockInDate = dp.StockInDate;
                    st.StockDesc   = dp.StockDesc;
                    db.StockDetail.RemoveRange(db.StockDetail.Where(p => p.StockID == dp.StockID));
                    if (list != null)
                    {
                        db.StockDetail.AddRange(list);
                    }

                    db.SaveChanges();
                    tx.Commit();
                }
                catch (Exception e)
                {
                    fg = 0;
                    tx.Rollback();
                    throw new Exception(e.Message);
                }
            }
            return(fg);
        }
コード例 #9
0
        /// <summary>
        /// 添加【---事务---】
        /// </summary>
        /// <param name="dep"></param>
        /// <returns></returns>
        public static int AddStocks(Stocks dep, List <StockDetail> list)
        {
            PSSEntities db = new PSSEntities();
            int         fg = 1;

            using (var tx = db.Database.BeginTransaction())
            {
                try
                {
                    db.Stocks.Add(dep);
                    if (list != null)
                    {
                        db.StockDetail.AddRange(list);
                    }

                    db.SaveChanges();
                    tx.Commit();
                }
                catch (Exception e)
                {
                    fg = 0;
                    tx.Rollback();
                    throw new Exception(e.Message);
                }
            }
            return(fg);
        }
コード例 #10
0
        public IHttpActionResult PostStocks(Stocks stocks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Stocks.Add(stocks);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (StocksExists(stocks.BranchOfficesID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = stocks.BranchOfficesID }, stocks));
        }
コード例 #11
0
        public void Upcasting()
        {
            Stocks msft = new Stocks();
            Asset  a    = msft; // Upcast

            Assert.AreEqual(msft, a);
        }
コード例 #12
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "item")
     {
         print(gameObject.name);
         Vector2 itemVelocity = collision.relativeVelocity;
         if (collision.gameObject.GetComponent <ItemCollision>().team == enemyTeam)
         {
             Destroy(gameObject);
             Stocks.playerDeath(team);
             SceneManager.LoadScene(0);
         }
         else
         {
             //if (itemVelocity.magnitude >= 7.1)
             //{
             //	print("item collided: " + collision.gameObject.name + "at speed: " + itemVelocity);
             //	//Destroy(gameObject);
             //}
             //else
             //{
             collision.gameObject.GetComponent <ItemCollision>().team = team;
             //}
         }
     }
 }
コード例 #13
0
        static void Main(string[] args)
        {
            Stocks myStocks = new Stocks();

            myStocks.totalPortfolio();
            myStocks.printPortfolio();
        }
コード例 #14
0
        public void BatchDeleteTest()
        {
            Stocks v1 = new Stocks();
            Stocks v2 = new Stocks();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.StockID       = "zMLdzudA";
                v1.ProductLendID = AddProductLend();
                v1.StockState    = SCMSupplyChain.Model.StockState.未定义3;
                v1.StockDesc     = "NQ7jFRM5";
                v2.StockID       = "YWm";
                v2.ProductLendID = v1.ProductLendID;
                v2.StockState    = SCMSupplyChain.Model.StockState.未定义2;
                v2.StockDesc     = "uxh0Fw";
                context.Set <Stocks>().Add(v1);
                context.Set <Stocks>().Add(v2);
                context.SaveChanges();
            }

            var rv = _controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data1 = context.Set <Stocks>().Find(v1.ID);
                var data2 = context.Set <Stocks>().Find(v2.ID);
                Assert.AreEqual(data1.IsValid, false);
                Assert.AreEqual(data2.IsValid, false);
            }

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
コード例 #15
0
 public OptimizableCategory Copy() => new OptimizableCategory
 {
     Name            = Name,
     Categories      = Categories?.Select(c => c.Copy()).ToList(),
     Stocks          = Stocks?.Select(s => s.Copy()).ToList(),
     AllocatedAmount = AllocatedAmount
 };
コード例 #16
0
        public void notify(StartWatchingSymbol message)
        {
            var presenter = new StockViewModel(symbol: message.Symbol, builder: builder);

            presenter.present();
            Stocks.Add(presenter);
        }
コード例 #17
0
        public async Task <ActionResult <Stocks> > PostStocks(Stocks stocks)
        {
            _context.Stocks.Add(stocks);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStocks", new { id = stocks.StockId }, stocks));
        }
コード例 #18
0
        public void CreateTest()
        {
            StocksVM vm = _controller.Wtm.CreateVM <StocksVM>();
            Stocks   v  = new Stocks();

            v.StockID       = "zMLdzudA";
            v.ProductLendID = AddProductLend();
            v.StockState    = SCMSupplyChain.Model.StockState.未定义3;
            v.StockDesc     = "NQ7jFRM5";
            vm.Entity       = v;
            var rv = _controller.Add(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Stocks>().Find(v.ID);

                Assert.AreEqual(data.StockID, "zMLdzudA");
                Assert.AreEqual(data.StockState, SCMSupplyChain.Model.StockState.未定义3);
                Assert.AreEqual(data.StockDesc, "NQ7jFRM5");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
コード例 #19
0
        public FrmEditProductLine(ModelViewProductLine productLine, bool newProductLine)
        {
            InitializeComponent();
            _newProductLine = newProductLine;
            ProductLineOut  = productLine;
            var repositoryStock   = new RepositoryStock();
            var repositoryProduit = new RepositoryProduct();

            _editProductLinePresenter = new EditProductLinePresenterPage(this, repositoryStock, repositoryProduit);
            _editProductLinePresenter.Display();

            comboBoxStock.DisplayMember   = "Name";
            comboBoxStock.ValueMember     = "Name";
            comboBoxProduit.DataSource    = Products;
            comboBoxProduit.DisplayMember = "Name";
            comboBoxProduit.ValueMember   = "Name";

            if (!newProductLine)
            {
                comboBoxStock.DataSource = Stocks.Where(s => s.Name == productLine.Stock.Name).ToList();
                //comboBoxStock.SelectedValue = productLine.Stock.Name;
                comboBoxProduit.SelectedValue = productLine.Name;
                textEditQuantité.Text         = productLine.Quantity.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                comboBoxStock.DataSource = Stocks.OrderBy(s => s.Name).ToList();
            }

            IsProductLineModified = false;
        }
コード例 #20
0
        public async Task <IActionResult> PutStocks(int id, Stocks stocks)
        {
            if (id != stocks.StoreId)
            {
                return(BadRequest());
            }

            _context.Entry(stocks).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StocksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #21
0
        public async Task <IActionResult> Edit(int id, [Bind("IdStock,FkProduct,Amount,FkStorehouse,Status")] Stocks stocks)
        {
            if (id != stocks.IdStock)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stocks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StocksExists(stocks.IdStock))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkProduct"]    = new SelectList(_context.Products, "IdProduct", "Name", stocks.FkProduct);
            ViewData["FkStorehouse"] = new SelectList(_context.Storehouses, "IdStorehouse", "IdStorehouse", stocks.FkStorehouse);
            return(View(stocks));
        }
コード例 #22
0
        public async Task <IActionResult> Create([Bind("IdStock,FkProduct,Amount,FkStorehouse,Status")] Stocks stocks)
        {
            ViewBag.COOKIE_LOGGED_USERNAME = Request.Cookies["COOKIE_LOGGED_USERNAME"];

            bool alreadyExists = _context.Stocks.Where(s => s.FkProduct == stocks.FkProduct && s.FkStorehouse == stocks.FkStorehouse).Count() > 0;

            if (alreadyExists)
            {
                ViewBag.Message = "Cannot create! Such stock already exists!";
            }

            if (!ModelState.IsValid || alreadyExists)
            {
                ViewData["FkProduct"]    = new SelectList(_context.Products, "IdProduct", "Name", stocks.FkProduct);
                ViewData["FkStorehouse"] = new SelectList(_context.Storehouses, "IdStorehouse", "IdStorehouse", stocks.FkStorehouse);
                return(View(stocks));
            }

            try
            {
                stocks.IdStock = _context.Stocks.Max(s => s.IdStock) + 1;
            }
            catch (Exception e)
            {
                stocks.IdStock = 1;
            }
            _context.Add(stocks);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #23
0
        public async Task <IActionResult> Edit(int id, [Bind("StoreId,ProductId,Quantity")] Stocks stocks)
        {
            if (id != stocks.StoreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stocks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StocksExists(stocks.StoreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", stocks.ProductId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", stocks.StoreId);
            return(View(stocks));
        }
コード例 #24
0
        public void StockTestTrue()
        {
            Stocks instance = Stocks.Instance;
            bool   target   = instance.UpdateStocks(3, 2, 2, 2, 2, 2);

            Assert.AreEqual(true, target);
        }
コード例 #25
0
ファイル: MainFormAdmin.cs プロジェクト: JoseGamerPT/Retail2
        private void PictureBox4_Click(object sender, EventArgs e)
        {
            if (tabstock == false)
            {
                PictureBox picBox = (PictureBox)(sender);
                picBox.BorderStyle = BorderStyle.Fixed3D;
                tabstock           = true;

                if (f4 == null)
                {
                    Stocks f = new Stocks();
                    f.TopLevel = false;
                    panel1.Controls.Add(f);
                    f.Show();
                    f4 = f;
                }
                else
                {
                    f4.Show();
                }
            }
            else
            {
                PictureBox picBox = (PictureBox)(sender);
                picBox.BorderStyle = BorderStyle.None;
                tabstock           = false;
                f4.Hide();
            }
        }
コード例 #26
0
        async Task ExecuteLoadStocksCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Stocks.Clear();
                var stocks = await StoreDataStore.GetStoreStocksAsync(App.currentStore.StoreId, true);

                foreach (var stock in stocks)
                {
                    Stocks.Add(stock);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #27
0
        /// <summary>
        /// 借货单归还调整 Allocated 的方法
        /// </summary>
        /// <param name="model">传入的批次信息</param>
        /// <param name="InUser">操作人</param>
        /// <param name="DocumentNumber">操作的单据号</param>
        /// <param name="Type">操作的单据类型</param>
        /// <param name="Action">操作的单据的动作</param>
        /// <param name="result">操作是否成功</param>
        /// <param name="OriginalInventoryBatchDetailsInfolist">ST表对应的原由单据信息</param>
        /// <returns>返回值</returns>
        private void InnerReturndMethod(List <InventoryBatchDetailsInfo> model, int inputDocumentNumber, string inputType, string inputAction)
        {
            string inputInUser = ServiceContext.Current.UserDisplayName;

            #region 将原由的数据作废
            //将原有的单据 占用的库存调回去( 只调整损单占用的库存就可以了  因为 益单是不占用库存的)
            if (model != null && model.Count > 0)
            {
                #region 拼接 损单调整占用库存的XML 消息
                List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>();
                foreach (var item in model)
                {
                    ItemBatchInfo itemBatchInfo = new ItemBatchInfo();
                    itemBatchInfo.BatchNumber   = item.BatchNumber;
                    itemBatchInfo.ProductNumber = item.ProductSysNo.ToString();

                    Stock stock = new Stock();
                    stock.Quantity        = item.ReturnQty.ToString(); //归还调整 批次商品 的库存
                    stock.WarehouseNumber = item.StockSysNo.ToString();
                    List <Stock> StockList = new List <Stock>();
                    StockList.Add(stock);

                    Stocks stocks = new Stocks();
                    stocks.Stock = StockList;

                    itemBatchInfo.Stocks = stocks;
                    itemBatchInfoList.Add(itemBatchInfo);
                }
                BatchXMLMessage batchXMLMessage = new BatchXMLMessage()
                {
                    Header = new InventoryHeader
                    {
                        NameSpace          = "http://soa.newegg.com/InventoryProfile",
                        Action             = inputAction,
                        Version            = "V10",
                        Type               = "Lend",
                        CompanyCode        = "8601",
                        Tag                = inputType + "" + inputAction,
                        Language           = "zh-CN",
                        From               = "IPP",
                        GlobalBusinessType = "Listing",
                        StoreCompanyCode   = "8601",
                        TransactionCode    = inputDocumentNumber.ToString()
                    },
                    Body = new InventoryBody
                    {
                        InUser        = inputInUser,
                        Number        = inputDocumentNumber.ToString(),
                        ItemBatchInfo = itemBatchInfoList
                    }
                };
                string      paramXml = SerializationUtility.XmlSerialize(batchXMLMessage);
                XmlDocument xmlD     = new XmlDocument();
                xmlD.LoadXml(paramXml);
                paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">";
                #endregion
                ObjectFactory <IInventoryAdjustDA> .Instance.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量
            }
            #endregion
        }
コード例 #28
0
ファイル: Presenter.cs プロジェクト: chichur/warehouse
        // обработчик события установки площадок
        private void OnSetPlatforms(Object sender, EventArgs e)
        {
            int?[][] platformView = _view.Platforms;
            using (warehousedbContext db = new warehousedbContext())
            {
                for (int i = 0; i < platformView.Length; i++)
                {
                    // иницилизируем запись для каждого пикета
                    Platforms platform = new Platforms {
                        Cargo = 0
                    };                                                // начальный груз 0
                    for (int j = 0; j < platformView[i].Length; j++)
                    {
                        Stocks stock = new Stocks
                        {
                            NameStock            = "Склад 1",
                            IdPlatformNavigation = platform, // присваиваем ссылку на площадку
                            Picket = platformView[i][j],
                        };

                        db.Stocks.Add(stock); // добавляем в контекст
                    }
                }
                try
                {
                    db.SaveChanges(); // сохраняем изменения в бд
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
            }

            UpdateView();
        }
コード例 #29
0
 public void AddMultipleStockItems(Stocks stocks)
 {
     foreach (var stock in stocks.Stock)
     {
         AddOutletStock(stock);
     }
 }
コード例 #30
0
        /// <summary>
        /// Insert Purchases
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>Message</returns>
        public async Task <string> InsertPurchases(Purchases entity)
        {
            var result = string.Empty;

            using (TransactionScope txScope = new TransactionScope())
            {
                try
                {
                    IEnumerable <Purchases> pud = new List <Purchases>();
                    pud = new PurchasesRepository(logger).GetAll().Result;
                    if (pud.Any(c => c.InvoiecNo.Equals(entity.InvoiecNo)))
                    {
                        throw new ArgumentNullException("Already this InvoiecNo is exist!", "");
                    }
                    var pudid = 1;
                    if (pud.Any())
                    {
                        pudid = pud.Last().Id + 1;
                    }
                    entity.Id = pudid;
                    result    = await new PurchasesRepository(logger).Insert(entity);
                    foreach (var data in entity.PurcheaseDetails)
                    {
                        data.PurchaseId = pudid;
                        result          = await new PurcheaseDetailsRepository(logger).Insert(data);
                        var stockdata = new StocksRepository(logger).GetAll().Result.FirstOrDefault(c => c.ProductId.Equals(data.ProductId));
                        if (stockdata != null)
                        {
                            if (stockdata.Quantity < data.Quantity)
                            {
                                stockdata.Quantity = decimal.Add(stockdata.Quantity, data.Quantity);;
                            }
                            else if (stockdata.Quantity > data.Quantity)
                            {
                                stockdata.Quantity = decimal.Subtract(stockdata.Quantity, data.Quantity);
                            }
                            stockdata.FinalUnitPrice = data.UnitePrice;
                            result = await new StocksRepository(logger).Update(stockdata);
                        }
                        else
                        {
                            Stocks svm = new Stocks {
                                ProductId = data.ProductId, FinalUnitPrice = data.UnitePrice, Quantity = data.Quantity
                            };
                            result = await new StocksRepository(logger).Insert(svm);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    result = "Fail~" + ex.Message.ToString();
                    throw ex;
                }
                finally {
                    txScope.Complete();
                }
            }
            return(result);
        }
コード例 #31
0
ファイル: CS.aspx.cs プロジェクト: tractozone/halconet_2016
    public static List<Stocks> ConsultaStocks(string DescripArticulo, int TipoConsulta, int BDescripcion)
    {
        Stocks objStock = new Stocks();
        List<Stocks> lstStock = new List<Stocks>();

        string CodArticulo = "--------------------";
        if (BDescripcion == 1)
            CodArticulo = ObtenerCodigo(8, DescripArticulo);
        else
            CodArticulo = DescripArticulo;

        SqlConnection connection = new SqlConnection(connectionStringPJ);

        SqlCommand command = new SqlCommand("PJ_CalculoUtilidad", connection);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@TipoConsulta", TipoConsulta);
        command.Parameters.AddWithValue("@Articulo", CodArticulo);
        command.Parameters.AddWithValue("@PrecioCompra", 0.0);

        connection.Open();
        using (SqlDataReader sdr = command.ExecuteReader())
        {
            while (sdr.Read())
            {
                objStock = new Stocks();
                objStock.Almacen = sdr["Almacen"].ToString();
                objStock.Stock = Convert.ToDecimal(sdr["Stock"]).ToString("N0");
                objStock.Solicitado = Convert.ToDecimal(sdr["Solicitado"]).ToString("N0");
                lstStock.Add(objStock);
            }
        }
        connection.Close();
        return lstStock;

    }
コード例 #32
0
ファイル: StockQuotesBuilder.cs プロジェクト: mjheller/Folio
        public Stocks createQuotes (string m_symbol)
        {
            const string stringForSearchData = "&f=sl1d1t1c1hgvbap2";
            Stocks stocks = new Stocks();
            
            stocks.companies = m_symbol.Replace(",", " ").Split(' ');
            // Update the textbox value.
            //txtSymbol.Value = m_symbol;

            if (m_symbol.Trim() != "")
            {
                try
                {
                    // Return the stock quote data in XML format.
                    string symbol = m_symbol.Trim();
                    // Use Yahoo finance service to download stock data from Yahoo
                    string yahooURL = @"http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol + stringForSearchData;
                    string[] symbols = symbol.Replace(",", " ").Split(' ');

                        // Initialize a new WebRequest.
                    HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(yahooURL);
                    // Get the response from the Internet resource.
                    HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
                    while (webresp == null)
                    {
                        webresp = (HttpWebResponse)webreq.GetResponse();
                    }
                    // Read the body of the response from the server.
                    StreamReader strm = new StreamReader(webresp.GetResponseStream(), Encoding.ASCII);

                    // Build our data model.
                    string content = "";
                    for (int i = 0; i < symbols.Length; i++)
                    {
                        Quote quote = new Quote();
                        if (symbols[i].Trim() == "")
                            continue;

                        content = strm.ReadLine().Replace("\"", "");
                        string[] contents = content.ToString().Split(',');
                        // If contents[2] = "N/A". the stock symbol is invalid.
                        if (contents[2] == "N/A")
                        {
                            quote.Symbol = symbols[i].ToUpper() + " is invalid";
                            quote.Last = "N/A";
                            quote.Date = "N/A";
                            quote.Time = "N/A";
                            quote.Change = "N/A";
                            quote.High = "N/A";
                            quote.Low = "N/A";
                            quote.Volume = "N/A";
                            quote.Volume = "N/A";
                            quote.Ask = "N/A";
                            quote.Ask += "N/A";
                        }
                        else
                        {
                            // Build model.
                            quote.Symbol = contents[0];
                            try
                            {
                                quote.Last = String.Format("{0:c}", Convert.ToDouble(contents[1]));
                            }
                            catch
                            {
                                quote.Last = contents[1];
                            }
                            quote.Date = contents[2];
                            quote.Time = contents[3];
                            if (contents[4].Trim().Substring(0, 1) == "-")
                                quote.Change = contents[4] + "(" + contents[10] + ")";
                            else if (contents[4].Trim().Substring(0, 1) == "+")
                                quote.Change += contents[4] + "(" + contents[10] + ")";
                            else
                                quote.Change += contents[4] + "(" +
                                       contents[10] + ")";
                            quote.High = contents[5];
                            quote.Low = contents[6];
                            try
                            {
                                quote.Volume = String.Format("{0:0,0}", Convert.ToInt64(contents[7]));
                            }
                            catch
                            {
                                quote.Volume = contents[7];
                            }
                            quote.Ask = contents[8];
                            quote.Bid = contents[9];

                        }
                        stocks.stocks.Add(quote);
                    }
                    strm.Close();
                }
                catch
                {
                    return null;
                }
            }
            return stocks;
        }
コード例 #33
0
 //��ѯ��Ŀǰ���п��
 public List<Stocks> SelectStocksAllForList()
 {
     DataTable dt = new DataTable();
     dt = ReadTableOrderByXXId("Stocks", "ProductSn");
     List<Stocks> listStocks = new List<Stocks>();
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         Stocks stock = new Stocks();
         stock.ProductId = Convert.ToInt16(dt.Rows[i][0].ToString());
         stock.WarehouseId = Convert.ToInt16(dt.Rows[i][1].ToString());
         stock.Remain = Convert.ToInt16(dt.Rows[i][2].ToString());
         stock.Lasttime = Convert.ToDateTime(dt.Rows[i][3].ToString());
         stock.ProductSn = dt.Rows[i][4].ToString();
         stock.ProductName = dt.Rows[i][5].ToString();
         listStocks.Add(stock);
     }
     return listStocks;
 }
コード例 #34
0
ファイル: ShopHelper.cs プロジェクト: Orthak/QuestForAKingdom
 public ShopHelper(Stocks theStock, MainForm theMain, MainHelper _mainHelper)
 {
     stocks = theStock;
     main = theMain;
     mainHelper = _mainHelper;
 }