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); }