//private delegate void AddCallMemberEvent(AGV_CALLMember si); //private delegate void DeleteCallMemberEvent(AGV_CALLMember si); public bool Add(int stationnum, int materialnum) { bool flag = false; if (stationnum > 0 && materialnum > 0) { DAL.ZSql callSql = new DAL.ZSql(); bool bFind = memberData.Any<AGV_CALLMember>(p => p.iStationNum == stationnum && p.iMaterialNum == materialnum); if (!bFind) { AGV_CALLMember DisMember = new AGV_CALLMember(); DisMember.iNO = memberData.Count + 1; DisMember.dtTime = new DateTime(); DisMember.iStationNum = stationnum; DisMember.iMaterialNum = materialnum; callSql.Open("Select * from T_CallSetting where StationNum=" + stationnum.ToString() + " and MaterialNum=" + materialnum); if (callSql.rowcount > 0) { DisMember.sMaterialName = callSql.Rows[0]["MaterialName"].ToString(); DisMember.iLineNum = Convert.ToInt16(callSql.Rows[0]["LineNum"]); lineNum.Add(DisMember.iLineNum); flag = true; } callSql.Close(); /********************************* http://blog.csdn.net/luminji/article/details/5353644 典型应用场景:WPF页面程序中,ListView的ItemsSource是一个ObservableCollection<StudentInfo>; 操作:另起一个线程,为ListView动态更新数据,也就是给ObservableCollection<StudentInfo>添加记录。 这类操作,就是跨线程访问线程安全的数据,如果不使用Dispatcher,就会导致出错“该类型的CollectionView 不支持从调度程序线程以外的线程对其SourceCollection”。 **********************************/ //Dispatcher.Invoke(new AddCallMemberEvent(this.AddCallMember), DisMember); AddCallMember(DisMember); } } return flag; }
/// <summary> /// 删除成员 /// </summary> /// <param name="si">成员数据</param> private void DeleteCallMember(AGV_CALLMember si) { memberData.Remove(si); }
/// <summary> /// 添加成员 /// </summary> /// <param name="si">成员数据</param> private void AddCallMember(AGV_CALLMember si) { memberData.Add(si); }
/// <summary> /// 删除成员 /// </summary> /// <param name="si">成员数据</param> private void DeleteCallMember(AGV_CALLMember si) { memberData.Remove(si); RichTextBoxUpdate(si.dtTime.ToString() + ":工位" + si.iStationNum.ToString() + "(" + si.iMaterialNum.ToString() + ")" + "取消叫料成功" + "\r\n", Colors.Green); UpdateInfo(); }
/// <summary> /// 添加成员 /// </summary> /// <param name="si">成员数据</param> private void AddCallMember(AGV_CALLMember si) { memberData.Add(si); RichTextBoxUpdate(si.dtTime.ToString() + ":工位" + si.iStationNum.ToString() + "(" + si.iMaterialNum.ToString() + ") 缺" + si.sMaterialName + "\r\n", Colors.Red); UpdateInfo(); }