Ejemplo n.º 1
0
        /// <summary>
        /// 获取检货单数据列表
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, string> GetInspectionSheet(out List <Enterprise> epList)
        {
            epList = new List <Enterprise>(); //企业列表
            try
            {
                List <InspectionSheet> list = dao.GetInspectionSheet();
                if (list == null)
                {
                    // epList = null;
                    return(null);
                }
                Dictionary <string, string> valueDic = new Dictionary <string, string>();//部门对应的订购量

                //获取企业列表,包括各企业中的订购蔬菜的所有部门

                Enterprise ep           = new Enterprise();
                Department dp           = new Department();
                string     currentEName = list[0].EName;
                string     currentDName = list[0].DName;
                ep.EName = currentEName;

                dp.DName = currentDName;
                ep.DepList.Add(dp);

                foreach (InspectionSheet ins in list)
                {
                    if (currentEName == ins.EName)
                    {
                        if (currentDName != ins.DName)
                        {
                            dp       = new Department();
                            dp.DName = ins.DName;
                            ep.DepList.Add(dp);
                            currentDName = ins.DName;
                        }
                    }
                    else
                    {
                        epList.Add(ep);
                        ep           = new Enterprise();
                        ep.EName     = ins.EName;
                        currentEName = ins.EName;
                        dp           = new Department();
                        dp.DName     = ins.DName;
                        currentDName = ins.DName;
                        ep.DepList.Add(dp);
                    }

                    if (!valueDic.ContainsKey(ins.EName + ins.DName + ins.VName))
                    {
                        valueDic.Add(ins.EName + ins.DName + ins.VName, ins.OrderCount.ToString());
                    }
                }
                epList.Add(ep);

                if (list.Count == 0)
                {
                    return(null);
                }
                return(valueDic);
            }
            catch (Exception ex)
            {
                XphpTool.CreateErrorLog(ex.ToString());
                return(null);
            }
        }