private void refreshDataView() // binding source change { consumeNum = 0; foreach (var detail in details_Num) { ArrayList goodNum = detail.Value; goodInfo temp = new goodInfo(detail.Key, Convert.ToDouble(goodNum[0]), (int)goodNum[1]); consumeNum += temp.tPrice; goodsList.Add(temp); //BindingList<goodInfo> temp = if (Items_Details.InvokeRequired) { Action listDel = () => { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); }; Items_Details.Invoke(listDel); } else { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); } if (Cost_Text.InvokeRequired) { Action <string> CostDel = (x) => { Cost_Text.Text = x.ToString(); }; Cost_Text.Invoke(CostDel, consumeNum.ToString()); } else { Cost_Text.Text = consumeNum.ToString(); } } double bal = meb.balance - consumeNum; if (bal < 0) { MessageBox.Show("余额不足"); return; } if (billNumber == "") { billNumber = InStock.getSoldBillNumber(); billNumber = BillHelper.getNextBillNumber(billNumber); } foreach (goodDetail goodTemp in goodsDetailList) { ArrayList detail = details_Num[goodTemp.name]; InStock.updateMemCostDetail(new costInfo(meb.ID, goodTemp.ID, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(), billNumber, Convert.ToInt32(detail[1]), Convert.ToDouble(detail[0]) / Convert.ToInt32(detail[1]), Convert.ToDouble(detail[0]))); } InStock.updateMemBalance(meb.ID, bal); //setUserData(bal.ToString()); }
//用户离开后刷新页面内容为空 private void initialAllInfo() { meb = null; tagList.Clear(); goodsDetailList.Clear(); details_Num.Clear(); goodsList.Clear(); if (Items_Details.InvokeRequired) { Action listDel = () => { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); }; Items_Details.Invoke(listDel); } else { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); } if (Cost_Text.InvokeRequired) { Action <string> CostDel = (x) => { Cost_Text.Text = x.ToString(); }; Cost_Text.Invoke(CostDel, ""); } else { Cost_Text.Text = ""; } if (ID_Text.InvokeRequired) { Action <string> IDDel = (x) => { ID_Text.Text = x.ToString(); }; ID_Text.Invoke(IDDel, ""); } else { ID_Text.Text = ""; } billNumber = ""; }