Exemplo n.º 1
0
        //保存更改信息
        private void SaveGoodsInfo_Click(object sender, RoutedEventArgs e)
        {
            if (tb_Gno.Text == "" ||
                tb_Gname.Text == "" ||
                tb_Gmanufacturer.Text == "")
            {
                MessageBox.Show("未填满空项", "错误", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            Goods goods = new Goods(tb_Gno.Text, tb_Gname.Text,
                                    tb_Gmanufacturer.Text);
            GoodsAdapter adapter = new GoodsAdapter(
                SQLConnection.GetDataBase());

            try
            {
                adapter.AddOneGoods(goods);
                MessageBox.Show("添加商品成功", "提醒", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常发生,请检查数据库连接或数据是否符合标准", "错误", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                //写入日志
            }
        }
        //加载进货细节
        private void LoadPurchaseDetailData(int selectedIndex)
        {
            if (selectedIndex == -1)
            {
                return;
            }

            string purcharnum = (LV_PurchaseAndSupplier.Items[selectedIndex]
                                 as DataRowView)["Pno"].ToString();                 //获取选择的进货单号

            DataSet      GoodsList;
            DataTable    GoodsTable;
            GoodsAdapter gadapter = new GoodsAdapter(
                SQLConnection.GetDataBase());
            PurchaseDetailAdapter pdadapter = new PurchaseDetailAdapter(
                SQLConnection.GetDataBase());

            PurchaseDetailList = pdadapter.GetAllPurchaseDetail();
            DataSetHelper pdhelper = new DataSetHelper(ref PurchaseDetailList);

            //获取所有商品信息
            GoodsList  = gadapter.GetAllGoods();
            GoodsTable = GoodsList.Tables["Goods"];

            GoodsList.Tables.Remove("Goods");
            PurchaseDetailList.Tables.Add(GoodsTable);  //添加子表
            PurchaseDetailList.Relations.Add("PDAndG", PurchaseDetailList.Tables["Goods"].Columns["Gno"],
                                             PurchaseDetailList.Tables["PurchaseDetail"].Columns["Gno"]);

            pdhelper.SelectJoinInto("PurchaseDeatailAndGoods", PurchaseDetailList.Tables["PurchaseDetail"],
                                    "Gno,PDAndG.Gname,PDnum,PDprice",
                                    string.Format("Pno = '{0}'", purcharnum), "Gno");
            LV_PurchaseDetail.ItemsSource = PurchaseDetailList.Tables["PurchaseDeatailAndGoods"].DefaultView;
        }
Exemplo n.º 3
0
 //加载数据
 private void LoadData()
 {
     try
     {
         GoodsAdapter adapter = new GoodsAdapter(SQLConnection.GetDataBase());
         Goods = adapter.GetAllGoods();        //获取所有供应商信息
         LV_Goods.ItemsSource = Goods.Tables[0].DefaultView;
     }
     catch (Exception ex)
     {
         MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK,
                         MessageBoxImage.Error);
         //写入日志
     }
 }