public void addLisBox(codeClass code, bool moveToTop) { if (code.Id.Length < 8) return; code.Id = Regex.Replace(code.Id, "^0+", "P"); if (code.Id.StartsWith("P", StringComparison.CurrentCultureIgnoreCase)) { showDuplicateMsg(code, code.Id + "\r\n" + "不可添加包号"); return; } if (checkDuplicate(code.Id) != false) { showDuplicateMsg(code, code.Id + "\r\n" + "已存在"); return; } PlaySound("beep.wav", IntPtr.Zero, (Int32)Beep.SND_FILENAME | (Int32)Beep.SND_ASYNC); Data.codeList.Add( code ); updateLisBox_datasource(); if (moveToTop) listBox1.SelectedIndex = 0; }
public void showDuplicateMsg(codeClass code) { lblDuplicate.Show(); lblDuplicate.Text = code.Id + "\r\n" + "已存在"; PlaySound("infbeg.wav", IntPtr.Zero, (Int32)Beep.SND_FILENAME | (Int32)Beep.SND_ASYNC); inter1.Enabled = false; inter1.Interval = 1000; // 1 second inter1.Tick += delegate { lblDuplicate.Hide(); inter1.Enabled = false; }; inter1.Enabled = true; }
public void setListboxItem(string sn, codeClass item) { for (int i = 0; i < listBox1.Items.Count; i++) { codeClass code = ((codeClass)listBox1.Items[i]); if (code.Id == sn) { listBox1.Items[i] = item; return; } } return ; }
public void addLisBox(codeClass code, bool moveToTop) { if (code.Id == "") { return; } code.Id = Regex.Replace(code.Id, "^0+", "P"); if (checkDuplicate(code.Id) != false) { showDuplicateMsg(code); return; } if (code.Id.Length < 8) return; PlaySound("beep.wav", IntPtr.Zero, (Int32)Beep.SND_FILENAME | (Int32)Beep.SND_ASYNC); Data.codeList.Insert(0,code); listBox1.Items.Insert(0, code); lv.Items.Clear(); if (moveToTop) listBox1.SelectedIndex = 0; }