public static List <Productinfo> GetShelfOffInfo() { try { myCon.Open(); string sql = "SELECT ProductName FROM ShelfCodePositionCorrespondence WHERE ShelfState='已上架' group by ProductName "; MySqlCommand mySqlCommand = new MySqlCommand(sql, myCon); MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); List <Productinfo> productinfos = new List <Productinfo>(); while (mySqlDataReader.Read()) { if (mySqlDataReader.HasRows) { Productinfo productinfo = new Productinfo { ProductName = mySqlDataReader[0].ToString(), }; productinfos.Add(productinfo); } } mySqlDataReader.Close(); return(productinfos); } catch (Exception ex) { LogHelper.WriteLog("查询失败", ex); return(null); } finally { myCon.Close(); } }
public static ShelfOnInfo GetShelfOnInfo() { try { myCon.Open(); string sql = "SELECT sp.ProductName,GROUP_CONCAT(tid),COUNT(1) FROM StockProducts sp WHERE sp.ProductState='已入库' GROUP BY sp.ProductName "; MySqlCommand mySqlCommand = new MySqlCommand(sql, myCon); MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); ShelfOnInfo shelfOnInfo = new ShelfOnInfo(); while (mySqlDataReader.Read()) { if (mySqlDataReader.HasRows) { Productinfo productinfo = new Productinfo { ProductName = mySqlDataReader[0].ToString(), tids = mySqlDataReader[1].ToString().Split(new char[1] { ',' }).ToList(), Count = mySqlDataReader[2].ToString() }; shelfOnInfo.productinfos.Add(productinfo); } } mySqlDataReader.Close(); string sql2 = "SELECT shelfcode,shelflocation from ShelfCodePositionCorrespondence WHERE ShelfState='无货物'"; MySqlCommand mySqlCommand2 = new MySqlCommand(sql2, myCon); MySqlDataReader mySqlDataReader2 = mySqlCommand2.ExecuteReader(); while (mySqlDataReader2.Read()) { if (mySqlDataReader2.HasRows) { ShelfCode shelfCode = new ShelfCode { shelfcode = mySqlDataReader2[0].ToString(), shelflocation = mySqlDataReader2[1].ToString(), }; shelfOnInfo.ShelfCodes.Add(shelfCode); } } mySqlDataReader2.Close(); return(shelfOnInfo); } catch (Exception ex) { LogHelper.WriteLog("查询失败", ex); return(null); } finally { myCon.Close(); } }
/// <summary> /// 获取所有已下架的商品信息,用于创建出库单 /// </summary> /// <returns></returns> public static List <Productinfo> GetProductinfos() { try { myCon.Open(); string sql = "SELECT sp.ProductName,COUNT(1),GROUP_CONCAT(tid) FROM StockProducts sp WHERE sp.ProductState='已下架' GROUP BY sp.ProductName "; MySqlCommand mySqlCommand = new MySqlCommand(sql, myCon); MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); List <Productinfo> productinfos = new List <Productinfo>(); while (mySqlDataReader.Read()) { if (mySqlDataReader.HasRows) { Productinfo productinfo = new Productinfo { ProductName = mySqlDataReader[0].ToString(), tids = mySqlDataReader[2].ToString().Split(new char[1] { ',' }).ToList(), Count = mySqlDataReader[1].ToString() }; productinfos.Add(productinfo); } } mySqlDataReader.Close(); return(productinfos); } catch (Exception ex) { LogHelper.WriteLog("", ex); return(null); } finally { myCon.Close(); } }