Пример #1
0
        protected Dictionary <string, BaseItemInfo> ReadXlsItems(string fileName)
        {
            Dictionary <string, BaseItemInfo> items = new Dictionary <string, BaseItemInfo>();

            try
            {
                DataTable data = CommonFun.ReadXLS(fileName);

                for (int row = 0; row < data.Rows.Count; row++)
                {
                    try
                    {
                        BaseItemInfo item = new BaseItemInfo();
                        item.ID       = data.Rows[row]["批准文号"].ToString();
                        item.Name     = (string)data.Rows[row]["通用名称"].ToString();
                        item.ItemName = data.Columns.Contains("商品名称") ? data.Rows[row]["商品名称"].ToString() : "";
                        item.Created  = (string)data.Rows[row]["生产厂家"].ToString();
                        item.Format   = (string)data.Rows[row]["包装规格"].ToString();
                        string priceStr = (string)data.Rows[row]["平台售价(最低价格)"].ToString();
                        item.ShopPrice     = string.IsNullOrEmpty(priceStr) ? 9999 : Convert.ToDecimal(priceStr);
                        item.PlatformPrice = item.ShopPrice;
                        item.Type          = data.Columns.Contains("剂型") ? (string)data.Rows[row]["剂型"].ToString() : "";
                        item.Inventory     = (string)data.Rows[row]["库存"].ToString();
                        item.SellType      = (string)data.Rows[row]["出售方式(零或整)"].ToString();

                        string key = item.Name + item.Format + item.Created;
                        if (!items.ContainsKey(key))
                        {
                            items.Add(key, item);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(items);
        }