private void stockRecord_init() { /** * 初始化listView **/ List <Item> items = daoManager.getItemDao().getAll(); ListViewItem it; foreach (Item i in items) { it = new ListViewItem(); it.Text = i.Id.ToString(); it.SubItems.Add(i.Name); it.SubItems.Add(i.Price); it.SubItems.Add(i.Number); it.SubItems.Add(i.Created_at.ToString()); this.stockRecord.Items.Add(it); sum += Convert.ToDouble(i.Price) * int.Parse(i.Number); } label3.Text = sum.ToString(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.TextLength == 0 || textBox2.TextLength == 0) { MessageBox.Show("请填完所有表单"); } else if (numericUpDown1.Value == 0) { MessageBox.Show("数量不能为0"); } else { Item = new Item(); Item.Name = textBox1.Text; Item.Number = Convert.ToString(numericUpDown1.Value); Item.Price = textBox2.Text; daoManager.getItemDao().add(Item); this.DialogResult = DialogResult.OK; } }