public void Updata(string category, float buyPrice, float sellPrice) { if (sellPrice != 0) { for (int i = 0; i < sellData.Count; i++) { var v = sellData[i]; OneListed ci = v.obj as OneListed; if (ci != null) { if (ci.pricingMethod == "0" && ci.premium != null && ci.contract != null && category.EndsWith(ci.contract)) { SetData(ci, v.data, v, 1); } } } } if (buyPrice != 0) { for (int i = 0; i < buyData.Count; i++) { var v = buyData[i]; OneListed ci = v.obj as OneListed; if (ci != null) { if (ci.pricingMethod == "0" && ci.premium != null && ci.contract != null && category.EndsWith(ci.contract)) { SetData(ci, v.data, v, 1); } } } } }
/// <summary> /// 数据对象 /// </summary> /// <param name="info">数据</param> /// <param name="type">0为买 1为卖</param> public void InsertData(OneListed info, int type) { // if (info.blackWhiteType != "0") { MLabels data = new MLabels(); data.BackColor = COLOR.RGB(MCommonData.fontColor6); data.MouseBackColor = COLOR.RGB(MCommonData.fontColor10); UData ud = new UData(); for (int i = 0; i < 10; i++) { MLabel ml = new MLabel(); ml.ForeColor = COLOR.RGB(MCommonData.fontColor4); ml.MouseForeColor = COLOR.RGB(MCommonData.fontColor4); ml.BackColor = -1; ml.Font = MCommonData.d4Font; ml.LeftAligned = true; data.lbs.Add(ml); } data.lbs[6].MouseForeColor = COLOR.RGB(MCommonData.fontColor2); data.lbs[6].Underline = true; data.lbs[9].ForeColor = COLOR.RGB(MCommonData.fontColor8); if (type == 0) { buyData.Add(ud); } else { sellData.Add(ud); } SetData(info, data, ud, type); } }
public void Updata(OneListed info) { if (info == null) { return; } for (int i = 0; i < buyData.Count; i++) { var v = buyData[i]; OneListed ci = v.obj as OneListed; if (ci != null && info.id == ci.id) { ci.Update(info); if (ci.blackWhiteType == "0" || (ci.transStatus == "2" && ci.commAvailableQuantity == "0") || ci.transStatus == "3" || ci.transStatus == "4") { buyData.Remove(v); } else { SetData(ci, v.data, v, 1); } return; } } for (int i = 0; i < sellData.Count; i++) { var v = sellData[i]; OneListed ci = v.obj as OneListed; if (ci != null && info.id == ci.id) { ci.Update(info); if (ci.blackWhiteType == "0" || (ci.transStatus == "2" && ci.commAvailableQuantity == "0") || ci.transStatus == "3" || ci.transStatus == "4") { sellData.Remove(v); } else { SetData(ci, v.data, v, 0); } return; } } }
private void SetData(OneListed info, MLabels data, UData ud, int type) { if (info == null || data == null || ud == null || data.lbs == null || data.lbs.Count == 0) { return; } data.lbs[0].Text = info.transTypeName; data.lbs[1].Text = info.commLevelName; if (string.IsNullOrWhiteSpace(info.contract)) { data.lbs[2].Text = "--"; } else { data.lbs[2].Text = info.contract; } if (string.IsNullOrWhiteSpace(info.premium)) { data.lbs[3].Text = "--"; } else { data.lbs[3].Text = info.premium; } if (info.pricingMethod == "0" && info.premium != null) { var vvv = DataManager.Instance.GetContractLastPrice(info.contract); if (vvv != null) { int premium; int.TryParse(info.premium, out premium); if (premium != 0) { if (type == 0) { info.fixedPrice = (vvv.bidPrice + premium).ToString(); } else { info.fixedPrice = (vvv.askPrice + premium).ToString(); } } } } decimal money; decimal.TryParse(info.fixedPrice, out money); if (money > 0) { data.lbs[4].Text = string.Format("{0:C}", money); } else { data.lbs[4].Text = ""; } data.lbs[5].Text = info.commAvailableQuantity; string text = info.warehouseName; if (text != null && text.Length >= 6) { text = text.Substring(0, 6) + "..."; } data.lbs[6].Text = text; data.lbs[7].Text = info.publisher; data.lbs[8].Text = info.remarks; long l; long.TryParse(info.publisherDate, out l); DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); data.lbs[9].Text = start.AddMilliseconds(l).ToLocalTime().ToString("HH:mm:ss"); if (DataManager.Instance.LoginData != null) { ud.data1image = new MImage(); if (info.createdBy == DataManager.Instance.LoginData.id) { ud.data1image.BackgroundImage = Resources.icon_publish; } else if (DataManager.Instance.WhiteEnable && DataManager.Instance.WhiteDY != null && info.publisher != null && DataManager.Instance.WhiteDY.ContainsKey(info.publisher)) { ud.data1image.BackgroundImage = Resources.icon_white; } else if (DataManager.Instance.BlackEnable && DataManager.Instance.BlackDY != null && info.publisher != null && DataManager.Instance.BlackDY.ContainsKey(info.publisher)) { ud.data1image.BackgroundImage = Resources.icon_black; } else { ud.data1image = null; } } data.Tag = ud; ud.obj = info; ud.data = data; ud.house = data.lbs[6];//仓库信息 if (type == 0) { scrollbar2.CalculationSliderWith(buyData.Count * dataInterval); } else { scrollbar1.CalculationSliderWith(sellData.Count * dataInterval); } }