private void confirmGoodButton_Click(object sender, RoutedEventArgs e) { IWareHouseDao whd = new WareHouseDao(); IProcurementDao ipd = new ProcementDao(); IGoodDao igd = new GoodDao(); Procurement procurment = new Procurement(); List <WareHouse> warehouseList = whd.getWareHouseList(); int warehouseid = Convert.ToInt32(warehouseBox.Text); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < warehouseList.Count; j++) { if (warehouseid == warehouseList[j].WareHouseID) { procurment.WareHouse = warehouseList[j]; Good good = igd.getSingleGood(Convert.ToInt32(dt.Rows[i][0])); Dictionary <Good, int> listgood_number = new Dictionary <Good, int>(); listgood_number.Add(good, Convert.ToInt32(dt.Rows[i][3])); //procurment还需要自己添加一个自身employee信息 procurment.addGood(good, listgood_number[good]); } } } DateTime now = DateTime.Now; procurment.WareHouse.WareHouseID = warehouseid; procurment.Employee.EmployeeID = 0; procurment.StorageTime = now; ipd.addProcurement(procurment); dt.Clear(); dataGridDetail.ItemsSource = dt.DefaultView; }
private void addGoodButton_Click(object sender, RoutedEventArgs e) { IGoodDao pd = new GoodDao(); DataRowView mySelectedElement = (DataRowView)dataGrid.SelectedItem; //获取datagrid选择的对象 string s = mySelectedElement.Row[0].ToString(); int i; if (int.TryParse(s, out i)) { //第二个datagrid添加一行数据, Good good = pd.getSingleGood(i); Good temp = new Good(); int GoodID = good.GoodID; string Name = good.Name; int number = 1; int warehouseId = 1; DataRow dr = dt.NewRow(); dr[0] = GoodID; dr[1] = Name; dr[2] = number; dr[3] = warehouseId; for (int m = 0; m < dt.Rows.Count; m++) { if (i == Convert.ToInt32(dt.Rows[m][0])) { dr[2] = Convert.ToInt32(dt.Rows[m][2]) + number; dt.Rows.RemoveAt(m); break; } } dt.Rows.Add(dr); dataGridDetail.ItemsSource = dt.DefaultView; } else { MessageBox.Show("请输入数字。"); } }
private void confirmGoodButton_Click(object sender, RoutedEventArgs e) { IWareHouseDao whd = new WareHouseDao(); IMoveRecordDao mrd = new MoveRecordDao(); IGoodDao igd = new GoodDao(); MoveRecord moverecord = new MoveRecord(); List <WareHouse> warehouseList = whd.getWareHouseList(); Good good = new Good(); bool find = false; for (int j = 0; j < warehouseList.Count; j++) { if (Convert.ToInt32(warehouseIdBox.Text) == warehouseList[j].WareHouseID) { find = true; moverecord.WareHouse = warehouseList[j]; for (int i = 0; i < dt.Rows.Count; i++) { //遍历查询仓库 good = igd.getSingleGood(Convert.ToInt32(dt.Rows[i][0])); moverecord.addGood(good, Convert.ToInt32(dt.Rows[i][2])); } } } if (!find) { MessageBox.Show("仓库不存在!"); } else { DateTime now = DateTime.Now; moverecord.RemoveTime = now; mrd.addmove(moverecord); } //提交采购单后清空 dt.Clear(); dataGridDetail.ItemsSource = dt.DefaultView; }