Ejemplo n.º 1
0
        public bool GenerateStocktakingDetailInfo(StockModel sb, int Status, SqlTransaction st)
        {
            StringBuilder sqlstrsb = new StringBuilder($" Insert into StocktakingBillDetail SELECT {sb.StocktakingID} AS Sbd_Sb_Id, s.Sto_Com_ID AS Sbd_Com_Id, s.Sto_Sku_Id AS Sbd_Sku_Id, s.Sto_Gal_Id AS Sbd_Gal_Id, SUM(s.Sto_PackingNum) AS Sbd_PN, SUM(s.Sto_AccountingNum)  AS Sbd_AN, {Status} AS Sbd_Status, NULL AS Sbd_Result, NULL AS Sbd_Ope_Checker, NULL AS Sbd_CheckTime, NULL AS Sbd_Remark FROM Stock AS s left JOIN GoodsAllocation AS ga ON ga.Gal_Id = s.Sto_Gal_Id left JOIN ReservoirArea AS ra ON ra.Rar_Id = ga.Gal_Rar_Id left JOIN Depots AS d ON d.Dep_ID = ra.Rar_Dep_ID where (s.Sto_Sub_Id = 5 OR s.Sto_Sub_Id = 13 OR s.Sto_Sub_Id = 24) and s.Sto_Gal_Id IS NOT NULL and (s.Sto_PackingNum>0 or s.Sto_AccountingNum>0) and d.DEP_Cmst_ID = {sb.CmstID} ");

            if (sb.CompanyID != null && sb.CompanyID > 0)
            {
                sqlstrsb.Append($" and s.Sto_Com_ID = {sb.CompanyID} ");
            }
            if (sb.DepotID != null && sb.DepotID > 0)
            {
                sqlstrsb.Append($" and d.Dep_ID = {sb.DepotID} ");
            }
            if (sb.ReservoirID != null && sb.ReservoirID > 0)
            {
                sqlstrsb.Append($" and ra.Rar_Id = {sb.ReservoirID} ");
            }
            sqlstrsb.Append(" GROUP BY s.Sto_Com_ID,s.Sto_Sku_Id,s.Sto_Gal_Id ");
            int ret = SqlDataHelper.ExecuteNonQuery(st, CommandType.Text, sqlstrsb.ToString());

            if (ret > 0)
            {
                return(true);
            }
            throw new Exception(INSERT_STOCKTACKINGINFO_ERROR);
        }
Ejemplo n.º 2
0
        public bool Insert(StockModel stock)
        {
            bool success = false;

            connection = new DataConnection();
            try
            {
                connection.MyConnection();
                connection.SqlQuery("Insert Into Stock (ProductId,ProductCode,Quantity,PurchasePrice,PurchaseDate) Values(@id,@prdtcode,@qty,@purchasePrice,@purchaseDate)");
                connection.command.Parameters.AddWithValue("@id", stock.Id);
                connection.command.Parameters.AddWithValue("@prdtcode", stock.ProductCode);
                connection.command.Parameters.AddWithValue("@qty", stock.Quantity);
                connection.command.Parameters.AddWithValue("@purchasePrice", stock.PurchasePrice);
                connection.command.Parameters.AddWithValue("@purchaseDate", stock.PurchaseDate);

                int row = connection.command.ExecuteNonQuery();

                if (row > 0)
                {
                    success = true;
                }
                else
                {
                    success = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return(success);
        }
        /// <summary>
        /// Gets stock´s information fron Yahoo Finance
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public StockModel GetStockInfo(string request)
        {
            StockModel stockModel = new StockModel();

            try
            {
                HttpResponseMessage httpResponseMessage = this._HttpClient.GetAsync($"{request}").Result;
                if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    //Extract dynamicaly Promise from Content
                    var     response    = httpResponseMessage.Content.ReadAsStringAsync();
                    dynamic jsonparse   = JObject.Parse(response.Result);
                    var     optionChain = jsonparse["optionChain"];
                    var     result      = optionChain["result"];
                    var     tet3        = result[0];
                    var     options     = tet3["options"];

                    var tet5       = options[0];
                    var calls      = tet5["calls"];
                    var callsArray = calls[0];
                    stockModel.StockPrice = callsArray["lastPrice"];
                    stockModel.StockName  = request;
                    //JsonConvert.DeserializeObject<StockModel>(jsonparse.Result);
                    return(stockModel);
                }
            }
            catch
            {
                return(null);
            }

            return(stockModel);
        }
Ejemplo n.º 4
0
        // PUT api/stockdetails/5
        public int Put(int id, StockModel m)
        {
            m.StockId = id;
            int i = StockDetailProvider.insertStock(m);

            return(i);
        }
Ejemplo n.º 5
0
        public void OnCellExpandPro(string productCode, string stockListID)
        {
            StockListModel slm = bllStockList.GetModel(long.Parse(stockListID));

            if (slm == null)
            {
                return;
            }
            StockModel sm = bllStock.GetModel(slm.StockID);

            if (sm == null)
            {
                return;
            }
            View_GoodsSiteModel viewGSM = bllViewGS.GetModelByGSID(sm.GoodsSiteID);

            if (viewGSM == null)
            {
                return;
            }
            StockListProEventArgs slpea = new StockListProEventArgs();

            slpea.HouseName = viewGSM.StoreHouseName;
            slpea.CellCoord = new CellCoordModel(viewGSM.GoodsSiteRow, viewGSM.GoodsSiteColumn, viewGSM.GoodsSiteLayer);

            slpea.ProductCode = productCode;
            StorageMainView.storageMana.OnEventStorDetail(slpea);
            this.view.ShowExtForm(ExtendFormCate.外部);//直接打开页面
        }
Ejemplo n.º 6
0
        public GoodsReceiptModel AddGoodsReceipt(GoodsReceiptModel model)
        {
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    model.GoodsReceiptItem.ForEach(item =>
                    {
                        item.CreatedOn = DateTime.Now;  //Assign Today's date as CreatedOn
                        item.CreatedBy = model.CreatedBy;
                    });
                    model.CreatedOn = DateTime.Now;

                    db.GoodsReceipts.Add(model);


                    //Save Goods Receipt to DB

                    db.SaveChanges();

                    StockModel stockItem = new StockModel();
                    //If GR generated then save items in  Stock table
                    int SavedGoodsReceiptId = model.GoodsReceiptID;
                    if (SavedGoodsReceiptId > 0)
                    {
                        model.GoodsReceiptItem.ForEach(item =>
                        {
                            stockItem = new StockModel();
                            stockItem.GoodsReceiptItemId = item.GoodsReceiptItemId;
                            stockItem.ItemId             = item.ItemId;
                            stockItem.BatchNO            = item.BatchNO;
                            stockItem.ExpiryDate         = item.ExpiryDate;
                            stockItem.ReceivedQuantity   = item.ReceivedQuantity + item.FreeQuantity;
                            stockItem.AvailableQuantity  = item.ReceivedQuantity + item.FreeQuantity;
                            stockItem.ReceiptDate        = model.GoodsReceiptDate;
                            stockItem.CreatedBy          = item.CreatedBy;
                            stockItem.CreatedOn          = item.CreatedOn;
                            db.Stock.Add(stockItem);
                        });
                        //Save => Stock Items in stock table
                        db.SaveChanges();

                        PurchaseOrderModel poitems = db.PurchaseOrders.Where(a => a.PurchaseOrderId == model.PurchaseOrderId).FirstOrDefault();
                        if (poitems != null)
                        {
                            poitems.POStatus        = "complete";
                            db.Entry(poitems).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    transaction.Commit();
                }
                catch (Exception Ex)
                {
                    transaction.Rollback();
                    throw Ex;
                }
            }
            return(model);
        }
Ejemplo n.º 7
0
        public StockModel GetStock(Guid productID)
        {
            string queryString =
                $@" SELECT *
                    FROM Stocks
                    WHERE ProductID = @id
                ";

            List <SqlParameter> dbParameters = new List <SqlParameter>();

            dbParameters.Add(new SqlParameter("@id", productID));

            var dt = this.GetDataTable(queryString, dbParameters);

            //----- 檢查值 -----
            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }
            //----- 檢查值 -----


            StockModel model = new StockModel();
            DataRow    dr    = dt.Rows[0];

            model.ID         = (Guid)dr["ID"];
            model.CurrentQty = (int)dr["CurrentQty"];
            model.LockedQty  = (int)dr["LockedQty"];

            return(model);
        }
Ejemplo n.º 8
0
        public void UpdateInventory(StockModel stock)
        {
            Stock new_stock = new Stock();
            Stock old_stock;

            new_stock.BranchId = (_branchService.GetBranchByCondition(b => b.Name == stock.LibraryName).FirstOrDefault()).BranchId;
            new_stock.BookId   = _bookService.GetBooksByCondition(b => b.Title == stock.updatedInventoryTitle).FirstOrDefault().AuthorId;


            old_stock = GetStockByCondition(b => b.BranchId == new_stock.BranchId && b.BookId == new_stock.BookId).FirstOrDefault();
            if (old_stock != null)
            {
                new_stock           = old_stock;
                new_stock.Quantity += stock.updatedInventoryQuantity;
            }
            else
            {
                new_stock.Quantity = stock.updatedInventoryQuantity;
            }
            if (new_stock.Quantity < 0)
            {
                throw new InvalidOperationException("Books cannot have a negative number in stock");
            }
            try
            {
                repositoryWrapper.StockRepository.Update(new_stock);
            }
            catch {
                repositoryWrapper.StockRepository.Create(new_stock);
            }
        }
Ejemplo n.º 9
0
        public static StockViewModel ToViewModel(this StockModel value, bool isWatchedByUser = false)
        {
            if (value == null)
            {
                return(null);
            }

            var lastTwoTrades = value.StockQuotes
                                .OrderByDescending(o => o.TradeDate)
                                .Take(2);

            var lastTrade     = lastTwoTrades.FirstOrDefault();
            var previousTrade = lastTwoTrades.Skip(1).FirstOrDefault();

            return(new StockViewModel
            {
                Name = value.Name,
                SectorId = value.SectorId,
                StockId = value.StockId,
                Symbol = value.Symbol,
                LastTradePrice = lastTrade.Close,
                High = lastTrade?.High,
                LastTradeDate = lastTrade.TradeDate,
                PreviousClose = previousTrade.Close,
                Low = lastTrade?.Low,
                NetForeignBuy = lastTrade?.NetForeignBuy,
                Open = lastTrade?.Open,
                IsWatchedByUser = isWatchedByUser,
                WatchersCount = value.Wacthers.Count(),
                Volume = lastTrade.Volume,
                PointsChange = lastTrade.Close - previousTrade.Close,
                PercentChange = Math.Round(((lastTrade.Close - previousTrade.Close) / previousTrade.Close) * 100, 2)
            });
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Tag,EnrollmentDate")] StockModel productStock)
        {
            if (id != productStock.StockId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _stockBll.UpdateProductStock(productStock);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(productStock.StockId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productStock));
        }
Ejemplo n.º 11
0
        private StockModel ConvertCsvToStockModel(string message)
        {
            StockModel output = new StockModel();

            List <string> lines = message.Split(new[] { "\r\n" }, StringSplitOptions.None)
                                  .ToList();

            try
            {
                if (lines.Count > 1)
                {
                    List <string> line = lines[1].Split(",".ToCharArray()).ToList();

                    output.Symbol = line[0];
                    output.Date   = line[1];
                    output.Time   = line[2];
                    output.Open   = line[3];
                    output.High   = double.Parse(line[4]);
                    output.Low    = double.Parse(line[5]);
                    output.Close  = double.Parse(line[6]);
                    output.Volume = int.Parse(line[7]);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(output);
        }
Ejemplo n.º 12
0
        public HttpResponseMessage PutSupplierProductComModel(int id, StockModel data)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            if (id != data.ID)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var tempdata = StockModel.MapEntity(data);//SupplierProductComModel.MaptoEntity(data);

            tempdata.ModifiedBy   = "user";
            tempdata.ModifiedDate = DateTime.Today;

            try
            {
                BusinessFacade.SupplierProduct.Update(tempdata);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupplierProductComModelExists(id))
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
                else
                {
                    throw;
                }
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 13
0
        //ปุ่มเรียกใช้อยู่หน้า index/stock
        public ActionResult stockEdeting_Popup(int stockID)
        {
            // ตัวที่จะแก้ไข
            Database   db     = new Database();
            StockDAO   sDAO   = new StockDAO(db);
            StockModel sModel = sDAO.FindById(stockID);

            db.Close();
            ViewBag.Stock = sModel;

            // ทำตัวเลือกประเภท
            db = new Database();
            PartsTypeDAO          ptDAO   = new PartsTypeDAO(db);
            List <PartsTypeModel> ptModel = ptDAO.FindAll();

            db.Close();
            ViewBag.PartsType = ptModel;

            //ทำตัวเลือกยี่ห้อ
            db = new Database();
            PartsDAO          pDAO   = new PartsDAO(db);
            List <PartsModel> pModel = pDAO.FindByPartsTypeID(sModel.PART.TYPE.PART_TYPE_ID);

            db.Close();
            ViewBag.PartsBrand = pModel;

            return(View());
        }
Ejemplo n.º 14
0
        public void DeleteStock(StockModel stockModel)
        {
            _ = ExecuteSqlCommand(
                sqlCmd =>
            {
                var stockId = _tickerMap[stockModel.Ticker].StockId;


                sqlCmd.Parameters.Add(new MySqlParameter("@stockId", MySqlDbType.Int32)
                {
                    Value = stockId
                });
                sqlCmd.Parameters.Add(new MySqlParameter("@userId", MySqlDbType.Int32)
                {
                    Value = stockModel.UserId
                });
                sqlCmd.Parameters.Add(new MySqlParameter("@qty", MySqlDbType.Double)
                {
                    Value = stockModel.Quantity
                });
                sqlCmd.Parameters.Add(new MySqlParameter("@purchasePrice", MySqlDbType.Double)
                {
                    Value = stockModel.PurchasePrice
                });
                sqlCmd.Parameters.Add(new MySqlParameter("@purchaseDate", MySqlDbType.DateTime)
                {
                    Value = stockModel.PurchaseDate
                });

                return(sqlCmd.ExecuteNonQuery());
            },
                deleteCommand);
        }
Ejemplo n.º 15
0
        public FeedbackInfomation AddStocktakingBill(StockModel sb)
        {
            FeedbackInfomation fi = new FeedbackInfomation();

            try
            {
                using (SqlConnection conn = SqlDataHelper.GetConnection())
                {
                    conn.Open();
                    SqlTransaction st = conn.BeginTransaction();
                    sb.Status = BaseInfo.FindBillStatusIDByName("未盘点");
                    long id = MySMDAL.InsertStocktakingBill(sb, st);
                    sb.StocktakingID = id;
                    bool ret = MySMDAL.GenerateStocktakingDetailInfo(sb, BaseInfo.FindBillStatusIDByName("未盘点"), st);
                    sb = MySMDAL.SelectStocktakingBill(sb.CmstID, sb.StocktakingID, st);
                    st.Commit();
                }
                fi.FeedbackMessage = Tips.SAVE_SUCCESS;
                fi.ErrorStatus     = STATUS_ADAPTER.SAVE_SUCCESS;
                fi.Result          = sb;
                return(fi);
            }
            catch (Exception ex)
            {
                fi.FeedbackMessage = ex.Message.ToString();
                fi.ErrorStatus     = STATUS_ADAPTER.SAVE_FAILED;
                fi.Result          = null;
                return(fi);
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Adds new GiveX card for Sale
 /// </summary>
 /// <param name="stockModel"></param>
 private void AddGivexCardForSaleLine(StockModel stockModel)
 {
     IsSubmitButtonEnable   = false;
     IsCloseBatchEnabled    = false;
     _stockCodeForGivexCard = stockModel.StockCode;
     EnableNewCard();
 }
Ejemplo n.º 17
0
        public ActionResult Edit(int id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user     = _systemService.GetUserAndRole(0, userName);

            if (user == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (user.StockR == 0)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var model = new StockModel
            {
                Entity     = _service.GetByKey(id),
                Types      = new SelectList(_systemService.TypeStockList(), "Id", "Name"),
                Categories = new SelectList(_systemService.CategoryStockList(0), "Id", "Name"),
                Units      = new SelectList(_systemService.UnitStockList(0), "Id", "Name"),
                Positions  = new SelectList(_systemService.PositionStockList(), "Id", "Name")
                             //Labels = new SelectList(_systemService.LabelStockList(0), "Id", "Name")
            };

            return(View(model));
        }
Ejemplo n.º 18
0
        public IActionResult Index()
        {
            var model = new StockModel();

            model.getTableData();
            return(View(model));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 查询入库时间
        /// </summary>
        /// <param name="houseName">库房名称</param>
        /// <param name="cellCoord">库存位置</param>
        /// <param name="inputDT">入库时间</param>
        /// <returns>若货位空,返回false</returns>
        public bool GetCellInputTime(string houseName, CellCoordModel cellCoord, ref System.DateTime inputDT)
        {
            if (cellCoord == null)
            {
                return(false);
            }
            StoreHouseModel houseModel = bllStoreHouse.GetModelByName(houseName);

            if (houseModel == null)
            {
                return(false);
            }
            GoodsSiteModel gsm = bllGoodsSite.GetModelByRCL(houseModel.StoreHouseID, cellCoord.Row, cellCoord.Col, cellCoord.Layer);

            if (gsm == null)
            {
                return(false);
            }
            StockModel sm = bllStock.GetModelByGSID(gsm.GoodsSiteID);

            if (sm == null)
            {
                return(false);
            }
            StockListModel slm = bllStockList.GetModelByStockID(sm.StockID);

            if (slm == null)
            {
                return(false);
            }

            inputDT = slm.InHouseTime;
            return(true);
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,Code")] StockModel stockModel)
        {
            if (id != stockModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var stock = _stockRepo.GetById(stockModel.Id);
                    _stockRepo.Edit(stock);
                    stockModel.Update(stock);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockExists(stockModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }


            return(View(stockModel));
        }
Ejemplo n.º 21
0
        public void UpdateStock(StockModel model)
        {
            if (model.CurrentQty < model.LockedQty)
            {
                throw new ArgumentException(" CurrentQty should more than LockedQty. ");
            }


            string dbCommandText =
                $@" UPDATE Stocks
                    SET 
                        CurrentQty = @CurrentQty, 
                        LockedQty = @LockedQty	
                    WHERE
                        ID = @ID
                ";

            List <SqlParameter> parameters = new List <SqlParameter>()
            {
                new SqlParameter("@ID", model.ID),
                new SqlParameter("@CurrentQty", model.CurrentQty),
                new SqlParameter("@LockedQty", model.LockedQty),
            };

            this.ExecuteNonQuery(dbCommandText, parameters);
        }
Ejemplo n.º 22
0
        static void PrintStockInfo(StockModel stock)
        {
            bool compare(string item1, string item2)
            => String.Compare(item1, item2, StringComparison.OrdinalIgnoreCase) == 0;

            var symbol = stock.Symbol;

            var color = Console.ForegroundColor;

            if (compare(symbol, "MSFT"))
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            else if (compare(symbol, "FB"))
            {
                Console.ForegroundColor = ConsoleColor.Blue;
            }
            else if (compare(symbol, "AAPL"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else if (compare(symbol, "GOOG"))
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
            }
            else if (compare(symbol, "AMZN"))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }

            Console.WriteLine(
                $"Symbol {stock.Symbol} - Date {stock.Date:MM/dd/yyyy} - High Price {stock.DayHigh} - Low Price {stock.DayLow}");

            Console.ForegroundColor = color;
        }
Ejemplo n.º 23
0
        public void DeleteStock(List <long> stockIDList)
        {
            string reStr = "";

            if (stockIDList == null)
            {
                return;
            }
            for (int i = 0; i < stockIDList.Count; i++)
            {
                StockModel        sm    = bllStock.GetModel(stockIDList[i]);
                View_StockGSModel vsgsm = bllViewStockGs.GetModelByStockID(stockIDList[i]);
                if (vsgsm == null)
                {
                    return;
                }
                bllStock.Delete(stockIDList[i]);

                this.iStorageManager.AddGSOperRecord(vsgsm.StoreHouseName, new CellCoordModel(vsgsm.GoodsSiteRow, vsgsm.GoodsSiteColumn,
                                                                                              vsgsm.GoodsSiteLayer), EnumGSOperateType.手动删除货位, "手动删除货位:" + vsgsm.GoodsSiteName, ref reStr);
                this.view.AddLog("库存管理", "手动删除货位:" + vsgsm.GoodsSiteName + "成功!", LogInterface.EnumLoglevel.提示);

                bllGs.UpdateGSStatusByRCL(vsgsm.StoreHouseName, vsgsm.GoodsSiteRow, vsgsm.GoodsSiteColumn, vsgsm.GoodsSiteLayer, EnumCellStatus.空闲);
                bllGs.UpdateGsTaskStatusByRCL(vsgsm.StoreHouseName, vsgsm.GoodsSiteRow, vsgsm.GoodsSiteColumn, vsgsm.GoodsSiteLayer, EnumGSTaskStatus.完成);
                string operteDetail = "[" + vsgsm.GoodsSiteName + "]货位状态由《" + vsgsm.GoodsSiteStatus + "》变更为《" + EnumCellStatus.空闲.ToString()
                                      + "》;" + "货位任务状态由《" + vsgsm.GoodsSiteTaskStatus + "》变更为《" + EnumGSTaskStatus.完成.ToString() + "》";

                this.iStorageManager.AddGSOperRecord(vsgsm.StoreHouseName, new CellCoordModel(vsgsm.GoodsSiteRow, vsgsm.GoodsSiteColumn, vsgsm.GoodsSiteLayer)
                                                     , EnumGSOperateType.手动修改状态, operteDetail, ref reStr);
                this.view.AddLog("库存管理", "手动删除货位,同时更新货位状态" + operteDetail + "成功!", LogInterface.EnumLoglevel.提示);
            }
            QueryStock(this.currHouseName, this.currHouseArea, this.currRowth, this.currColth, this.currLayerth, this.gsStatus, this.gsTaskSta, this.currProBatch);
            this.view.ClearStockDetailView();
        }
Ejemplo n.º 24
0
        public void updateStock(StockModel model, int id)
        {
            using (SqlConnection connection = new SqlConnection(Constants.CONNECTION_STRING)) {
                string command_text = "UPDATE dbo.Stock SET Product_ID = @Product_ID, Warehouse_ID = @Warehouse_ID, Supplier_ID = @Supplier_ID, Quantity = @Quantity, Date = @Date WHERE ID = @ID";
                using (SqlCommand command = new SqlCommand(command_text)) {
                    command.Connection = connection;
                    command.Parameters.Add("@Product_ID", System.Data.SqlDbType.Int).Value   = model.ProductID.value;
                    command.Parameters.Add("@Warehouse_ID", System.Data.SqlDbType.Int).Value = model.WarehouseID.isNull() ? (object)DBNull.Value : model.WarehouseID.value;
                    command.Parameters.Add("@Supplier_ID", System.Data.SqlDbType.Int).Value  = model.SupplierID.isNull() ? (object)DBNull.Value : model.SupplierID.value;
                    command.Parameters.Add("@Quantity", System.Data.SqlDbType.Int).Value     = model.Quantity.value;
                    command.Parameters.Add("@Date", System.Data.SqlDbType.DateTime).Value    = model.Date.isNull() ? (object)DBNull.Value : model.Date.value;
                    command.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value           = id;

                    try {
                        connection.Open();
                        command.ExecuteNonQuery();
                        CoreApp.logger.log("Successfully stock updated in database");
                    }
                    catch (Exception ex) { throw new Exception(ex.Message); }
                    finally {
                        try { connection.Close(); CoreApp.logger.log("Successfully connection closed"); }
                        catch (Exception ex) { throw new Exception(ex.Message); }
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> Edit(int id, [Bind("SalesModedID,Quantity,ProductID")] StockModel stockModel)
        {
            if (id != stockModel.StockModelID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stockModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockModelExists(stockModel.StockModelID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductID"] = new SelectList(_context.ProductModel, "ProductID", "ProductName", stockModel.ProductID);
            return(View(stockModel));
        }
        public IEnumerable <StockModel> Get(IEnumerable <string> symbols)
        {
            var stocks = new List <Quote>();

            foreach (var symbol in symbols)
            {
                var request  = new RestRequest("yql?q=select symbol,Ask,LastTradeDate,LastTradeTime,Change,Open,DaysHigh,DaysLow,Volume,PreviousClose,PercentChange,Name from yahoo.finance.quotes where symbol in (\"" + symbol + "\")&format=json&env=store://datatables.org/alltableswithkeys&callback=");
                var response = yahooClient.Execute(request);
                try
                {
                    var stock = SimpleJson.DeserializeObject <LiveStockModel>(response.Content);
                    stocks.Add(stock.query.results.quote);
                }
                catch (Exception e)
                {
                }
            }

            var actualStocks = new List <StockModel>();

            foreach (var stock in stocks)
            {
                actualStocks.Add(StockModel.Map(stock));
            }
            return(actualStocks);
        }
Ejemplo n.º 27
0
        /// <summary>
        ///  配盘数据,建立库存
        /// </summary>
        /// <param name="trayCode">托盘码</param>
        /// <param name="targetHouseName">目标库房名称</param>
        /// <param name="targetStationName">目标站台名称,可做成配置</param>
        /// <param name="inputType">入库类型</param>
        /// <param name="isFull">满盘标识</param>
        public void TrayGoodsRecord(string trayCode, string targetHouseName, string targetStationName, string inputType, bool isFull)
        {
            //判断当前托盘是否已经在库存中了
            StockModel stock = bllStock.GetModelByTrayCode(trayCode);

            if (stock != null)
            {
                this.View.ShowMessage("信息提示", "已经存在此托盘库存!");
                return;
            }

            StockModel stockModel = new StockModel();

            stockModel.Cell_Child_ID = "-1";
            if (isFull == true)
            {
                stockModel.Stock_Full_Flag = "1";
            }
            else
            {
                stockModel.Stock_Full_Flag = "0";
            }

            foreach (TrayGoodsListModel goods in ViewDataManager.PALLETWITHPLANDATA.TrayGoodsListData)
            {
            }
        }
Ejemplo n.º 28
0
        public void ModifyStockList(string stockID, string oldCode, string newCode)
        {
            char[]     splitArr     = { ',', ',' };
            string[]   stockListStr = newCode.Split(splitArr);
            StockModel sm           = bllStock.GetModel(long.Parse(stockID));

            if (sm == null)//没有库存信息
            {
                return;
            }

            List <StockListModel> stockList = bllStockList.GetListByStockID(long.Parse(stockID));

            if (stockList.Count != stockListStr.Length)
            {
                this.view.AddLog("库存管理", "料框条码个数错误!", LogInterface.EnumLoglevel.提示);
                return;
            }
            for (int i = 0; i < stockList.Count; i++)
            {
                StockListModel slm = stockList[i];
                if (stockListStr.Length > i)
                {
                    slm.MeterialboxCode = stockListStr[i];
                    bllStockList.Update(slm);
                }
            }
            this.view.AddLog("库存管理", "库存料框条码由:" + oldCode + "手动修改为:" + newCode, LogInterface.EnumLoglevel.提示);

            //RefreshStockList(long.Parse(stockID));
            QueryStock(this.currHouseName, this.currHouseArea, this.currRowth, this.currColth, this.currLayerth, this.gsStatus, this.gsTaskSta, this.currProBatch, this.isChecked, this.materialBoxCode);
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Ticker,StockName,Price")] StockModel stockModel)
        {
            if (id != stockModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stockModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockModelExists(stockModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(stockModel));
        }
Ejemplo n.º 30
0
        private void shuaxin()
        {
            StockModel stock = new StockModel();

            page.nowPage            = 1;
            Session["jxc_z_select"] = stock.jxc_z_select(user.gongsi, page.getLimit1(), page.getLimit2());
        }