private void btn_add_Click(object sender, EventArgs e) { if (!Checker.Check_Number(txt_optnum.Text.Trim(), false)) { MessageBox.Show("数量输入不正确"); return; } if (cbx_tp.SelectedIndex == -1) { MessageBox.Show("未选择操作类型"); return; } GoodsMenu menu = new GoodsMenu(); txt_menuid.Text = UpdateMulGoodsHelper.get_menu_id(user, dt_opttime.Value, ++menu_list_count); menu.MenuId = txt_menuid.Text.Trim(); menu.Date = dt_opttime.Value; menu.OptPeopleId = user.Userid; menu.TxtMsg = txt_msg.Text.Trim(); menu.Number = txt_optnum.Text.Trim(); menu.Goods = GoodsMSHelper.Select_goods_by_goodsId(txt_goodsid.Text.Trim()); if (menu.Goods == null) { MessageBox.Show("记录中不存在该货物"); return; } list.Add(new KeyValuePair <GoodsMenu, int>(menu, cbx_tp.SelectedIndex)); lis_menu.Items.Add(UpdateMulGoodsHelper.add_list_message(menu, cbx_tp.SelectedIndex)); this.btn_fresh_Click(sender, e); }
private void fresh_menu_by_del_line() { if (lis_menu.SelectedItem == null) { return; } if (MessageBox.Show("确认删除这一项?", "确认删除这一项?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } var arr = lis_menu.SelectedItem.ToString().Split(' '); string good_id = arr[0]; string good_num = arr[3]; if (!Checker.Check_Number(good_num)) { MessageBox.Show("库存修改数值错误"); return; } foreach (var x in list) { if (x.Key.Goods.Goods_id.Equals(good_id) && x.Key.Number.Equals(good_num)) { list.Remove(x); string tmp = UpdateMulGoodsHelper.add_list_message(x.Key, x.Value); lis_menu.Items.Remove(UpdateMulGoodsHelper.add_list_message(x.Key, x.Value)); break; } } }