//选择 private void btnSelect_Click(object sender, EventArgs e) { List <SelectStockInOrderDetail> alt = new List <SelectStockInOrderDetail>(); if (gridView1.RowCount > 0) { //采购订单guid int intRow = gridView1.GetSelectedRows()[0]; string strStockInOrderGuid = gridView1.GetRowCellValue(intRow, gridStockInOrderGuid).ToString(); //采购入库单id string strStockInOrderID = gridView1.GetRowCellValue(intRow, gridStockInOrderID).ToString(); SelectStockInOrderDetail SelectStockInOrderDetail = new SelectStockInOrderDetail(); //采购订单明细 for (int i = 0; i < gridView2.RowCount; i++) { if (gridView2.GetRowCellValue(i, gridCheckBox).ToString() == "True") { SelectStockInOrderDetail = new SelectStockInOrderDetail(); SelectStockInOrderDetail.StockInOrderGuid = strStockInOrderGuid; SelectStockInOrderDetail.StockInOrderID = strStockInOrderID; SelectStockInOrderDetail.StockInOrderDetailGuid = gridView2.GetRowCellValue(i, gridStockInOrderDetailGuid).ToString(); SelectStockInOrderDetail.StockInOrderDate = DateTime.Parse(gridView1.GetRowCellValue(intRow, gridStockInOrderDate).ToString()); SelectStockInOrderDetail.MaterialGuID = gridView2.GetRowCellValue(i, gridMaterialGuid).ToString(); SelectStockInOrderDetail.MaterialID = gridView2.GetRowCellValue(i, gridMaterialID).ToString(); SelectStockInOrderDetail.MaterialName = gridView2.GetRowCellValue(i, gridMaterialName).ToString(); decimal price = StockInOrderManage.GetStockOrderPriceByMaterial(gridView2.GetRowCellValue(i, gridStockOrderGuid).ToString(), SelectStockInOrderDetail.MaterialGuID); decimal StorageSum = decimal.Parse(gridView2.GetRowCellValue(i, gridStorageSum).ToString()); SelectStockInOrderDetail.MaterialPrice = price; SelectStockInOrderDetail.MaterialMoney = price * StorageSum; SelectStockInOrderDetail.StorageSum = StorageSum; SelectStockInOrderDetail.SupplierName = gridView1.GetRowCellValue(intRow, gridSupplierName).ToString(); alt.Add(SelectStockInOrderDetail); } } if (alt.Count <= 0) { //请选择记录 ShowMessage("请选择采购入库单数据!"); return; } this.Tag = alt; this.Close(); } }
//选择采购入库单 private void btnSelectStockInOrder_Click(object sender, EventArgs e) { frmSelectStockInOrder3 frmSelectStockInOrder3 = new frmSelectStockInOrder3(); frmSelectStockInOrder3.ShowDialog(); if (frmSelectStockInOrder3.Tag != null) { //取出选择的料件Guid List <SelectStockInOrderDetail> lstGuid = frmSelectStockInOrder3.Tag as List <SelectStockInOrderDetail>; SelectStockInOrderDetail SelectStockInOrderDetail = new SelectStockInOrderDetail(); //选择的品名填充 if (lstGuid.Count > 0) { //得到入库单的信息 for (int i = 0; i < lstGuid.Count; i++) { SelectStockInOrderDetail = lstGuid[i] as SelectStockInOrderDetail; //填充数据 gridView2.AddNewRow(); gridView2.SetFocusedRowCellValue(gridStockInOrderGuid, SelectStockInOrderDetail.StockInOrderGuid); gridView2.SetFocusedRowCellValue(gridStockInOrderID, SelectStockInOrderDetail.StockInOrderID); gridView2.SetFocusedRowCellValue(gridStockInOrderDate, DateTime.Parse(SelectStockInOrderDetail.StockInOrderDate.ToString()).ToString("yyyy-MM-dd")); gridView2.SetFocusedRowCellValue(gridSupplierName, SelectStockInOrderDetail.SupplierName); gridView2.SetFocusedRowCellValue(gridMaterialGuID, SelectStockInOrderDetail.MaterialGuID); gridView2.SetFocusedRowCellValue(gridMaterialID, SelectStockInOrderDetail.MaterialID); gridView2.SetFocusedRowCellValue(gridMaterialName, SelectStockInOrderDetail.MaterialName); gridView2.SetFocusedRowCellValue(gridMaterialPrice, SelectStockInOrderDetail.MaterialPrice.ToString("g0")); gridView2.SetFocusedRowCellValue(gridMaterialSum, SelectStockInOrderDetail.StorageSum.ToString("g0")); gridView2.SetFocusedRowCellValue(gridMaterialMoney2, SelectStockInOrderDetail.MaterialMoney.ToString("g0")); gridView2.SetFocusedRowCellValue(gridOrderFlag, "采购入库单"); } } } }