private MerchandiseData BuildMerchandiseData(DataRow dr) { MerchandiseData data = new MerchandiseData(); data.ID = (string)dr["goods_id"]; if (!string.IsNullOrEmpty(dr["code"].ToString())) { data.MerchID = (string)dr["code"]; } if (!string.IsNullOrEmpty(dr["name"].ToString())) { data.MerchName = (string)dr["name"]; } if (!string.IsNullOrEmpty(dr["ean"].ToString())) { data.Ean = (string)dr["ean"]; } if (!string.IsNullOrEmpty(dr["sell_status"].ToString())) { data.State = (int)dr["sell_status"]; } if (!string.IsNullOrEmpty(dr["units"].ToString())) { data.Unit = (string)dr["units"]; } if (!string.IsNullOrEmpty(dr["selling_price"].ToString())) { data.UnitPrice = (decimal)dr["selling_price"]; } if (!string.IsNullOrEmpty(dr["selling_vip_price"].ToString())) { data.VipPrice = (decimal)dr["selling_vip_price"]; } if (!string.IsNullOrEmpty(dr["purchasing_price"].ToString())) { data.Bid = (decimal)dr["purchasing_price"]; } if (!string.IsNullOrEmpty(dr["num"].ToString())) { data.Amount = (float)dr["num"]; } if (!string.IsNullOrEmpty(dr["category_name"].ToString())) { data.Category = (string)dr["category_name"]; } if (!string.IsNullOrEmpty(dr["exchange_score"].ToString())) { data.Integral = (long)dr["exchange_score"]; } data.RealAmount = 0; data.DiffAmount = 0; data.Remark = ""; return(data); }
public List <MerchandiseData> QueryInven(string lbid, string searcher) { DataSet ds; List <MerchandiseData> data_list = new List <MerchandiseData>(); if (!string.IsNullOrEmpty(lbid)) { ds = ExecuteDataSet(@"select goods.goods_id,goods.code,goods.ean,goods.sell_status,goods.name,goods.units,goods.selling_price,goods.selling_vip_price, goods.purchasing_price,goods.num,goods_category.category_name, ifnull(exchange.exchange_score, 0) as exchange_score from goods left join goods_category on goods.category = goods_category.id left join exchange on exchange.goods_id = goods.goods_id where (goods.code like @code or goods.ean like @ean or goods.name like @name) and goods_category.id = @category order by goods.code", new MySqlParameter("@category", lbid), new MySqlParameter("@code", "%" + searcher + "%"), new MySqlParameter("@ean", "%" + searcher + "%"), new MySqlParameter("@name", "%" + searcher + "%") ); } else { ds = ExecuteDataSet(@"select goods.goods_id,goods.code,goods.ean,goods.sell_status,goods.name,goods.units,goods.selling_price,goods.selling_vip_price, goods.purchasing_price,goods.num,goods_category.category_name, ifnull(exchange.exchange_score, 0) as exchange_score from goods left join goods_category on goods.category = goods_category.id left join exchange on exchange.goods_id = goods.goods_id where (goods.code like @code or goods.ean like @ean or goods.name like @name) order by goods.code", new MySqlParameter("@code", "%" + searcher + "%"), new MySqlParameter("@ean", "%" + searcher + "%"), new MySqlParameter("@name", "%" + searcher + "%") ); } if (null != ds && ds.Tables.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; MerchandiseData data = BuildMerchandiseData(dr); data_list.Add(data); } } return(data_list); }