//加载进货细节
        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;
        }
        private void Init()
        {
            try
            {
                //设定绑定源(进货信息)
                Grid_Purchase.DataContext = PurchaseInfo;
                //设定绑定源(进货明细列表)
                if (bAddPurchase)        //添加进货
                {
                    //设置进货日期为当前日期
                    dp_PDate.SelectedDate = DateTime.Now;
                    PurchaseDetailList    = pdadapter.CreateEmptyDataset();
                    PurchaseDetailList.Tables["PurchaseDetail"].Columns.Add("Gname", Type.GetType("System.String"));      //添加商品名称列
                }
                else
                {
                    dp_PDate.SelectedDate = PurchaseInfo.PDate;

                    DataSet supplierInfo = supplierAdapter.GetSupplierBySupplierNum(PurchaseInfo.Sno);
                    tb_Pno.IsReadOnly = true;
                    tb_Supplier.Text  = supplierInfo.Tables["Supplier"].Rows[0]["Sname"].ToString();

                    string PDname = "PurchaseDeatail_T";
                    //获取所有商品信息
                    DataSet   GoodsList  = goodsAdapter.GetAllGoods();
                    DataTable GoodsTable = GoodsList.Tables["Goods"];

                    //获取指定进货批次的进货明细
                    PurchaseDetailList = pdadapter.GetPurchaseDetailByPurchaseNum(PurchaseInfo.Pno);
                    PurchaseDetailList.Tables["PurchaseDetail"].TableName = PDname;     //修改表名

                    DataSetHelper pdhelper = new DataSetHelper(ref PurchaseDetailList);

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

                    pdhelper.SelectJoinInto("PurchaseDetail", PurchaseDetailList.Tables[PDname],
                                            "Pno,Gno,PDnum,PDprice,PDAndG.Gname", "1=1", "Gno");
                }

                LV_PurchaseDetail.ItemsSource = PurchaseDetailList.Tables["PurchaseDetail"].DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                //写入日志

                this.Close();
            }
        }
示例#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);
         //写入日志
     }
 }
示例#4
0
 //初始化操作
 private void Init()
 {
     try
     {
         GoodsList = goodsAdapter.GetAllGoods();          //获取所有商品信息
         GoodsList.Tables["Goods"].TableName = TableName; //修改表名
         GoodsList.Tables[TableName].Columns.Add("LmGstore", Type.GetType("System.Double"));
         GoodsList.Tables[TableName].Columns.Add("PGnum", Type.GetType("System.Double"));
         GoodsList.Tables[TableName].Columns.Add("SGnum", Type.GetType("System.Double"));
         GoodsList.Tables[TableName].Columns.Add("Gstore", Type.GetType("System.Double"));
     }
     catch (Exception ex)
     {
         MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK,
                         MessageBoxImage.Error);
         //写入日志
     }
 }