Ejemplo n.º 1
0
        /// <summary>
        /// 实现IOrgBLL接口
        /// </summary>
        /// <param name="firstOrg">需要保存的FirstOrg</param>
        /// <returns>返回是否保存成功的布尔值</returns>
        public bool SaveFirstOrg(FirstOrg firstOrg)
        {
            //throw new System.NotImplementedException();

            IFirstOrgDAL dAL = new FirstOrgDAL();

            //先检查有没有该FirstOrg,如果有,则更新,没有则添加
            if (dAL.QueryById(firstOrg.Id) != null)
            {
                if (dAL.Update(firstOrg) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (dAL.Add(firstOrg) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 实现IOrgBLL接口
        /// </summary>
        /// <returns>返回所有1级机构</returns>
        public List <FirstOrg> GetAllFirstOrg()
        {
            //throw new NotImplementedException();

            IFirstOrgDAL dAL = new FirstOrgDAL();

            return(dAL.Query());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 实现IOrgBLL接口
        /// </summary>
        /// <param name="id">主键id</param>
        /// <returns>返回对应id的1级机构</returns>
        public FirstOrg GetFirstOrgById(int id)
        {
            //throw new NotImplementedException();

            IFirstOrgDAL dAL = new FirstOrgDAL();

            return(dAL.QueryById(id));
        }
Ejemplo n.º 4
0
        public bool DeleteFirstOrgById(int id)
        {
            //throw new System.NotImplementedException();

            IFirstOrgDAL dAL = new FirstOrgDAL();

            if (dAL.Remove(id) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            //Console.WriteLine(new FirstOrgDAL().AddFirstOrg(new FirstOrg() { OrgName = "大集团1", OrgLevel = 1 }));
            //Console.ReadKey();


            //List<FirstOrg> list = new FirstOrgDAL().GetAllFirstOrg();
            //foreach (var item in list)
            //{
            //    Console.WriteLine(item.Id + "-" + item.OrgName + "-" + item.OrgLevel);
            //}
            //Console.ReadKey();

            //Console.WriteLine(new FirstOrgDAL().RemoveFirstOrgById(13));
            //Console.ReadKey();

            //Console.WriteLine(new FirstOrgDAL().UpdateFirstOrg(new FirstOrg() { Id = 11, OrgName = "第二集团", OrgLevel = 1 }));
            //Console.ReadKey();

            IFirstOrgDAL dAL = new FirstOrgDAL();


            //dAL.Add(new FirstOrg() { OrgName = "第fdhkjh集团", OrgLevel = 1 });
            //Console.ReadKey();

            //foreach (var o in dAL.Query())
            //{
            //    Console.WriteLine(o.Id);
            //    Console.WriteLine(o.OrgName);
            //    Console.WriteLine(o.OrgLevel);
            //}
            //Console.ReadKey();

            //Console.WriteLine(dAL.Update(new FirstOrg() { Id = 10, OrgName = "第一集团", OrgLevel = 1 }));
            //Console.ReadKey();

            Console.WriteLine(dAL.Remove(15));
            Console.ReadKey();
        }