private void AddLogisticsForm_Load(object sender, EventArgs e)
 {
     htWareHouse = LogisticCtrl.listWarehouse();
     comboBox1.Items.Clear();
     foreach (DictionaryEntry de in htWareHouse)
     {
         comboBox1.Items.Add((string)de.Key);
     }
     LogisticCtrl.loadProduct(null, listView1);
     LogisticCtrl.loadCompany(listView2);
     LogisticCtrl.loadReadyToChoose(listView4);
     choose.Clear();
 }
 private void Button4_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < choose.Count; i++)
     {
         ListViewItem li           = choose[i];
         string       thingsNo     = li.Text.ToString();
         string       warehouseNo  = li.SubItems[2].Text;
         string       numberWanted = li.SubItems[5].Text;
         LogisticCtrl.recoverStock(thingsNo, warehouseNo, numberWanted);
     }
     LogisticCtrl.loadReadyToChoose(listView4);
     choose.Clear();
     Button1_Click(null, null);
 }
        private void ListView4_DoubleClick(object sender, EventArgs e)
        {
            string thingsNo     = listView4.SelectedItems[0].Text.ToString();
            string warehouseNo  = listView4.SelectedItems[0].SubItems[2].Text;
            string numberWanted = listView4.SelectedItems[0].SubItems[4].Text;

            choose.Remove(listView4.SelectedItems[0]);
            LogisticCtrl.recoverStock(thingsNo, warehouseNo, numberWanted);
            LogisticCtrl.loadReadyToChoose(listView4);
            for (int i = 0; i < choose.Count; i++)
            {
                listView4.Items.Add(choose[i]);
            }
            Button1_Click(null, null);
        }
        private void Button3_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count != 1)
            {
                MessageBox.Show("请你指定一种商品");
                return;
            }
            if (this.listView2.SelectedItems.Count != 1)
            {
                MessageBox.Show("请你指定一家快递公司");
                return;
            }
            string numberWanted = textBox5.Text;

            if (numberWanted == "")
            {
                MessageBox.Show("请输入商品数量");
                return;
            }
            string thingsNo    = listView1.SelectedItems[0].Text.ToString();
            string warehouseNo = listView1.SelectedItems[0].SubItems[2].Text;
            string totalNumber = listView1.SelectedItems[0].SubItems[4].Text;

            if (int.Parse(numberWanted) > int.Parse(totalNumber))
            {
                MessageBox.Show("该商品数量不够");
                return;
            }
            if (choose.Count == 0)
            {
                chooseWNo = warehouseNo;
                companyNo = listView2.SelectedItems[0].Text.ToString();
            }
            else if (chooseWNo != warehouseNo)
            {
                MessageBox.Show("本订单只能选择一个发货地址");
                return;
            }
            else if (companyNo != listView2.SelectedItems[0].Text.ToString())
            {
                MessageBox.Show("本订单只能选择一家快递公司");
                return;
            }
            string number = (-int.Parse(numberWanted) + int.Parse(totalNumber)).ToString();

            if (LogisticCtrl.updateStock(thingsNo, warehouseNo, number) == false)
            {
                MessageBox.Show("加入失败");
                return;
            }
            int p = Productctrl.searchprice(thingsNo);

            for (int i = 0; i < choose.Count; i++)
            {
                if (thingsNo == choose[i].SubItems[0].Text)
                {
                    ListViewItem listItem1 = choose[i];
                    listItem1.SubItems[5].Text = (int.Parse(choose[i].SubItems[5].Text) + int.Parse(numberWanted)).ToString();
                    listItem1.SubItems[6].Text = (int.Parse(choose[i].SubItems[5].Text) * p).ToString();
                    LogisticCtrl.loadReadyToChoose(listView4);
                    for (int j = 0; j < choose.Count; j++)
                    {
                        listView4.Items.Add(choose[j]);
                    }
                    Button1_Click(null, null);
                    return;
                }
            }
            ListViewItem li = new ListViewItem();//形成一个表项

            li.SubItems.Clear();
            li.SubItems[0].Text = thingsNo;                               //设置第一列
            li.SubItems.Add(listView1.SelectedItems[0].SubItems[1].Text); //其余的列
            li.SubItems.Add(warehouseNo);                                 //其余的列
            li.SubItems.Add(listView1.SelectedItems[0].SubItems[3].Text); //其余的列
            li.SubItems.Add(listView2.SelectedItems[0].SubItems[1].Text); //其余的列
            li.SubItems.Add(numberWanted);                                //其余的列
            string price = (int.Parse(numberWanted) * p).ToString();

            //string cost = int.Parse(this.listView2.SelectedItems[0].SubItems[2].Text).ToString();
            //string totalcost = (int.Parse(price) + int.Parse(cost)).ToString();
            li.SubItems.Add(price);
            //li.SubItems.Add(cost);
            //li.SubItems.Add(totalcost);
            listView4.Items.Add(li);
            choose.Add(li);
            Button1_Click(null, null);
        }