Beispiel #1
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (textBox4.Text == "")
            {
                MessageBox.Show("请输入件数!");
                return;
            }
            ListViewItem li    = this.listView1.SelectedItems[0];
            string       pNo   = li.SubItems[0].Text;
            int          price = (int.Parse)(li.SubItems[6].Text);
            string       wNo   = li.SubItems[2].Text;
            int          x;

            try
            {
                x = int.Parse(textBox4.Text);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
                return;
            }
            int amount = Productctrl.sumamount(wNo);
            int volume = int.Parse(li.SubItems[5].Text);

            if (Productctrl.update(x, pNo, wNo, volume, amount) && x > 0)
            {
                MessageBox.Show("产品进货成功!成本为" + price * x + "元");
            }
            button1_Click(null, null);
            if (listView2.Items.Count != 0)
            {
                button2_Click(null, null);
            }
        }
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            int input, volume;

            if (textBox4.Text == "")
            {
                MessageBox.Show("请输入产品数量!");
                return;
            }
            try
            {
                input  = int.Parse(textBox4.Text);
                volume = int.Parse(label6.Text);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
                return;
            }

            string wName  = comboBox1.Text;
            string wNo    = (string)hs[wName];
            int    amount = Productctrl.sumamount(wNo);

            if (input < 0)
            {
                MessageBox.Show("添加件数不可为负!");
                return;
            }
            if (input + amount > volume)
            {
                MessageBox.Show("添加件数超过仓库容量允许范围");
                return;
            }
            if (this.listView1.SelectedItems.Count != 1)
            {
                MessageBox.Show("请选择一个产品");
                return;
            }
            string pNo   = this.listView1.SelectedItems[0].Text.ToString();
            int    money = 0;

            if (Productctrl.addproduct(pNo, wNo, input, ref money))
            {
                MessageBox.Show("产品添加成功!成本为" + money.ToString() + "元");
            }
            button1_Click(null, null);
        }