private void click_deleteOne(object sender, RoutedEventArgs e) { IGoodDao pd = new GoodDao(); DataRow mySelectedElement = (DataRow)dataGridDetail.SelectedItem; //获取datagrid选择的对象 dt.Rows.Remove(mySelectedElement); //移除选中行 }
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 FrmWarehouseWarning_Load(object sender, EventArgs e) { List <EtCategory> list = CategoryDao.QueryAll(); for (int i = 0; i < list.Count; i++) { if (list[i].IsValid == Enums.EValid.效) { int currentStock = GetCurrentStock(list[i].CategoryID); if (currentStock < list[i].MinStock || currentStock > list[i].MaxStock) { categories.Add(list[i]); currentStocks.Add(currentStock); } } } List <EtGood> list2 = GoodDao.QueryAll(); for (int i = 0; i < list2.Count; i++) { if (list2[i].State != Enums.EState.已出售) { int intervalDays = CalcDateUtil.IntervalDays(list2[i].ProductionDate, list2[i].Category.ExpirationDate); if (intervalDays <= 10) { goods.Add(list2[i]); goodDeadlines.Add(CalcDateUtil.NextDays(list2[i].ProductionDate, list2[i].Category.ExpirationDate).ToString("yyyyMMdd")); goodIntervalDays.Add(intervalDays); } } } DgvWarehouseShow(); }
private void deleteGoodButton_Click(object sender, RoutedEventArgs e) { IGoodDao pd = new GoodDao(); DataRowView mySelectedElement = (DataRowView)dataGridDetail.SelectedItem; //获取datagrid选择的对象 dt.Rows.RemoveAt(dataGridDetail.SelectedIndex); }
private void nameSearch_Click(object sender, RoutedEventArgs e) { IGoodDao pd = new GoodDao(); string s = nameBox.Text; //此处是调用商品名称模糊搜索,把前端的商品类别label改成商品名称 DataSet ds = pd.vagueGetGood(s); dataGrid.ItemsSource = ds.Tables[0].DefaultView; }
public FrmSaleInsert() { InitializeComponent(); CmbGoodID.Items.Clear(); List <EtGood> goods = GoodDao.QueryByState(Enums.EState.未出售); foreach (EtGood good in goods) { if (null == FrmSale.Sales.Find(delegate(EtSale sale) { return(sale.Good.GoodID.Equals(good.GoodID)); })) { CmbGoodID.Items.Add(good.GoodID.ToString() + " " + good.Category.CategoryName); } } }
private void DgvGoodAdd(List <EtSale> sales) { DgvGoodInfo.Rows.Clear(); sales = SaleDao.QueryBySaleID(sales[0].SaleID); for (int i = 0; i < sales.Count; i++) { goods = GoodDao.QueryByGoodID(sales[i].Good.GoodID); DgvGoodInfo.Rows.Add(new object[] { goods[0].GoodID, goods[0].Category.CategoryName, goods[0].Category.Unit, goods[0].Price }); } }
private void BtnInsert_Click(object sender, EventArgs e) { try { EtSale sale = new EtSale { SaleID = 0, Good = GoodDao.QueryByGoodID(int.Parse(CmbGoodID.SelectedItem.ToString().Split(' ')[0]))[0] }; sale.Profit = int.Parse(TxtPrice.Text) - sale.Good.Cost; sale.Good.Price = int.Parse(TxtPrice.Text); sale.Good.State = Enums.EState.已出售; FrmSale.Sales.Add(sale); Close(); } catch (Exception) { MsgBoxUtil.ErrMsgBox("输入不得为空!"); } }
private void idSearch_Click(object sender, RoutedEventArgs e) { IGoodDao pd = new GoodDao(); string s = idBox.Text; int i; if (int.TryParse(s, out i)) { //需调用返回dataset 的getSingleGoodDataSet函数 DataSet ds = pd.getSingleGoodDataSet(i); dataGrid.ItemsSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("请输入数字。"); } }
private bool Save() { EtPurchase purchase; if (-1 == CmbOperator.SelectedIndex) { MsgBoxUtil.ErrMsgBox("经办人不能为空!"); return(false); } int staffId = StaffDao.QueryByStaffName(CmbOperator.SelectedItem.ToString())[0].StaffID; int res = 0; foreach (ClsGood good in Goods) { purchase = new EtPurchase { PurchaseID = int.Parse(LblPurchaseID.Text), Category = good.Good.Category, PurchaseDate = DtpPurchaseDate.Value.ToString("yyyyMMdd"), Quantity = good.Count, Cost = good.Good.Cost, StaffID = staffId }; res += PurchaseDao.InsertPurchase(purchase); EtGood g = new EtGood { Category = good.Good.Category, ProductionDate = good.Good.ProductionDate, PurchaseDate = purchase.PurchaseDate, Cost = good.Good.Cost, Price = good.Good.Price, State = good.Good.State }; for (int i = 0; i < good.Count; i++) { GoodDao.InsertGood(g); } } if (res == Goods.Count) { return(true); } else { return(false); } }
private void datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { int goodid = 0; try { var a = datagrid.SelectedItem; var b = a as DataRowView; string result = b.Row[0].ToString(); goodid = int.Parse(result); } catch (Exception exx) { return; } GoodDao gdao = new GoodDao(); warehouse_good.ItemsSource = gdao.getAllWareHouseStorage(goodid).Tables[0].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 EtSale ParseSale(IRow row) { if ("" == row.GetCell(0).ToString()) { errInfo = "商品不存在"; hasErr = true; return(null); } int goodID = int.Parse(row.GetCell(0).ToString()); List <EtGood> goods = GoodDao.QueryByGoodID(goodID); if (0 == goods.Count || goods[0].State != Enums.EState.未出售) { errInfo = "商品不存在"; hasErr = true; return(null); } if ("" == row.GetCell(1).ToString()) { errInfo = "销售日期不能为空"; hasErr = true; return(null); } string saleDate = row.GetCell(1).ToString(); if ("" == row.GetCell(2).ToString()) { errInfo = "售价不能为空"; hasErr = true; return(null); } int price = int.Parse(row.GetCell(2).ToString()); EtSale sale = new EtSale { SaleID = 0, Good = goods[0], SaleDate = saleDate, Profit = price - goods[0].Cost }; return(sale); }
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; }
private bool Save() { if (CmbOperator.SelectedIndex == -1) { MsgBoxUtil.ErrMsgBox("经办人不能为空!"); return(false); } int res = 0; foreach (EtSale sale in Sales) { res += SaleDao.InsertSale(sale); GoodDao.UpdateGood(sale.Good); } if (res == Sales.Count) { return(true); } else { return(false); } }
private void BtnQuery_Click(object sender, EventArgs e) { if (TxtQuery.Text != "") { List <EtSale> subSales = new List <EtSale>(); List <EtGood> subGoods = new List <EtGood>(); string query = TxtQuery.Text; string RegexStr = "^[0-9]+$"; if (RdoSale.Checked) { if (Regex.IsMatch(query, RegexStr)) { subSales = SaleDao.QueryBySaleID(int.Parse(query)); if (subSales.Count == 0) { subSales = SaleDao.QueryByStaffID(int.Parse(query)); } } if (subSales.Count == 0) { MsgBoxUtil.ErrMsgBox("未找到销售单!"); } else { subGoods = GoodDao.QueryByGoodID(subSales[0].Good.GoodID); } } else { if (Regex.IsMatch(query, RegexStr)) { subGoods = GoodDao.QueryByGoodID(int.Parse(query)); } else { subGoods = GoodDao.QueryByCategoryID(CategoryDao.QueryByCategoryName(query)[0].CategoryID); } if (subGoods.Count == 0) { MsgBoxUtil.ErrMsgBox("未找到商品!"); } else { for (int i = 0; i < subGoods.Count; i++) { if (subGoods[i].State == Enums.EState.已出售) { subSales.Add(SaleDao.QueryByGoodID(subGoods[i].GoodID)[0]); } else { subGoods.RemoveAt(i); i--; } } } } DgvAdd(subSales, subGoods); } else { MsgBoxUtil.ErrMsgBox("请输入查询条件!"); } }
private int GetCurrentStock(int categoryID) { List <EtGood> goods = GoodDao.QueryByCategoryID(categoryID); return(goods.Count); }