public static StockInfo getStockInfo(string Ticker) { string html = WebZap.ObtainWebPage("http://finance.yahoo.com/q?s=" + Ticker + "&d=2b"); StockInfo info = new StockInfo(Ticker); info.LastTrade = float.Parse(WebZap.getHTML(html, "Last Trade<br>", "<b>", "</b>")); info.Volume = (int) float.Parse(WebZap.getHTML(html, "", "Volume<br>", "</font>")); info.RecentNewsURL = WebZap.getHTML(html, "Yahoo TimeStamp", "href=\"", "\">"); info.RecentNewsText = WebZap.getHTML(html, "Yahoo TimeStamp", "\">", "</a>"); info.PreviousClose = float.Parse(WebZap.getHTML(html, "", "Prev Cls<br>", "</font>")); info.Open = float.Parse(WebZap.getHTML(html, "", "Open<br>", "</font>")); info.DayLow = float.Parse(WebZap.getHTML(html, "", "Day's Range<br>", " - ")); info.DayHigh = float.Parse(WebZap.getHTML(html, "Day's Range<br>", " - ", "</font>")); return info; }
/* * Method executed when short term memory changed */ protected override void HandleWorkingMemoryChanged(object sender, EventArgs e) { //Set the most recent search ticker in focus MemoryItem idaItem = ownerAgent.WorkingMemory.GetLastItemByTag(MemoryItemTags.InternetDataAcquisitionProcess); if (idaItem != null) { //Only go further if idaItem is a response (both IDA requests and responses share the same MemoryItemTag) string idaItemType = idaItem.Content.Split('*')[0]; string idaItemMessage = idaItem.Content.Split('*')[1]; if (idaItemType.Equals("responseSearch") && timeOfLastResponseSearch < idaItem.CreationDateTime) { JavaScriptSerializer parser = new JavaScriptSerializer(); //Put ':' back into string to make JSON compatible string idaItemMessageJson = idaItemMessage.Replace(';', ':'); List <StockInfo> stockInfoList = (List <StockInfo>)parser.Deserialize(idaItemMessageJson, typeof(List <StockInfo>)); StockInfo stockInfo = stockInfoList.First(); stockInFocus = stockInfo.t; stockInFocusLastPrice = stockInfo.l_fix; timeOfLastResponseSearch = idaItem.CreationDateTime; } if (idaItemType.Equals("responsePortfolio") && timeOfLastResponsePortfolio < idaItem.CreationDateTime) { JavaScriptSerializer parser = new JavaScriptSerializer(); //Put ':' back into string to make JSON compatible string idaItemMessageJson = idaItemMessage.Replace(';', ':'); List <StockInfo> stockInfoList = (List <StockInfo>)parser.Deserialize(idaItemMessageJson, typeof(List <StockInfo>)); //Iterate through new data recieved about stocks and update the last known price of each stock in portfolio foreach (StockInfo stockInfo in stockInfoList) { List <Trade> tempTradeList = stockList.FindAll(x => x.StockName == stockInfo.t); foreach (Trade tempTrade in tempTradeList) { tempTrade.LastPrice = stockInfo.l_fix; } } timeOfLastResponsePortfolio = idaItem.CreationDateTime; //check for stop losses and target profits hit foreach (Trade tempTrade in new List <Trade>(stockList)) { string exitMessage = ""; //if short if (tempTrade.Quantity < 0) { if (tempTrade.TargetProfit != 0 && (tempTrade.LastPrice <= tempTrade.TargetProfit)) { //There is a target profit set and it's hit TryExitPosition(tempTrade.Id); exitMessage = "Target has been hit for trade id " + tempTrade.Id + " at " + tempTrade.LastPrice; } else if (tempTrade.StopLoss != 0 && (tempTrade.LastPrice >= tempTrade.StopLoss)) { //There is a stop loss set and it's hit TryExitPosition(tempTrade.Id); exitMessage = "Stop loss has been hit for trade id " + tempTrade.Id + " at " + tempTrade.LastPrice; } } //if long else { if (tempTrade.TargetProfit != 0 && (tempTrade.LastPrice >= tempTrade.TargetProfit)) { //There is a target profit set and it's hit TryExitPosition(tempTrade.Id); exitMessage = "Target has been hit for trade id " + tempTrade.Id + " at " + tempTrade.LastPrice; } else if (tempTrade.StopLoss != 0 && (tempTrade.LastPrice <= tempTrade.StopLoss)) { //There is a stop loss set and it's hit TryExitPosition(tempTrade.Id); exitMessage = "Stop loss has been hit for trade id " + tempTrade.Id + " at " + tempTrade.LastPrice; } } //If agent has exited a trade, tell about it if (exitMessage != "") { MemoryItem exitTradeItem = new MemoryItem(); exitTradeItem.CreationDateTime = DateTime.Now; exitTradeItem.Tag = MemoryItemTags.SpeechProcess; exitTradeItem.Content = exitMessage; ownerAgent.WorkingMemory.InsertItem(exitTradeItem); } } //Repaint form containing info about positions if (portfolioTable.InvokeRequired) { portfolioTable.BeginInvoke(new MethodInvoker(() => RepaintPortfolioTable())); } else { RepaintPortfolioTable(); } } } //Check if there is any request to modify the portfolio MemoryItem portfolioItem = ownerAgent.WorkingMemory.GetLastItemByTag(MyMemoryItemTags.PortfolioUpdate); if (portfolioItem != null) { if (timeOfLastInput < portfolioItem.CreationDateTime) { string content = portfolioItem.Content; timeOfLastInput = portfolioItem.CreationDateTime; } } }
private void buttonCancel_Click(object sender, EventArgs e) { int putawayTicketID; if (int.TryParse(this.value, out putawayTicketID) == false) { MessageBox.Show("system error!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.putawayTicketID == -1) { return; } if (MessageBox.Show("是否将此上架单中所有上架单条目上架?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } PutawayTicket putawayTicket = (from pt in wmsEntities.PutawayTicket where pt.ID == putawayTicketID select pt).FirstOrDefault(); if (putawayTicket == null) { MessageBox.Show("该上架单已被删除,请刷新后查看", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PutawayTicketItem[] putawayTicketItems = putawayTicket.PutawayTicketItem.ToArray(); int n = 0; foreach (PutawayTicketItem pti in putawayTicketItems) { if (pti.State == "已上架") { n++; } } if (n == putawayTicketItems.Length) { MessageBox.Show("该上架单已全部上架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } foreach (PutawayTicketItem pti in putawayTicketItems) { decimal oldPutawayAmount = (pti.PutawayAmount == null ? 0 : (decimal)pti.PutawayAmount); pti.PutawayAmount = pti.ScheduledMoveCount; //pti.PutawayAmount = pti.UnitAmount * pti.MoveCount; pti.UnitCount = pti.PutawayAmount / pti.UnitAmount; pti.OperateTime = DateTime.Now.ToString(); pti.State = "已上架"; //ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == pti.ReceiptTicketItemID select rti).FirstOrDefault(); StockInfo stockInfo = (from si in wmsEntities.StockInfo where si.ReceiptTicketItemID == pti.ReceiptTicketItemID select si).FirstOrDefault(); if (stockInfo != null) { stockInfo.OverflowAreaAmount -= pti.PutawayAmount - oldPutawayAmount; stockInfo.ShipmentAreaAmount += pti.PutawayAmount - oldPutawayAmount; } } putawayTicket.State = "已上架"; wmsEntities.SaveChanges(); MessageBox.Show("上架成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Search(); CallBack(); /* * var worksheet = this.reoGridControlPutaway.Worksheets[0]; * try * { * if (worksheet.SelectionRange.Rows != 1) * { * MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * int putawayTicketItemID; * try * { * putawayTicketItemID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString()); * } * catch * { * MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * PutawayTicketItem putawayTicketItem = (from pti in wmsEntities.PutawayTicketItem where pti.ID == putawayTicketItemID select pti).FirstOrDefault(); * new Thread(() => * { * if (putawayTicketItem == null) * { * MessageBox.Show("找不到该上架单,可能已被删除"); * return; * } * else * { * putawayTicketItem.State = "待上架"; * wmsEntities.SaveChanges(); * int count = wmsEntities.Database.SqlQuery<int>( * "SELECT COUNT(*) FROM PutawayTicketItem " + * "WHERE PutawayTicketID = @putawayTicketID AND State <> '待上架'", * new SqlParameter("putawayTicketID", putawayTicketItem.PutawayTicketID)).FirstOrDefault(); * * if (count == 0) * { * wmsEntities.Database.ExecuteSqlCommand( * "UPDATE PutawayTicket SET State = '待上架' " + * "WHERE ID = @putawayTicketID", * new SqlParameter("putawayTicketID", putawayTicketItem.PutawayTicketID)); * } * else * { * wmsEntities.Database.ExecuteSqlCommand( * "UPDATE PutawayTicket SET State = '部分上架' " + * "WHERE ID = @putawayTicketID", * new SqlParameter("putawayTicketID", putawayTicketItem.PutawayTicketID)); * } * } * StockInfo stockInfo = (from si in wmsEntities.StockInfo where si.ReceiptTicketItemID == putawayTicketItem.ReceiptTicketItemID select si).FirstOrDefault(); * if (stockInfo != null) * { * if (stockInfo.OverflowAreaAmount != null) * { * int amount = (int)stockInfo.OverflowAreaAmount; * if (stockInfo.ReceiptAreaAmount != null) * { * stockInfo.ReceiptAreaAmount += amount; * } * else * { * stockInfo.ReceiptAreaAmount = amount; * } * stockInfo.OverflowAreaAmount = 0; * } * } * wmsEntities.SaveChanges(); * //MessageBox.Show("成功"); * this.Invoke(new Action(() => * { * this.pagerWidget.Search(); * CallBack(); * })); * }).Start(); * } * * catch (Exception) * { * MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); * return; * }*/ }
/* * private void Search() * { * this.labelStatus.Text = "搜索中..."; * try * { * new Thread(new ThreadStart(() => * { * var wmsEntities = new WMSEntities(); * //ReceiptTicketView[] receiptTicketViews = null; * PutawayTicketItemView[] putawayTicketItemView = null; * // * //try * //{ * // putawayTicketItemView = wmsEntities.Database.SqlQuery<PutawayTicketItemView>("SELECT * FROM PutawayTicketItemView WHERE PutawayTicketID=@putawayTicketID", new SqlParameter("putawayTicketID", putawayTicketID)).ToArray(); * //} * //catch * //{ * // MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); * // return; * //} * * PutawayTicketItemView[] putawayTicketItemViews1; * if (this.key != null && this.value != null) * { * putawayTicketItemViews1 = wmsEntities.Database.SqlQuery<PutawayTicketItemView>(string.Format("SELECT * FROM PutawayTicketItemView WHERE {0}=@value AND PutawayTicketWarehouseID = @warehouseID AND PutawayTicketProjectID = @projectID", key), new SqlParameter[] { new SqlParameter("value", value), new SqlParameter("warehouseID", this.warehouseID), new SqlParameter("projectID", this.projectID) }).ToArray(); * } * else * { * putawayTicketItemViews1 = wmsEntities.Database.SqlQuery<PutawayTicketItemView>("SELECT * FROM PutawayTicketItemView WHERE PutawayTicketWarehouseID = @warehouseID AND PutawayTicketProjectID = @projectID", new SqlParameter[] { new SqlParameter("warehouseID", this.warehouseID), new SqlParameter("projectID", this.projectID) }).ToArray(); * } * putawayTicketItemView = * (from ptiv in putawayTicketItemViews1 * where ptiv.PutawayTicketProjectID == this.projectID && ptiv.PutawayTicketWarehouseID == this.warehouseID * orderby ptiv.StockInfoShipmentAreaAmount / (ptiv.ComponentDailyProduction * ptiv.ComponentSingleCarUsageAmount) ascending, * ptiv.ReceiptTicketItemInventoryDate ascending * select ptiv).ToArray(); * S * // * //string sql = (from ptiv in wmsEntities.PutawayTicketItemView * // where ptiv.PutawayTicketProjectID == this.projectID && ptiv.PutawayTicketWarehouseID == this.warehouseID * // orderby ptiv.StockInfoShipmentAreaAmount / (ptiv.ComponentDailyProduction * ptiv.ComponentSingleCarUsageAmount) ascending, * // ptiv.ReceiptTicketItemInventoryDate ascending * // select ptiv).ToString(); * //Console.WriteLine(sql); * this.reoGridControlPutaway.Invoke(new Action(() => * { * this.labelStatus.Text = "搜索完成"; * var worksheet = this.reoGridControlPutaway.Worksheets[0]; * worksheet.DeleteRangeData(RangePosition.EntireRange); * int n = 0; * for (int i = 0; i < putawayTicketItemView.Length; i++) * { * if (putawayTicketItemView[i].State == "作废") * { * continue; * } * PutawayTicketItemView curputawayTicketItemView = putawayTicketItemView[i]; * object[] columns = Utilities.GetValuesByPropertieNames(curputawayTicketItemView, (from kn in ReceiptMetaData.putawayTicketItemKeyName select kn.Key).ToArray()); * for (int j = 0; j < worksheet.Columns; j++) * { * worksheet[n, j] = columns[j]; * } * n++; * } * })); * this.Invoke(new Action(() => { this.RefreshTextBoxes(); })); * })).Start(); * } * catch * { * MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); * return; * } * * }*/ private void buttonModify_Click(object sender, EventArgs e) { var worksheet = this.reoGridControlPutaway.Worksheets[0]; try { if (worksheet.SelectionRange.Rows != 1) { MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int putawayTicketItemID; try { putawayTicketItemID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString()); } catch { MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PutawayTicketItem putawayTicketItem = (from pti in wmsEntities.PutawayTicketItem where pti.ID == putawayTicketItemID select pti).FirstOrDefault(); if (putawayTicketItem == null) { MessageBox.Show("修改失败,该收货单可能已被删除,请刷新后查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } decimal oldPutawayAmount = 0; if (putawayTicketItem.PutawayAmount == null) { if (putawayTicketItem.PutawayAmount == null) { putawayTicketItem.PutawayAmount = 0; } } oldPutawayAmount = (decimal)putawayTicketItem.PutawayAmount; if (putawayTicketItem == null) { MessageBox.Show("此上架单条目不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { string errorInfo; if (Utilities.CopyTextBoxTextsToProperties(this, putawayTicketItem, ReceiptMetaData.putawayTicketItemKeyName, out errorInfo) == false) { MessageBox.Show(errorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { if (Utilities.CopyComboBoxsToProperties(this, putawayTicketItem, ReceiptMetaData.putawayTicketItemKeyName) == false) { MessageBox.Show("下拉框获取失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (putawayTicketItem.PutawayAmount == null) { MessageBox.Show("实际上架数量不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == putawayTicketItem.ReceiptTicketItemID select rti).FirstOrDefault(); if (putawayTicketItem.UnitAmount == null) { if (receiptTicketItem != null) { putawayTicketItem.UnitAmount = receiptTicketItem.UnitAmount; } } if (putawayTicketItem.PutawayAmount > putawayTicketItem.ScheduledMoveCount) { MessageBox.Show("实际上架数量不能大于计划上架数量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //putawayTicketItem.PutawayAmount = putawayTicketItem.UnitAmount * putawayTicketItem.MoveCount; putawayTicketItem.MoveCount = putawayTicketItem.PutawayAmount / putawayTicketItem.UnitAmount; StockInfo stockInfo = (from si in wmsEntities.StockInfo where si.ReceiptTicketItemID == putawayTicketItem.ReceiptTicketItemID select si).FirstOrDefault(); if (stockInfo != null) { stockInfo.OverflowAreaAmount -= putawayTicketItem.PutawayAmount - oldPutawayAmount; stockInfo.ShipmentAreaAmount += putawayTicketItem.PutawayAmount - oldPutawayAmount; } if (putawayTicketItem.ScheduledMoveCount == putawayTicketItem.PutawayAmount) { putawayTicketItem.State = "已上架"; } else if (putawayTicketItem.PutawayAmount == 0) { putawayTicketItem.State = "待上架"; } else { putawayTicketItem.State = "部分上架"; } wmsEntities.SaveChanges(); this.modifyMode(putawayTicketItem.PutawayTicketID); MessageBox.Show("上架成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Search(); } } } catch (Exception) { MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); return; } /* * decimal oldPutawayAmount = 0; * var worksheet = this.reoGridControlPutaway.Worksheets[0]; * try * { * if (worksheet.SelectionRange.Rows != 1) * { * MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * int putawayTicketItemID; * try * { * putawayTicketItemID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString()); * } * catch * { * MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * PutawayTicketItem putawayTicketItem = (from pti in wmsEntities.PutawayTicketItem where pti.ID == putawayTicketItemID select pti).FirstOrDefault(); * if (putawayTicketItem.ScheduledMoveCount != null) * { * oldPutawayAmount = (decimal)putawayTicketItem.ScheduledMoveCount; * //return; * } * if (putawayTicketItem == null) * { * MessageBox.Show("错误 无法修改此条目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * } * else * { * string errorInfo; * if (Utilities.CopyTextBoxTextsToProperties(this, putawayTicketItem, ReceiptMetaData.putawayTicketItemKeyName, out errorInfo) == false) * { * MessageBox.Show(errorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * else * { * if (Utilities.CopyComboBoxsToProperties(this, putawayTicketItem,ReceiptMetaData.putawayTicketItemKeyName) == false) * { * MessageBox.Show("下拉框获取失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * } * ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == putawayTicketItem.ReceiptTicketItemID select rti).FirstOrDefault(); * if (receiptTicketItem != null) * { * receiptTicketItem.HasPutwayAmount += putawayTicketItem.ScheduledMoveCount - oldPutawayAmount; * } * if (this.JobPersonIDGetter() != -1) * { * this.jobPersonID = JobPersonIDGetter(); * } * if (this.ConfirmIDGetter() != -1) * { * this.confirmPersonID = ConfirmIDGetter(); * } * * putawayTicketItem.JobPersonID = this.jobPersonID; * putawayTicketItem.ConfirmPersonID = this.confirmPersonID; * new Thread(() => * { * * wmsEntities.SaveChanges(); * this.Invoke(new Action(() => * { * this.pagerWidget.Search(); * })); * MessageBox.Show("成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); * * * }).Start(); * } * } * } * * catch (Exception) * { * MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); * return; * }*/ }
/// <summary> /// 添加库存信息 /// </summary> /// <param name="stock">库存实体</param> /// <returns></returns> public static int AddStock(StockInfo model) { return(Remoting.RemoteObject().AddStock(model)); }
private AssetInfo GetSBERStock() { var operations = new List <AssetOperation>() { new AssetOperation() { Id = 3, Ticket = "SBER", Amount = 3, PaymentPrice = 1012430, AssetAction = _buyAction, AssetActionId = _buyAction.Id, PortfolioId = 1, AssetType = _stockType, AssetTypeId = _stockType.Id, Date = new DateTime(2018, 1, 4) }, new AssetOperation() { Id = 4, Ticket = "SBER", Amount = 1, PortfolioId = 1, PaymentPrice = 212430, AssetAction = _buyAction, AssetActionId = _buyAction.Id, AssetType = _stockType, AssetTypeId = _stockType.Id, Date = new DateTime(2019, 4, 4) } }; var payments = new List <Payment>() { new Payment() { PortfolioId = 1, Ticket = "SBER", Amount = 3, Date = DateTime.Now, PaymentValue = 3600 }, new Payment() { PortfolioId = 1, Ticket = "SBER", Amount = 4, Date = DateTime.Now, PaymentValue = 6400 }, }; _financeDataService.EfContext.Payments.AddRange(payments); _financeDataService.EfContext.SaveChanges(); var stockInfo = new StockInfo(_stockMarketData, _financeDataService, "SBER"); foreach (var assetOperation in operations) { stockInfo.RegisterOperation(assetOperation); } return(stockInfo); }
protected override void OnResize(EventArgs e) { base.OnResize(e); DataTable table2 = new DataTable(); var col1 = table2.Columns.Add("Symbol_0", typeof(String)); var col2 = table2.Columns.Add("Price_0", typeof(decimal)); var col3 = table2.Columns.Add("Change_0", typeof(decimal)); int heightPerRow = 30; // TBD: determine height based on Font int numRowsAvailable = (this.Height - this.ColumnHeadersHeight) / heightPerRow; if (numRowsAvailable == previousNumRowsAvailable) { return; } previousNumRowsAvailable = numRowsAvailable; int n = Math.Max(1, numRowsAvailable); int id = 0; for (int i = 0, k = 0; i < StockData.Count; i++) { StockInfo s = StockData[i]; DataRow row = null; if (id == 0) { row = table2.NewRow(); table2.Rows.Add(row); } else { row = table2.Rows[k]; } row[col1] = s.Symbol; row[col2] = s.Price; row[col3] = s.Change; k++; if (k == n) { k = 0; id++; col1 = table2.Columns.Add("Symbol_" + id, typeof(String)); col2 = table2.Columns.Add("Price_" + id, typeof(decimal)); col3 = table2.Columns.Add("Change_" + id, typeof(decimal)); } } DataSource = table2; table.Dispose(); table = table2; foreach (DataGridViewColumn c in Columns) { String t = c.HeaderText; int x = t.IndexOf('_'); if (x < 0) { continue; } c.HeaderText = t.Substring(0, x); } }
public async Task <IActionResult> Create([Bind("Id,Date,Benchmark,BaseAmount,Name")] MasterPortfolio masterPortfolio, string holdings) { if (masterPortfolio.Benchmark == null || !masterPortfolio.BaseAmount.HasValue) { return(View(masterPortfolio)); } StockInfo si = _context.StockInfos.Find(masterPortfolio.Benchmark); if (si == null) { return(View(masterPortfolio)); } if (masterPortfolio.BaseAmount.HasValue) { masterPortfolio.BaseAmount = 100000; } if (ModelState.IsValid) { //masterPortfolio.Name = string.Format("{0}-{1}",si.Name,masterPortfolio.Date.ToString("yyyyMMdd")); masterPortfolio.Status = MasterPortfolioStatus.Pending; masterPortfolio.CreatedOn = masterPortfolio.ModifiedOn = DateTime.Now; _context.Add(masterPortfolio); await _context.SaveChangesAsync(); if (!String.IsNullOrEmpty(holdings)) { string[] holdingVals = holdings.Split(new char[] { ',', ';' }); List <PortfolioHolding> holdingList = new List <PortfolioHolding>(); foreach (string val in holdingVals) { if (String.IsNullOrEmpty(val)) { continue; } PortfolioHolding ph = new PortfolioHolding() { MasterPortfolioId = masterPortfolio.Id, StockId = val.Split(new char[] { '_' })[0], }; holdingList.Add(ph); } foreach (PortfolioHolding ph in holdingList) { ph.Weight = 100.0m / holdingList.Count; si = _context.StockInfos.Find(ph.StockId); if (si == null) { return(View(masterPortfolio)); } string key = String.Format("{0}_{1}", si.Id, masterPortfolio.Date.ToString("yyyyMMdd")); StockPerf price = _context.StockPerfs.Find(key); if (price == null) { return(View(masterPortfolio)); } ph.ModifiedOn = ph.CreatedOn = DateTime.Now; ph.Shares = (int)Math.Floor(ph.Weight.Value * masterPortfolio.BaseAmount.Value / price.Close.Value / 100 / 100) * 100;//整手 ph.ActualWeight = 100 * ph.Shares * price.Close.Value / masterPortfolio.BaseAmount; _context.Add(ph); } } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(masterPortfolio)); }
private void SetInfo(StockInfo info) { info.LowWarning = Convert.ToInt32(txtLowWarning.Text); info.HighWarning = Convert.ToInt32(txtHighWarning.Text); }
private void OK_Click(object sender, EventArgs e) { var worksheet = this.reoGridControlUser.Worksheets[0]; worksheet.FocusPos = new CellPosition(0, 0); WMSEntities wmsEntities = new WMSEntities(); ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == this.receiptTicketID select rt).FirstOrDefault(); if (receiptTicket == null) { MessageBox.Show("该收货单已被删除,送检失败"); return; } else { if (receiptTicket.State != "待收货") { MessageBox.Show("该收货单状态为" + receiptTicket.State + ",无法送检!"); } } SortedDictionary <int, decimal> idsAndSubmissionAmount = SelectReceiptTicketItem(); if (idsAndSubmissionAmount == null) { return; } Dictionary <ReceiptTicketItem, decimal> receiptTicketItemsAndSubmissionAmount = new Dictionary <ReceiptTicketItem, decimal>(); foreach (KeyValuePair <int, decimal> kv in idsAndSubmissionAmount) { ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == kv.Key select rti).FirstOrDefault(); if (receiptTicketItem != null) { if (receiptTicketItem.ReceiviptAmount < kv.Value) { MessageBox.Show("送检数量不应大于收货数量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (kv.Value < 0) { MessageBox.Show("送检数量不应为负数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } receiptTicketItemsAndSubmissionAmount.Add(receiptTicketItem, kv.Value); } } if (this.formMode == FormMode.ADD) { SubmissionTicket submissionTicket = new SubmissionTicket(); string errorInfo; if (Utilities.CopyTextBoxTextsToProperties(this, submissionTicket, ReceiptMetaData.submissionTicketKeyName, out errorInfo) == false) { MessageBox.Show(errorInfo); return; } else { Utilities.CopyComboBoxsToProperties(this, submissionTicket, ReceiptMetaData.submissionTicketKeyName); submissionTicket.PersonID = this.PersonIDGetter(); submissionTicket.ReceivePersonID = this.ReceivePersonIDGetter(); submissionTicket.SubmissionPersonID = this.SubmissionPersonIDGetter(); submissionTicket.DeliverSubmissionPersonID = this.DeliverSubmissionPersonIDGetter(); //ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == this.receiptTicketID select rt).FirstOrDefault(); submissionTicket.SubmissionDate = receiptTicket.ReceiptDate; submissionTicket.CreateTime = DateTime.Now; submissionTicket.ReceiptTicketID = this.receiptTicketID; submissionTicket.CreateUserID = this.userID; submissionTicket.LastUpdateTime = DateTime.Now; submissionTicket.LastUpdateUserID = this.userID; submissionTicket.ProjectID = receiptTicket.ProjectID; submissionTicket.WarehouseID = receiptTicket.WarehouseID; submissionTicket.State = "待检"; //////////////////////////// Begin if (string.IsNullOrWhiteSpace(submissionTicket.No)) { if (submissionTicket.CreateTime.HasValue == false) { MessageBox.Show("单号生成失败(未知创建日期)!请手动填写单号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DateTime createDay = new DateTime(submissionTicket.CreateTime.Value.Year, submissionTicket.CreateTime.Value.Month, submissionTicket.CreateTime.Value.Day); DateTime nextDay = createDay.AddDays(1); int maxRankOfToday = Utilities.GetMaxTicketRankOfDay((from s in wmsEntities.SubmissionTicket where s.CreateTime >= createDay && s.CreateTime < nextDay select s.No).ToArray()); if (maxRankOfToday == -1) { MessageBox.Show("单号生成失败!请手动填写单号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } submissionTicket.No = Utilities.GenerateTicketNo("J", submissionTicket.CreateTime.Value, maxRankOfToday + 1); } /////////////////////////////////////////////////////////////// End wmsEntities.SubmissionTicket.Add(submissionTicket); try { wmsEntities.SaveChanges(); //submissionTicket.No = Utilities.GenerateTicketNo() wmsEntities.SaveChanges(); foreach (KeyValuePair <ReceiptTicketItem, decimal> vp in receiptTicketItemsAndSubmissionAmount) { SubmissionTicketItem submissionTicketItem = new SubmissionTicketItem(); StockInfo stockInfo = (from si in wmsEntities.StockInfo where si.ReceiptTicketItemID == vp.Key.ID select si).FirstOrDefault(); if (stockInfo == null) { MessageBox.Show("找不到对应的库存信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (stockInfo.ReceiptAreaAmount != null) { submissionTicketItem.ArriveAmount = stockInfo.ReceiptAreaAmount; } stockInfo.SubmissionAmount = vp.Value; stockInfo.ReceiptAreaAmount -= vp.Value; submissionTicketItem.ArriveAmount = vp.Key.ReceiviptAmount; submissionTicketItem.ReceiptTicketItemID = vp.Key.ID; submissionTicketItem.State = "待检"; vp.Key.State = "送检中"; submissionTicketItem.SubmissionAmount = vp.Value; submissionTicketItem.SubmissionTicketID = submissionTicket.ID; wmsEntities.SubmissionTicketItem.Add(submissionTicketItem); } } receiptTicket.HasSubmission = 1; receiptTicket.State = "送检中"; wmsEntities.SaveChanges(); /* * int count = wmsEntities.Database.SqlQuery<int>( * "SELECT COUNT(*) FROM ReceiptTicketItem " + * "WHERE ReceiptTicketID = @receiptTicketID AND State <> '送检中'", * new SqlParameter("receiptTicketID", receiptTicketID)).FirstOrDefault(); * if (count == 0) * { * wmsEntities.Database.ExecuteSqlCommand( * "UPDATE ReceiptTicket SET State='送检中' " + * "WHERE ID = @receiptTicketID", * new SqlParameter("receiptTicketID", receiptTicketID)); * } * else * { * wmsEntities.Database.ExecuteSqlCommand( * "UPDATE ReceiptTicket SET State='部分送检中' " + * "WHERE ID = @receiptTicketID", * new SqlParameter("receiptTicketID", receiptTicketID)); * } */ this.Search(); CallBack(); this.Hide(); MessageBox.Show("收货单条目送检成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); return; } } } else { } }
static async Task Main(string[] args) { var tickersLimit = -1; var showHelp = false; var p = new OptionSet() { { "h|?|help", v => { showHelp = v != null; } }, { "l|limit=", v => { int.TryParse(v, out tickersLimit); } }, }; List <string> extra; try { extra = p.Parse(args); } catch (OptionException e) { Console.Write("greet: "); Console.WriteLine(e.Message); Console.WriteLine("Try `greet --help' for more information."); return; } if (showHelp) { ShowHelp(p); return; } var output = GetOutput(); var config = await GetTokensAsync(); if (config == null) { throw new ArgumentNullException(); } var tinkoffToken = config.Tinkoff.Tokens?.FirstOrDefault(); if (tinkoffToken == null) { throw new ArgumentNullException(); } var stockMarket = GetStockMarket(tinkoffToken, output); var fileStorage = GetFileStorage(); var dbStorage = GetDbStorage(config); var financeDataProviders = GetFinanceDataProviders(output, config); var financeDataManager = GetFinanceDataManager(output, financeDataProviders, dbStorage); var stockInfoCache = GetStockInfoCache(); var tickers = await stockMarket.GetTickersAsync(); var n = tickers.Length; var stockInfos = new List <StockInfo>(); var stockInfosFromCache = await stockInfoCache.GetAllAsync(); if (tickersLimit > 0) { output.Publish($"tickers limit = {tickersLimit}"); } var tryCount = 0; if (tickersLimit < 0) { output.Publish($"Fill data"); await financeDataManager.FillData(tickers); } for (int i = 0; i < n; i++) { if (i == tickersLimit) { break; } var ticker = tickers[i]; output.Publish($"{ticker} {i}/{n}"); try { var stockInfo = stockInfosFromCache.FirstOrDefault(x => x.Ticker == ticker); if (stockInfo == null) { var companyInfo = await financeDataManager.GetCompanyInfoAsync(ticker); stockInfo = StockInfo.Create( ticker, companyInfo.Industry, companyInfo.CompanyName, companyInfo.Logo, companyInfo.CurrentPrice, companyInfo.PriceTarget, companyInfo.Recommendations); await stockInfoCache.SaveAsync(stockInfo); } stockInfos.Add(stockInfo); } catch (System.Net.Http.HttpRequestException ex) { if (tryCount > 3) { return; } output.Publish($"{ticker} {i}/{n} else one try"); await Task.Delay(2000); i--; tryCount++; } tryCount = 0; } await fileStorage.CreateReportAsync(stockInfos.ToArray()); await stockInfoCache.ClearAsync(); output.Publish($"report saved"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(StockInfo model) { return(StockInfoDAL.instance.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(StockInfo model) { return(StockInfoDAL.instance.Add(model)); }
/// <summary> /// 更新库存 /// </summary> /// <param name="childjson">出库单出库商品json</param> private void UpdateStockInfo(IList <string> strList, DeliveryOrder deorder) { string db = ConfigurationManager.AppSettings["ExamineDB"]; string strguids = ""; Dictionary <string, object> dic = null; StockInfo stoinfo = null; for (int i = 0; i < strList.Count; i++) { dic = FromJson(strList[i]) as Dictionary <string, object>; if (dic != null) { //记录日志begin if (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "") { StockLog slEnt = new StockLog();//创建库存变更日志 slEnt.InOrOutDetailId = dic["Id"] + ""; slEnt.InOrOutBillNo = deorder.Number; slEnt.OperateType = "产品出库"; slEnt.WarehouseId = deorder.WarehouseId; slEnt.WarehouseName = deorder.WarehouseName; IList <StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, dic["ProductId"], StockInfo.Prop_WarehouseId, deorder.WarehouseId); if (siEnts.Count > 0) { slEnt.StockQuantity = siEnts[0].StockQuantity; } slEnt.Quantity = Convert.ToInt32(dic["SmCount"]); slEnt.ProductId = dic["ProductId"] + ""; Product pEnt = Product.Find(dic["ProductId"]); slEnt.ProductCode = pEnt.Code; slEnt.ProductName = pEnt.Name; slEnt.ProductIsbn = pEnt.Isbn; slEnt.ProductPcn = pEnt.Pcn; slEnt.DoCreate(); } //记录日志end //更新唯一编号的状态 if (dic.ContainsKey("Guids") && dic["Guids"] + "" != "") { string guids = dic["Guids"] + ""; guids = guids.Substring(0, guids.Length - 1); strguids = "'" + guids.Replace(",", "','") + "'"; DataHelper.ExecSql("update " + db + "..Compressor set [state]='已出库',CustomerId='" + deorder.CId + "',DeliveryOrderId='" + deorder.Id + "' where SeriesNo in (" + strguids + ")"); } //更新库存 OutCount stoinfo = StockInfo.FindAllByProperties("ProductId", dic["ProductId"], "WarehouseId", deorder.WarehouseId).FirstOrDefault <StockInfo>(); if (stoinfo != null) { //SmCount 本次出库数量 stoinfo.StockQuantity -= (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0); stoinfo.DoUpdate(); } else { stoinfo = new StockInfo { ProductCode = dic["Code"] + "", ProductId = dic["ProductId"] + "", ProductName = dic["Name"] + "", StockQuantity = -(dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0), WarehouseId = deorder.WarehouseId, WarehouseName = deorder.WarehouseName }; stoinfo.DoCreate(); } } } }
public static bool Update(StockInfo stockInfo) { return(dal.Update(stockInfo)); }
private void GetStockMinInfoSZ_DoWork(object sender, DoWorkEventArgs e) { IsDownStockCode = true; Dictionary <string, string> dic; int con = 0; short shortResult = 0; if (e.Argument != null) { dic = (Dictionary <string, string>)e.Argument; con = Convert.ToInt32(dic["Con"]); shortResult = (short)Convert.ToInt32(dic["Count"]); } bool bool1; short Count; //bool bool1 =TdxApi.TdxHq_Multi_GetSecurityCount(con, 0, ref shortResult, ErrInfo); //Console.WriteLine(bool1 ? shortResult.ToString() : ErrInfo.ToString()); int num = shortResult / 1000; int sum = 0; for (int x = 0; x <= num; x++) { int start = x * 1000; Count = shortResult; bool1 = TdxApi.TdxHq_Multi_GetSecurityList(con, 0, (short)start, ref Count, Result, ErrInfo); string[] strRow = Result.ToString().Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); //分解行的字符串 //string[] strCol=strRow[0].Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Dictionary <string, string> Message = new Dictionary <string, string>(); Message.Add("Result", ""); Message.Add("ErrInfo", ""); for (int i = 1; i < strRow.Length; i++) { //分解行的字符串 //StockInfo属性 每列数据 string[] strCol = strRow[i].Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (strCol[6] == "0" || strCol[2].Contains("指数")) { continue; } StockInfo stock = new StockInfo(); stock.stockcode = strCol[0]; stock.Type = "0"; stock.OneHand = strCol[1]; stock.Name = strCol[2]; stock.PointIndex = strCol[4]; stock.YestClose = decimal.Parse(strCol[5]); stock.Unknow1 = strCol[3]; stock.Unknow2 = strCol[6]; stock.Unknow3 = strCol[7]; int ID = _Stockservice.Add(stock); if (ID > 0) { sum += 1; string message = "Current sum is: " + start.ToString(); //ReportProgress 方法把信息传递给 ProcessChanged 事件处理函数。 //第一个参数类型为 int,表示执行进度。 //如果有更多的信息需要传递,可以使用 ReportProgress 的第二个参数。 //这里我们给第二个参数传进去一条消息。 Message["Result"] = Result.ToString(); Message["ErrInfo"] = ErrInfo.ToString(); bk_GetStockInfoSZ.ReportProgress(sum, Message); } else { //记录日志 Message["Result"] = Result.ToString(); Message["ErrInfo"] = ErrInfo.ToString(); bk_GetStockInfoSZ.ReportProgress(sum, Message); continue; } } } SzStockCompleted = true; }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance StockInfo mock = CreateMockInstance(tm); bool result = DataRepository.StockInfoProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); StockInfoQuery query = new StockInfoQuery(); query.AppendEquals(StockInfoColumn.Id, mock.Id.ToString()); query.AppendEquals(StockInfoColumn.GoodsId, mock.GoodsId.ToString()); if (mock.OpenDate != null) { query.AppendEquals(StockInfoColumn.OpenDate, mock.OpenDate.ToString()); } if (mock.LastDate != null) { query.AppendEquals(StockInfoColumn.LastDate, mock.LastDate.ToString()); } if (mock.MinusDate != null) { query.AppendEquals(StockInfoColumn.MinusDate, mock.MinusDate.ToString()); } if (mock.StktakeDt != null) { query.AppendEquals(StockInfoColumn.StktakeDt, mock.StktakeDt.ToString()); } if (mock.StktakeTm != null) { query.AppendEquals(StockInfoColumn.StktakeTm, mock.StktakeTm.ToString()); } if (mock.BeginQty != null) { query.AppendEquals(StockInfoColumn.BeginQty, mock.BeginQty.ToString()); } if (mock.ExpQty != null) { query.AppendEquals(StockInfoColumn.ExpQty, mock.ExpQty.ToString()); } if (mock.ImpQty != null) { query.AppendEquals(StockInfoColumn.ImpQty, mock.ImpQty.ToString()); } if (mock.BeginAmt != null) { query.AppendEquals(StockInfoColumn.BeginAmt, mock.BeginAmt.ToString()); } if (mock.ExpAmt != null) { query.AppendEquals(StockInfoColumn.ExpAmt, mock.ExpAmt.ToString()); } if (mock.ImpAmt != null) { query.AppendEquals(StockInfoColumn.ImpAmt, mock.ImpAmt.ToString()); } if (mock.Averimppr != null) { query.AppendEquals(StockInfoColumn.Averimppr, mock.Averimppr.ToString()); } TList <StockInfo> results = DataRepository.StockInfoProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
public Stock() { observers = new List <IObserver>(); sInfo = new StockInfo(); }
public int InsertStock(StockInfo stock) { SqlConnection conn; int count = 0; using (conn = SqlHelper.CreateConntion()) { conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { count = DAL.InsertStock(stock, trans); trans.Commit(); } catch (Exception) { trans.Rollback(); } conn.Close(); } return count; }
/// <summary> /// 写入库存信息 /// </summary> private int InsertStockData(Dictionary <string, string> WareHouseDict) { int intOk = 0; int intFail = 0; bool isFirstError = true; if (myDs != null && myDs.Tables[0].Rows.Count > 0) { double step = 50 * (1.0 / myDs.Tables[0].Rows.Count); DataTable dt = myDs.Tables[0]; try { int i = 1; foreach (DataRow dr in dt.Rows) { #region 单条记录操作代码 if (dr[0].ToString() == "") { continue; } string itemNo = dr["备件编号(mm码)"].ToString(); string wareHouseKey = dr["库房编号"].ToString(); if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(wareHouseKey)) { continue; } try { string wareHouse = WareHouseDict[wareHouseKey]; StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(itemNo, wareHouse); if (stockInfo != null) { #region 更新 stockInfo.ItemNo = itemNo; stockInfo.WareHouse = wareHouse; stockInfo.ItemName = dr["备件名称"].ToString(); stockInfo.ItemBigType = dr["备件属类"].ToString(); stockInfo.ItemType = dr["备件类别"].ToString(); int quantity = 0; try { quantity = Convert.ToInt32(dr["库存量"].ToString()); } catch { } stockInfo.StockQuantity = quantity; decimal price = 0M; try { price = Convert.ToDecimal(dr["单价(元)"].ToString()); } catch { } bool success = BLLFactory <Stock> .Instance.Update(stockInfo, stockInfo.ID.ToString()); if (success) { intOk++; } #endregion } else { #region 添加 stockInfo = new StockInfo(); stockInfo.ItemNo = itemNo; stockInfo.WareHouse = wareHouse; stockInfo.ItemName = dr["备件名称"].ToString(); stockInfo.ItemBigType = dr["备件属类"].ToString(); stockInfo.ItemType = dr["备件类别"].ToString(); int quantity = 0; try { quantity = Convert.ToInt32(dr["库存量"].ToString()); } catch { } stockInfo.StockQuantity = quantity; decimal price = 0M; try { price = Convert.ToDecimal(dr["单价(元)"].ToString()); } catch { } bool success = BLLFactory <Stock> .Instance.Insert(stockInfo); if (success) { intOk++; } #endregion } } catch (Exception ex) { intFail++; LogTextHelper.Error(ex); if (isFirstError) { MessageDxUtil.ShowError(ex.Message); isFirstError = false; } } #endregion int currentStep = Convert.ToInt32(step * i); worker.ReportProgress(50 + currentStep);//50为前面部分进度 i++; } } catch (Exception ex) { LogTextHelper.Error(ex); MessageDxUtil.ShowError(ex.ToString()); } } return(intOk); }
public int UpdateStock(StockInfo stock, SqlTransaction trans) { string sql = @"UPDATE [Stock] SET [WarehouseID] = @WarehouseID ,[ProductID] = @ProductID ,[StockInTP] = @StockInTP ,[StockInDate] = @StockInDate ,[StockInReason] = @StockInReason ,[StockOutTP] = @StockOutTP ,[StockOutDate] = @StockOutDate ,[StockOutReason] = @StockOutReason ,[Num] = @Num ,[UpdateDateTime] = @UpdateDateTime ,[UpdateUser] = @UpdateUser WHERE id=@id"; SqlParameter[] spvalues = DBTool.GetSqlPm(stock); return SqlHelper.ExecuteNonQuery(trans, System.Data.CommandType.Text, sql, spvalues); }
public static int BatchImport(DataTable dtField, string filePath, string specialId, int nodeId, int modelId) { ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId); if (modelInfoById.IsNull) { return(0); } string tableName = modelInfoById.TableName; ProductInfo info = new ProductInfo(); info.EnableWholesale = false; info.EnableSingleSell = true; info.SalePromotionType = 0; info.ProductCharacter = modelInfoById.Character; DataTable dataTable = GetDataTableFromModel(modelId, specialId, nodeId); info.Fields = ContentManage.GetNewContentData(dataTable); OleDbConnection selectConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""); string selectCommandText = "select * from [sheet1$]"; OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommandText, selectConnection); DataSet dataSet = new DataSet(); try { adapter.Fill(dataSet, "ss"); } catch (OleDbException) { } StringBuilder builder = new StringBuilder(); int num2 = 0; for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { int newProductId = GetNewProductId(); info.ProductId = newProductId; DataRow rows = dataSet.Tables[0].Rows[i]; info.ProductName = GetExcelFieldValue(rows, dtField, "ProductName", string.Empty); info.ProductNum = GetExcelFieldValue(rows, dtField, "ProductNum", string.Empty); if (string.IsNullOrEmpty(info.ProductNum)) { Random random = new Random(); info.ProductNum = DateTime.Now.ToString("yyyyMMddHHmmss") + random.Next().ToString(); } else if (IsExistSameProductNum(info.ProductNum)) { builder.Append("<li>商品:" + info.ProductName + "的编号已存在,未导入!</li>"); continue; } info.Unit = GetExcelFieldValue(rows, dtField, "Unit", "个"); info.PriceInfo.Price = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "Price", string.Empty)); info.PriceMarket = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "Price_Market", string.Empty)); info.Weight = DataConverter.CDouble(GetExcelFieldValue(rows, dtField, "Weight", string.Empty)); info.Stocks = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "Stocks", string.Empty)); info.AlarmNum = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "AlarmNum", string.Empty)); info.ProducerName = GetExcelFieldValue(rows, dtField, "ProducerName", string.Empty); info.TrademarkName = GetExcelFieldValue(rows, dtField, "TrademarkName", string.Empty); info.BarCode = GetExcelFieldValue(rows, dtField, "BarCode", string.Empty); info.ProductIntro = GetExcelFieldValue(rows, dtField, "ProductIntro", string.Empty); info.ProductExplain = GetExcelFieldValue(rows, dtField, "ProductExplain", string.Empty); info.Stars = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "Stars", "3")); info.PriceInfo.PriceMember = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "PriceMember", string.Empty)); info.PriceInfo.PriceAgent = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "PriceAgent", string.Empty)); DataRow[] rowArray = info.Fields.Select("FieldName='Title'"); if (rowArray.Length == 0) { AddNewRows(dataTable, "Title", info.ProductName, FieldType.TitleType, 0); } else { rowArray[0][1] = info.ProductName; } foreach (DataRow row2 in info.Fields.Select("FieldLevel=1")) { string str5 = GetExcelFieldValue(rows, dtField, row2["FieldName"].ToString() + "_F", string.Empty); if (string.IsNullOrEmpty(str5)) { goto Label_04AA; } FieldType fieldtype = (FieldType)Enum.Parse(typeof(FieldType), row2["FieldType"].ToString()); string name = Field.GetFieldDataType(fieldtype).Name; if (name != null) { if (!(name == "Double")) { if (name == "Decimal") { goto Label_0448; } if (name == "DateTime") { goto Label_045C; } if (name == "Boolean") { goto Label_0476; } if (name == "Int32") { goto Label_048A; } } else { str5 = DataConverter.CDouble(str5).ToString(); } } goto Label_049C; Label_0448: str5 = DataConverter.CDecimal(str5).ToString(); goto Label_049C; Label_045C: str5 = DataConverter.CDate(str5).ToString(); goto Label_049C; Label_0476: str5 = DataConverter.CBoolean(str5).ToString(); goto Label_049C; Label_048A: str5 = DataConverter.CLng(str5).ToString(); Label_049C: row2["FieldValue"] = str5; Label_04AA :; } bool flag = Add(modelId, tableName, info); StockInfo stockInfo = new StockInfo(); stockInfo.StockId = StockManage.GetMaxId() + 1; stockInfo.StockNum = StockItem.GetInStockNum(); DataRow[] rowArray3 = info.Fields.Select("FieldName='Inputer'"); if (rowArray3.Length > 0) { stockInfo.Inputer = rowArray3[0]["FieldValue"].ToString(); } stockInfo.InputTime = DateTime.Now; stockInfo.StockType = StockType.InStock; stockInfo.Remark = "商品库存初始"; StockManage.Add(stockInfo); if (flag) { IList <StockItemInfo> infoList = new List <StockItemInfo>(); StockItemInfo item = new StockItemInfo(); item.Amount = info.Stocks; item.Price = info.PriceInfo.Price; item.ProductId = newProductId; item.TableName = tableName; item.Property = string.Empty; item.ProductNum = info.ProductNum; item.Unit = info.Unit; item.ProductName = info.ProductName; infoList.Add(item); StockItem.Add(infoList, stockInfo.StockId); } else { builder.Append("<li>商品:" + info.ProductName + "导入失败!</li>"); continue; } num2++; } s_MessgeOfBatchImport = builder.ToString(); dataSet.Dispose(); adapter.Dispose(); selectConnection.Dispose(); return(num2); }
private void SetStockInfoProperty(StockInfo stockInfo, QuotV5.StaticInfo.SecurityCloseMD securityCloseMD) { stockInfo.stkId = securityCloseMD.SecurityID; stockInfo.exchTotalKnockAmt = securityCloseMD.TotalValueTrade; stockInfo.exchTotalKnockQty = (Int64)securityCloseMD.TotalVolumeTrade; }
public static bool Add(int modelId, ProductInfo productInfo, IList <ProductDataInfo> productDataInfoList, IList <ProductPriceInfo> priceInfoList) { ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId); if (modelInfoById.IsNull) { return(false); } string tableName = modelInfoById.TableName; int newProductId = GetNewProductId(); productInfo.ProductId = newProductId; bool flag = true; int num2 = 0; int alarmNum = 0; foreach (ProductDataInfo info2 in productDataInfoList) { num2 += info2.Stocks; alarmNum = info2.AlarmNum; } productInfo.Stocks = num2; productInfo.AlarmNum = alarmNum; flag = Add(modelId, tableName, productInfo); StockInfo stockInfo = new StockInfo(); stockInfo.StockId = StockManage.GetMaxId() + 1; stockInfo.StockNum = StockItem.GetInStockNum(); DataRow[] rowArray = productInfo.Fields.Select("FieldName='Inputer'"); if (rowArray.Length > 0) { stockInfo.Inputer = rowArray[0]["FieldValue"].ToString(); } stockInfo.InputTime = DateTime.Now; stockInfo.StockType = StockType.InStock; stockInfo.Remark = "商品库存初始"; StockManage.Add(stockInfo); if (flag) { IList <StockItemInfo> infoList = new List <StockItemInfo>(); if (!string.IsNullOrEmpty(productInfo.Properties)) { flag = ProductData.Add(newProductId, tableName, productDataInfoList); foreach (ProductDataInfo info4 in productDataInfoList) { StockItemInfo item = new StockItemInfo(); item.ItemId = StockItem.GetMaxId() + 1; item.Amount = info4.Stocks; item.Price = info4.PriceInfo.Price; item.ProductId = newProductId; item.TableName = tableName; item.Property = info4.PropertyValue; item.StockId = stockInfo.StockId; item.ProductNum = productInfo.ProductNum; item.Unit = productInfo.Unit; item.ProductName = productInfo.ProductName; infoList.Add(item); } } else { StockItemInfo info6 = new StockItemInfo(); info6.Amount = productInfo.Stocks; info6.Price = productInfo.PriceInfo.Price; info6.ProductId = newProductId; info6.TableName = tableName; info6.Property = string.Empty; info6.ProductNum = productInfo.ProductNum; info6.Unit = productInfo.Unit; info6.ProductName = productInfo.ProductName; infoList.Add(info6); } StockItem.Add(infoList, stockInfo.StockId); if (((productInfo.PriceInfo.PriceMember == -1M) || (productInfo.PriceInfo.PriceAgent == -1M)) && (priceInfoList != null)) { flag = ProductPrice.Add(newProductId, tableName, priceInfoList); } } return(flag); }
/// <summary> /// 修改库存信息 /// </summary> /// <param name="model">库存信息实体</param> /// <returns></returns> public static int UpdateStock(StockInfo model) { return(Remoting.RemoteObject().UpdateStock(model)); }
/// <summary> /// 更新渠道仓库 /// </summary> /// <param name="stockInfo"></param> /// <returns></returns> public virtual StockInfo UpdateStock(StockInfo stockInfo) { return(StockProcessor.UpdateStock(stockInfo)); }
private void buttonFInished_Click(object sender, EventArgs e) { var worksheet = this.reoGridControlPutaway.Worksheets[0]; try { if (worksheet.SelectionRange.Rows != 1) { MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int putawayTicketItemID; try { putawayTicketItemID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString()); } catch { MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PutawayTicketItem putawayTicketItem = (from pti in wmsEntities.PutawayTicketItem where pti.ID == putawayTicketItemID select pti).FirstOrDefault(); decimal oldPutawayAmount = 0; if (putawayTicketItem.PutawayAmount == null) { if (putawayTicketItem.PutawayAmount == null) { putawayTicketItem.PutawayAmount = 0; } } oldPutawayAmount = (decimal)putawayTicketItem.PutawayAmount; if (putawayTicketItem == null) { MessageBox.Show("此上架单条目不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { if (this.Controls.Find("textBoxOperateTime", true)[0].Text == "") { this.Controls.Find("textBoxOperateTime", true)[0].Text = DateTime.Now.ToString(); } string errorInfo; if (Utilities.CopyTextBoxTextsToProperties(this, putawayTicketItem, ReceiptMetaData.putawayTicketItemKeyName, out errorInfo) == false) { MessageBox.Show(errorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { if (Utilities.CopyComboBoxsToProperties(this, putawayTicketItem, ReceiptMetaData.putawayTicketItemKeyName) == false) { MessageBox.Show("下拉框获取失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (putawayTicketItem.PutawayAmount == null) { MessageBox.Show("实际上架数量不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == putawayTicketItem.ReceiptTicketItemID select rti).FirstOrDefault(); if (putawayTicketItem.UnitAmount == null) { if (receiptTicketItem != null) { putawayTicketItem.UnitAmount = receiptTicketItem.UnitAmount; } } if (putawayTicketItem.PutawayAmount > putawayTicketItem.ScheduledMoveCount) { MessageBox.Show("实际上架数量不能大于计划上架数量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //putawayTicketItem.PutawayAmount = putawayTicketItem.UnitAmount * putawayTicketItem.MoveCount; putawayTicketItem.MoveCount = putawayTicketItem.PutawayAmount / putawayTicketItem.UnitAmount; StockInfo stockInfo = (from si in wmsEntities.StockInfo where si.ReceiptTicketItemID == putawayTicketItem.ReceiptTicketItemID select si).FirstOrDefault(); if (stockInfo != null) { stockInfo.OverflowAreaAmount -= putawayTicketItem.PutawayAmount - oldPutawayAmount; stockInfo.ShipmentAreaAmount += putawayTicketItem.PutawayAmount - oldPutawayAmount; } if (putawayTicketItem.ScheduledMoveCount == putawayTicketItem.PutawayAmount) { putawayTicketItem.State = "已上架"; } else if (putawayTicketItem.PutawayAmount == 0) { putawayTicketItem.State = "待上架"; } else { putawayTicketItem.State = "部分上架"; } wmsEntities.SaveChanges(); this.modifyMode(putawayTicketItem.PutawayTicketID); MessageBox.Show("上架成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Search(); if (CallBack != null) { CallBack(); } } } } catch (Exception) { MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); return; } }
/// <summary> /// 创建渠道仓库 /// </summary> /// <param name="stockInfo"></param> /// <returns></returns> public virtual StockInfo CreateStock(StockInfo stockInfo) { return(StockProcessor.CreateStock(stockInfo)); }
public void Update(ISubject subject, StockInfo info) { Console.WriteLine($"{_name} is being notified by {info.CompanyName} that its stock is now {info.Price}"); }
string type = String.Empty; // 对象类型 protected void Page_Load(object sender, EventArgs e) { switch (this.RequestAction) { case RequestActionEnum.Insert: case RequestActionEnum.Create: //添加库存数量 string WarehouseId = RequestData.Get <string>("WarehouseId"); string WarehouseName = RequestData.Get <string>("WarehouseName"); string json = RequestData.Get <string>("json"); Dictionary <string, object> dic = null; json = json.Substring(1, json.Length - 2); string[] objarr = json.Replace("},{", "#").Split('#'); for (int i = 0; i < objarr.Length; i++) { if (objarr.Length == 1) { dic = FromJson(objarr[i]) as Dictionary <string, object>; } else { if (i == 0) { dic = FromJson(objarr[i] + "}") as Dictionary <string, object>; } else if (i == objarr.Length - 1) { dic = FromJson("{" + objarr[i]) as Dictionary <string, object>; } else { dic = FromJson("{" + objarr[i] + "}") as Dictionary <string, object>; } } if (dic != null) { StockInfo stoinfo = StockInfo.FindAllByProperties("ProductId", dic["Id"], "WarehouseId", WarehouseId).FirstOrDefault <StockInfo>(); if (stoinfo != null) { stoinfo.StockQuantity = (stoinfo.StockQuantity == null ? 0 : stoinfo.StockQuantity) + (dic.ContainsKey("Count") ? Convert.ToInt32(dic["Count"]) : 0); stoinfo.DoUpdate(); } else { stoinfo = new StockInfo { ProductCode = dic["Code"] + "", ProductName = dic["Name"] + "", ProductId = dic["Id"] + "", WarehouseId = WarehouseId, WarehouseName = WarehouseName, StockQuantity = dic.ContainsKey("Count") ? Convert.ToInt32(dic["Count"]) : 0 }; stoinfo.DoCreate(); } } } break; } }
/// <summary> /// 编辑状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveUpdated() { bool exist = BLLFactory <ItemDetail> .Instance.CheckExist(this.txtItemNo.Text, ID); if (exist) { MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改"); return(false); } ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindByID(ID); if (info != null) { if (txtBelongWareHouse.Text != txtBelongWareHouse.Tag.ToString()) { if (MessageDxUtil.ShowYesNoAndWarning("您的备件所属库存发生了修改,是否继续更改库房数据") == DialogResult.No) { return(false); } } SetInfo(info); try { #region 更新数据 bool succeed = BLLFactory <ItemDetail> .Instance.Update(info, info.ID.ToString()); if (succeed) { try { StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(this.txtItemNo.Text, this.txtBelongWareHouse.Tag.ToString()); if (stockInfo != null) { stockInfo.WareHouse = txtBelongWareHouse.Text; BLLFactory <Stock> .Instance.Update(stockInfo, stockInfo.ID.ToString()); } //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之 bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text); if (!isInit) { BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text); } } catch (Exception ex) { MessageDxUtil.ShowTips(string.Format("初始化库存为0失败:", ex.Message)); } //MessageDxUtil.ShowTips("备件数据保存成功"); //this.DialogResult = DialogResult.OK; return(true); } #endregion } catch (Exception ex) { LogTextHelper.Error(ex); MessageDxUtil.ShowError(ex.Message); } } return(false); }
private void ProcessStaticInfo(QuotV5.StaticInfo.SecurityInfoBase securityInfo) { RawStaticInfoSnap.SecurityInfo[securityInfo.CommonInfo.SecurityID] = securityInfo; if (securityInfo is QuotV5.StaticInfo.OptionSecuirtyInfo) { QuotV5.StaticInfo.OptionSecuirtyInfo optionSecurityInfo = securityInfo as QuotV5.StaticInfo.OptionSecuirtyInfo; FutureQuotation preFutureQuotation = null; FutureQuotation newFutureQuotation = null; if (ProcessedDataSnap.FutureQuotation.TryGetValue(securityInfo.CommonInfo.SecurityID, out preFutureQuotation)) { newFutureQuotation = preFutureQuotation.Clone(); SetFutureQuotationProperty(newFutureQuotation, optionSecurityInfo); } else { newFutureQuotation = new FutureQuotation(); SetFutureQuotationProperty(newFutureQuotation, optionSecurityInfo); } if (newFutureQuotation != null) { ProcessedDataSnap.FutureQuotation[newFutureQuotation.stkId] = newFutureQuotation; quotRepository.UpdateFutureQuotation(newFutureQuotation); } } else { StockInfo preStockInfo = null; StockInfo newStockInfo = null; if (ProcessedDataSnap.StockInfo.TryGetValue(securityInfo.CommonInfo.SecurityID, out preStockInfo)) { newStockInfo = preStockInfo.Clone(); SetStockInfoProperty(newStockInfo, securityInfo); } else { newStockInfo = new StockInfo(); SetStockInfoProperty(newStockInfo, securityInfo); } if (newStockInfo != null) { ProcessedDataSnap.StockInfo[newStockInfo.stkId] = newStockInfo; quotRepository.UpdateBasicInfo(newStockInfo); } } }
void _lib_OnTwQuote(StockInfo stockQuote) { }
private void ProcessStaticInfo(QuotV5.StaticInfo.SecurityCloseMD securityInfo) { RawStaticInfoSnap.SecurityCloseMD[securityInfo.SecurityID] = securityInfo; StockInfo preStockInfo = null; StockInfo newStockInfo = null; if (ProcessedDataSnap.StockInfo.TryGetValue(securityInfo.SecurityID, out preStockInfo)) { newStockInfo = preStockInfo.Clone(); SetStockInfoProperty(newStockInfo, securityInfo); } else { newStockInfo = new StockInfo(); SetStockInfoProperty(newStockInfo, securityInfo); } if (newStockInfo != null) { ProcessedDataSnap.StockInfo[newStockInfo.stkId] = newStockInfo; quotRepository.UpdateBasicInfo(newStockInfo); } }
private void SaveModify(int voucherNo) { BindingSource bslistSP = (BindingSource)dgvSP.DataSource; BindingList <ReceiptModel> listSP = (BindingList <ReceiptModel>)bslistSP.DataSource; //Adding in Receipt var objRec = (from rec in entities.Receipts where rec.VNo == voucherNo select rec).FirstOrDefault(); if (objRec != null) { objRec.VNo = voucherNo; objRec.VDate = dtDate.Value; objRec.CustType = ((KeyValuePair <string, string>)cmbCustType.SelectedValue).Key; objRec.LCode = Convert.ToString(cmbCustomer.SelectedValue); objRec.GrossWt = Convert.ToDecimal(txtTotalGsWt.Text.Trim()); objRec.NetWt = Convert.ToDecimal(txtTotalNetWt.Text.Trim()); objRec.MakingTotal = Convert.ToDecimal(txtTotalMakingRate.Text.Trim()); objRec.Remarks = txtRemark.Text.Trim(); entities.Entry(objRec).State = System.Data.Entity.EntityState.Modified; foreach (ReceiptModel rcModel in listSP) { if (String.IsNullOrEmpty(rcModel.BarCode)) { #region InOut if (rcModel.TID > 0) { //Modify in InOut var model = (from inout in entities.InOuts where inout.RefVNo == voucherNo && inout.TID == rcModel.TID select inout).FirstOrDefault(); if (model != null) { model.SeqNo = rcModel.SeqNo; model.TDate = rcModel.TDate; model.PCode = rcModel.PCode; model.MetalType = rcModel.MetalType; model.TType = rcModel.InType; model.RefVNo = voucherNo; model.RefVouType = rcModel.RefVouType; model.JobNo = rcModel.JobNo; model.OrderNo = rcModel.OrderNo; model.Pcs = rcModel.Pcs; model.GrossWt = rcModel.GrossWt; model.NetWt = rcModel.NetWt; model.MakingRate = rcModel.MakingRate; model.TotalRate = rcModel.TotalRate; model.SellingRate = rcModel.SellingRate; entities.Entry(model).State = System.Data.Entity.EntityState.Modified; } } else { //Add in InOut InOut model = new InOut(); model.SeqNo = rcModel.SeqNo; model.TDate = rcModel.TDate; model.PCode = rcModel.PCode; model.MetalType = rcModel.MetalType; model.TType = rcModel.InType; model.RefVNo = voucherNo; model.RefVouType = rcModel.RefVouType; model.JobNo = rcModel.JobNo; model.OrderNo = rcModel.OrderNo; model.Pcs = rcModel.Pcs; model.GrossWt = rcModel.GrossWt; model.NetWt = rcModel.NetWt; model.MakingRate = rcModel.MakingRate; model.TotalRate = rcModel.TotalRate; model.SellingRate = rcModel.SellingRate; entities.InOuts.Add(model); } #endregion } else { #region StockInfo if (rcModel.TID > 0) { //Modify in InOut var model = (from stockInfo in entities.StockInfoes where stockInfo.RefVNo == voucherNo && stockInfo.TID == rcModel.TID select stockInfo).FirstOrDefault(); if (model != null) { model.SeqNo = rcModel.SeqNo; model.TDate = rcModel.TDate; model.PCode = rcModel.PCode; model.BarCode = rcModel.BarCode; model.MetalType = rcModel.MetalType; model.InType = rcModel.InType; model.RefVNo = voucherNo; model.RefVouType = rcModel.RefVouType; model.JobNo = rcModel.JobNo; model.OrderNo = rcModel.OrderNo; model.Pcs = rcModel.Pcs; model.GrossWt = rcModel.GrossWt; model.NetWt = rcModel.NetWt; model.MakingRate = rcModel.MakingRate; model.TotalRate = rcModel.TotalRate; model.SellingRate = rcModel.SellingRate; model.Photo = rcModel.Photo; //Add Image //this.savePictureToFile(model); entities.Entry(model).State = System.Data.Entity.EntityState.Modified; } } else { //Add in StockInfo StockInfo model = new StockInfo(); model.SeqNo = rcModel.SeqNo; model.TDate = rcModel.TDate; model.PCode = rcModel.PCode; model.BarCode = rcModel.BarCode; model.MetalType = rcModel.MetalType; model.InType = rcModel.InType; model.RefVNo = voucherNo; model.RefVouType = rcModel.RefVouType; model.JobNo = rcModel.JobNo; model.OrderNo = rcModel.OrderNo; model.Pcs = rcModel.Pcs; model.GrossWt = rcModel.GrossWt; model.NetWt = rcModel.NetWt; model.MakingRate = rcModel.MakingRate; model.TotalRate = rcModel.TotalRate; model.SellingRate = rcModel.SellingRate; model.Photo = rcModel.Photo; //Add Image //this.savePictureToFile(model); entities.StockInfoes.Add(model); } #endregion } } } entities.SaveChanges(); //} #region Saving imgages foreach (ReceiptModel rcModel in listSP) { if (!String.IsNullOrEmpty(rcModel.BarCode)) { var model = (from stk in entities.StockInfoes where stk.RefVNo == voucherNo && stk.RefVouType == "R" && stk.BarCode == rcModel.BarCode select stk).FirstOrDefault(); if (model != null) { //Delete file for voucher string rootPath = Application.StartupPath; string relativePath = String.Format("\\Data\\Images\\{0}\\", model.TID); if (Directory.Exists(rootPath + relativePath)) { Directory.Delete(rootPath + relativePath, true); } if (rcModel.ProdImage != null) { bool success = MiscUtils.SavePictureToFile(rcModel.ProdImage, rootPath + relativePath, model.TID); if (success) { model.Photo = string.Format("{0}{1}.jpg", relativePath, model.TID); } } } } } entities.SaveChanges(); #endregion }
private void SetStockInfoProperty(StockInfo stockInfo, QuotV5.StaticInfo.SecurityInfoBase securityInfo) { stockInfo.stkId = securityInfo.CommonInfo.SecurityID; stockInfo.stkName = securityInfo.CommonInfo.Symbol; stockInfo.stkEnglishtAbbr = securityInfo.CommonInfo.EnglishName; stockInfo.stkParValue = securityInfo.CommonInfo.ParValue; stockInfo.totalCurrentStkQty = (Int64)securityInfo.CommonInfo.PublicFloatShareQuantity; stockInfo.listedDate = securityInfo.CommonInfo.ListDate; stockInfo.standardConvertRate = securityInfo.CommonInfo.ContractMultiplier; stockInfo.closePrice = securityInfo.CommonInfo.PrevClosePx; stockInfo.basicStkId = securityInfo.CommonInfo.UnderlyingSecurityID; stockInfo.ISINCode = securityInfo.CommonInfo.ISIN; stockInfo.CMOStandardRate = securityInfo.CommonInfo.GageRatio; stockInfo.totalStkQty = (Int64)securityInfo.CommonInfo.OutstandingShare; stockInfo.isCreditCashStk = securityInfo.CommonInfo.CrdBuyUnderlying; stockInfo.isCreditShareStk = securityInfo.CommonInfo.CrdSellUnderlying; if (securityInfo is QuotV5.StaticInfo.StockSecurityInfo) { QuotV5.StaticInfo.StockParams para = (securityInfo as QuotV5.StaticInfo.StockSecurityInfo).Params; stockInfo.stkIndustryType = para.IndustryClassification; stockInfo.lastYearProfit = para.PreviousYearProfitPerShare; stockInfo.thisYearProfit = para.CurrentYearProfitPerShare; } else if (securityInfo is QuotV5.StaticInfo.BondSecurityInfo) { QuotV5.StaticInfo.BondParams para = (securityInfo as QuotV5.StaticInfo.BondSecurityInfo).Params; stockInfo.endingDate = para.MaturityDate; stockInfo.accuredInterest = para.Interest; stockInfo.beginInterestDate = para.InterestAccrualDate; } else if (securityInfo is QuotV5.StaticInfo.FundSecurityInfo) { QuotV5.StaticInfo.FundParams para = (securityInfo as QuotV5.StaticInfo.FundSecurityInfo).Params; stockInfo.NAV = para.NAV; } }
public Stock() { _observers = new List<IObserver>(); _stockInfo = new StockInfo(); }
private void SetStockInfoProperty(StockInfo stockInfo, QuotV5.StaticInfo.IndexInfo securityInfo) { stockInfo.stkId = securityInfo.SecurityID; stockInfo.stkName = securityInfo.Symbol; stockInfo.stkEnglishtAbbr = securityInfo.EnglishName; stockInfo.closePrice = securityInfo.PrevCloseIdx; }
public Form1() { InitializeComponent(); StockInfo reader = new StockInfo(this.Handle, "000001", "上证指数"); }
private void SetStockInfoProperty(StockInfo stockInfo, QuotV5.StaticInfo.CashAuctionParams cashAuctionParams) { stockInfo.stkId = cashAuctionParams.SecurityID; stockInfo.buyQtyUpperLimit = (int)cashAuctionParams.BuyQtyUpperLimit; stockInfo.sellQtyUpperLimit = (int)cashAuctionParams.SellQtyUpperLimit; stockInfo.orderPriceUnit = cashAuctionParams.PriceTick; stockInfo.marketMarkerFlag = cashAuctionParams.MarketMakerFlag; }
public int InsertStock(StockInfo stock, SqlTransaction trans) { string sql = @"INSERT INTO [Stock] ([WarehouseID] ,[ProductID] ,[StockInTP] ,[StockInDate] ,[StockInReason] ,[StockOutTP] ,[StockOutDate] ,[StockOutReason] ,[Num] ,[InsertDateTime] ,[InsertUser]) VALUES (@WarehouseID ,@ProductID ,@StockInTP ,@StockInDate ,@StockInReason ,@StockOutTP ,@StockOutDate ,@StockOutReason ,@Num ,@InsertDateTime ,@InsertUser)"; SqlParameter[] spvalues = DBTool.GetSqlPm(stock); return SqlHelper.ExecuteNonQuery(trans, System.Data.CommandType.Text, sql, spvalues); }
private void SetStockInfoProperty(StockInfo stockInfo, QuotV5.StaticInfo.NegotiationParams negotiationParams) { stockInfo.stkId = negotiationParams.SecurityID; }
public void UpdateBasicInfo(StockInfo stockInfo) { byte[] stockInfoBytes = JsonSerializer.ObjectToBytes<StockInfo>(stockInfo); string stkId = stockInfo.stkId; string key = string.Format("{0}:{1}", stockQuotSource.ToFormatString(), QuotationDataType.StockInfo.ToFormatString()); QuotationPublisher.Publisher.Update(key, stkId, stockInfoBytes); }
public Data_Quote_Swap(StockInfo stockInfo = null) : base(stockInfo) { }