public bool Add(string id, string name, int hold, double money) { double height = -5; if (StockStateBox.pre != null) { height = StockStateBox.pre.Margin.Top + StockStateBox.pre.Height; } StockStateBox box = new StockStateBox(new StockStateBox.ChangeValues(ID.change)); box.Margin = new Thickness(5, height + 10, 0, 0); box.stockid = id; string StockID = ""; string netname; if (NetState.CheckName("0" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "0" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else if (NetState.CheckName("1" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "1" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else { MessageBox.Show("股票编号:" + id + "错误!"); box.StockName.Text = name.Insert(2, "\r\n"); return(false); } box.hold.Text = hold.ToString(); box.basemoney = money; NetDataController.sync s = new NetDataController.sync(box.UpdataSync); if (!NetSyncController.Handler().StockRefreshAdd(StockID, ref s)) { NetSyncController.Handler().StockRefreshDelete(StockID); NetSyncController.Handler().StockRefreshAdd(StockID, ref s); } canvas.Children.Add(box); canvasbox.Add(box); return(true); }
public bool Add(string id,string name,int hold,double money) { double height = -5; if (StockStateBox.pre != null) height = StockStateBox.pre.Margin.Top + StockStateBox.pre.Height; StockStateBox box = new StockStateBox(new StockStateBox.ChangeValues(ID.change)); box.Margin = new Thickness(5, height + 10, 0, 0); box.stockid = id; string StockID = ""; string netname; if (NetState.CheckName("0" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "0" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else if (NetState.CheckName("1" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "1" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else { MessageBox.Show("股票编号:" + id + "错误!"); box.StockName.Text = name.Insert(2, "\r\n"); return false; } box.hold.Text = hold.ToString(); box.basemoney = money; NetDataController.sync s = new NetDataController.sync(box.UpdataSync); if (!NetSyncController.Handler().StockRefreshAdd(StockID, ref s)) { NetSyncController.Handler().StockRefreshDelete(StockID); NetSyncController.Handler().StockRefreshAdd(StockID, ref s); } canvas.Children.Add(box); canvasbox.Add(box); return true; }