/// <summary> /// 加载商品信息列表—全部 /// </summary> /// <returns>加载结果 True:成功 False:失败</returns> public bool LoadGoodsInfo_Total() { bool result = false; GoodsList_Total.Clear(); DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; strSql += @"select McdCode,McdName,McdContent,Price, PicName,McdType,IsFree,Manufacturer, GoodsSpec,DrugType,DetailInfo,Unit,McdSaleType from T_MCD_BASEINFO order by id desc"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; for (int i = 0; i < recordCount; i++) { GoodsList_Total.Add(new GoodsModel() { McdCode = dataSet.Tables[0].Rows[i]["McdCode"].ToString(), McdName = dataSet.Tables[0].Rows[i]["McdName"].ToString(), McdContent = dataSet.Tables[0].Rows[i]["McdContent"].ToString(), PicName = dataSet.Tables[0].Rows[i]["PicName"].ToString(), Price = Convert.ToInt32(dataSet.Tables[0].Rows[i]["Price"].ToString()), IsFree = dataSet.Tables[0].Rows[i]["IsFree"].ToString(), Manufacturer = dataSet.Tables[0].Rows[i]["Manufacturer"].ToString(), GoodsSpec = dataSet.Tables[0].Rows[i]["GoodsSpec"].ToString(), DrugType = dataSet.Tables[0].Rows[i]["DrugType"].ToString(), TypeCode = dataSet.Tables[0].Rows[i]["McdType"].ToString(), Unit = dataSet.Tables[0].Rows[i]["Unit"].ToString(), DetailInfo = dataSet.Tables[0].Rows[i]["DetailInfo"].ToString(), McdSaleType = FunHelper.ChangeMcdSaleType(dataSet.Tables[0].Rows[i]["McdSaleType"].ToString()), }); } } result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }
/// <summary> /// 加载商品信息列表—上架 /// </summary> /// <param name="pageNum">每页显示的最大行数</param> /// <param name="rowNum">每行显示的最大列数</param> /// <returns></returns> public bool LoadGoodsInfo_Show(int eachPageMaxRowNum, int eachRowMaxNum) { bool result = false; GoodsList_Show.Clear(); GoodsShowPageCount = 0; CurrentPageNo = 1; DbOper dbOper = new DbOper(); dbOper.DbFileName = _m_DbFileName; try { string strSql = string.Empty; strSql += @"select distinct t1.mcdcode,t2.mcdname,t2.mcdcontent,t2.picname,t1.sellprice, t2.IsFree,t2.Manufacturer,t2.GoodsSpec, t2.DrugType,t2.McdType,t2.Unit,t2.DetailInfo,t2.McdSaleType from t_vm_painfo t1,t_mcd_baseinfo t2 where t1.mcdcode = t2.mcdcode and t1.pakind = '0' and t1.sellmodel = '0' order by t1.pacode_num"; DataSet dataSet = dbOper.dataSet(strSql); if (dataSet.Tables.Count > 0) { int recordCount = dataSet.Tables[0].Rows.Count; // 获取总页面 int intEachMaxNum = eachPageMaxRowNum * eachRowMaxNum;// 每页显示的最大商品数量 GoodsShowPageCount = ((recordCount / intEachMaxNum) + ((recordCount % intEachMaxNum) > 0 ? 1 : 0)); string strSql12 = string.Empty; string strMcdCode = string.Empty; int intSellPrice = 0; int intSurNum = 0; string strStockNum = string.Empty; DataSet dataSet_Sur = new DataSet(); for (int i = 0; i < recordCount; i++) { strMcdCode = dataSet.Tables[0].Rows[i]["McdCode"].ToString(); intSellPrice = Convert.ToInt32(dataSet.Tables[0].Rows[i]["sellprice"].ToString()); // 查询每个商品当前的库存 intSurNum = 0; strSql12 = @"select sum(surnum) as surnum from t_vm_painfo where pakind = '0' and mcdcode = '" + strMcdCode + "' and sellprice = " + intSellPrice; dataSet_Sur = dbOper.dataSet(strSql12); if (dataSet_Sur.Tables.Count > 0) { if (dataSet_Sur.Tables[0].Rows.Count > 0) { strStockNum = dataSet_Sur.Tables[0].Rows[0]["surnum"].ToString(); intSurNum = Convert.ToInt32(strStockNum); } } GoodsList_Show.Add(new GoodsModel() { McdCode = strMcdCode, McdName = dataSet.Tables[0].Rows[i]["McdName"].ToString(), McdContent = dataSet.Tables[0].Rows[i]["McdContent"].ToString(), PicName = dataSet.Tables[0].Rows[i]["PicName"].ToString(), Price = intSellPrice, Unit = dataSet.Tables[0].Rows[i]["Unit"].ToString(), SurNum = intSurNum, IsFree = dataSet.Tables[0].Rows[i]["IsFree"].ToString(), Manufacturer = dataSet.Tables[0].Rows[i]["Manufacturer"].ToString(), GoodsSpec = dataSet.Tables[0].Rows[i]["GoodsSpec"].ToString(), DrugType = dataSet.Tables[0].Rows[i]["DrugType"].ToString(), TypeCode = dataSet.Tables[0].Rows[i]["McdType"].ToString(), DetailInfo = dataSet.Tables[0].Rows[i]["DetailInfo"].ToString(), McdSaleType = FunHelper.ChangeMcdSaleType(dataSet.Tables[0].Rows[i]["McdSaleType"].ToString()), }); } } result = true; } catch { result = false; } finally { dbOper.closeConnection(); } return(result); }