码迷,mamicode.com
首页 > Web开发 > 详细

Ext.js项目(二)

时间:2016-08-28 21:00:40      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

人事管理模块:

     1.机构管理

     2.部门管理

     3.人员管理

一:用例图

技术分享技术分享 技术分享

二:数据表分析

技术分享

技术分享

三:需要涉及到的类:

需要涉及到的类:(完成一个模块时只需要修改包含:(----)即可)
ExtOA.Ent->BranchInfoBase
ExtOA.Ent->BranchInfo(----)
ExtOA.IDal->IBranchInfoDR(----)
ExtOA.SqlServerDal ->BranchInfoDRBase
ExtOA.SqlServerDal ->BranchInfoDR(-----)
ExtOA.Biz->BranchInfoBiz(-----)

四:在BranchInfoBiz中写两个重写的方法(Json格式):

引入的命名空间:


using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

 /// <summary>
        /// 添加一条 BranchInfo   通过重写的方法
        /// </summary>
        /// <param name="ent">BranchInfo实体</param>
        /// <returns>1成功,-1失败,0异常 主键从实体里返回</returns>
        /// <exception cref="ex">异常信息</exception>
        /// <remarks>
        /// <para>Author: "fwy"</para>
        /// </remarks>
        public int AddBranchInfo(string entJson)
        {
            try
            {
                //自动转换成泛型对象
                BranchInfo branch = Newtonsoft.Json.JsonConvert.DeserializeObject<BranchInfo>(entJson);
                IBranchInfoDR dal = BranchInfoDal.Create(Config.Instance().Dal, Config.Instance().MyConnectstring);
                return dal.Add(branch);
            }
            catch (Exception ex)
            {
                ////log.Error("AddBranchInfo err:",ex);
                return 0;
            }
        }


   /// <summary>
        /// 更新一条 BranchInfo
        /// </summary>
        /// <param name="ent">BranchInfo实体</param>
        /// <returns>1成功,-1失败,0异常</returns>
        /// <exception cref="ex">异常信息</exception>
        /// <remarks>
        /// <para>Author: "fwy"</para>
        /// </remarks>
        public int SetBranchInfo(BranchInfo entJson)
        {
            try
            {
                BranchInfo branch = Newtonsoft.Json.JsonConvert.DeserializeObject<BranchInfo>(entJson);
                IBranchInfoDR dal = BranchInfoDal.Create(Config.Instance().Dal, Config.Instance().MyConnectstring);
                return dal.Set(branch);
            }
            catch (Exception ex)
            {
                ////log.Error("SetBranchInfo err:",ex);
                return 0;
            }
        }

 五:四种构造返回到前台数据的方法

 /// <summary>  四种构造返回到前台数据的方法
        /// 得到所有机构列表(Json格式)格式如下:
        /// {
        ///    total:5,
        ///    rows:[{},{},...]
        /// }
        /// </summary>
        /// <returns></returns>
        public string GetJsonBranchInfo()
        {
            JArray ja = new JArray();
            IList<BranchInfo> branchInfos = this.GetBranchInfo();
            //创建了一个json格式的对象
            foreach (BranchInfo branch in branchInfos)
            {
                JObject sj = new JObject();
                //与实体类中的一一对应
                JProperty Id = new JProperty("Id", branch.Id);
                sj.Add(Id);
                JProperty BranchName = new JProperty("BranchName", branch.BranchName);
                sj.Add(BranchName);
                JProperty BranchAddr = new JProperty("BranchAddr", branch.BranchAddr);
                sj.Add(BranchAddr);
                JProperty BranchPhone = new JProperty("BranchPhone", branch.BranchAddr);
                sj.Add(BranchPhone);
                JProperty BranchUrl = new JProperty("BranchUrl", branch.BranchAddr);
                sj.Add(BranchUrl);
                JProperty BranchMaster = new JProperty("BranchMaster", branch.BranchMaster);
                sj.Add(BranchMaster);

                UserInfo userinfo = (new UserInfoBiz()).GetUserInfoById(branch.BranchMaster);
                JProperty BranchMasterName = new JProperty("BranchMasterName", userinfo.UserName);
                sj.Add(BranchMasterName);
                //把对象添加到数组中去
                ja.Add(sj);
            }
            JObject j = new JObject();

            //给json对象中添加了一个属性
            JProperty total = new JProperty("total", branchInfos.Count);
            j.Add(total);
            JProperty rows = new JProperty("rows", ja);
            j.Add(rows);

            return j.ToString();
        }


        /// <summary>
        /// 得到所有机构列表(Json格式)格式如下:
        /// {
        ///    total:5,
        ///    rows:[{},{},...]
        /// }
        /// </summary>
        /// <returns></returns>
        public string GetJsonBranchInfo2()
        {
            JArray ja = new JArray();
            IList<BranchInfo> branchInfos = this.GetBranchInfo();
            foreach (BranchInfo branch in branchInfos)
            {
                JObject sj = new JObject();
                JProperty Id = new JProperty("Id", branch.Id);
                sj.Add(Id);
                JProperty BranchName = new JProperty("BranchName", branch.BranchName);
                sj.Add(BranchName);
                JProperty BranchAddr = new JProperty("BranchAddr", branch.BranchAddr);
                sj.Add(BranchAddr);
                JProperty BranchPhone = new JProperty("BranchPhone", branch.BranchAddr);
                sj.Add(BranchPhone);
                JProperty BranchUrl = new JProperty("BranchUrl", branch.BranchAddr);
                sj.Add(BranchUrl);
                UserInfo userinfo = (new UserInfoBiz()).GetUserInfoById(branch.BranchMaster);
                string BranchMasterJson = Newtonsoft.Json.JsonConvert.SerializeObject(userinfo);

                // JProperty BranchMaster = new JProperty("BranchMaster", BranchMasterJson);
                //把json对象还原成JObject
                JProperty BranchMaster = new JProperty("BranchMaster", JObject.Parse(BranchMasterJson));
                sj.Add(BranchMaster);

                ja.Add(sj);
            }

            JObject j = new JObject();
            JProperty total = new JProperty("total", branchInfos.Count);
            j.Add(total);
            JProperty rows = new JProperty("rows", ja);
            j.Add(rows);

            return j.ToString();

        }

        /// <summary>
        /// 得到所有机构列表(Json格式)格式如下:
        /// {
        ///    total:5,
        ///    rows:[{},{},...]
        /// }
        /// </summary>
        /// <returns></returns>
        public string GetJsonBranchInfo3()
        {
            JArray ja = new JArray();
            IList<BranchInfo> branchInfos = this.GetBranchInfo();
            foreach (BranchInfo branch in branchInfos)
            {
                JObject sj = new JObject();
                JProperty Id = new JProperty("Id", branch.Id);
                sj.Add(Id);
                JProperty BranchName = new JProperty("BranchName", branch.BranchName);
                sj.Add(BranchName);
                JProperty BranchAddr = new JProperty("BranchAddr", branch.BranchAddr);
                sj.Add(BranchAddr);
                JProperty BranchPhone = new JProperty("BranchPhone", branch.BranchPhone);
                sj.Add(BranchPhone);
                JProperty BranchUrl = new JProperty("BranchUrl", branch.BranchUrl);
                sj.Add(BranchUrl);

                UserInfo userinfo = (new UserInfoBiz()).GetUserInfoById(branch.BranchMaster);
                //去拼接所需要的格式
                string BranchMasterJson = "{" + string.Format("Id:{0},UserName:‘{1}‘", userinfo.Id, userinfo.UserName) + "}";
                JProperty BranchMaster = new JProperty("BranchMaster", JObject.Parse(BranchMasterJson));
                sj.Add(BranchMaster);

                ja.Add(sj);
            }

            JObject j = new JObject();
            JProperty total = new JProperty("total", branchInfos.Count);
            j.Add(total);
            JProperty rows = new JProperty("rows", ja);
            j.Add(rows);

            return j.ToString();

        }


        /// <summary>
        /// 得到所有机构列表(Json格式)格式如下:
        /// {
        ///    total:5,
        ///    rows:[{},{},...]
        /// }
        /// </summary>
        /// <returns></returns>
        public string GetJsonBranchInfo4()
        {
            JArray ja = new JArray();
            IList<BranchInfo> branchInfos = this.GetBranchInfo();
            foreach (BranchInfo branch in branchInfos)
            {
                var branchJson = Newtonsoft.Json.JsonConvert.SerializeObject(branch);
                JObject sj = JObject.Parse(branchJson);

                //外键的时候 先把外键删除  再重新构建
                sj.Remove("BranchMaster");
                UserInfo userinfo = (new UserInfoBiz()).GetUserInfoById(branch.BranchMaster);
                string BranchMasterJson = "{" + string.Format("Id:{0},UserName:‘{1}‘", userinfo.Id, userinfo.UserName) + "}";
                JProperty BranchMaster = new JProperty("BranchMaster", JObject.Parse(BranchMasterJson));
                sj.Add(BranchMaster);

                //UserInfo userinfo = (new UserInfoBiz()).GetUserInfoById(branch.BranchMaster);
                //JProperty BranchMasterName = new JProperty("BranchMasterName", userinfo.UserName);
                //sj.Add(BranchMasterName);



                ja.Add(sj);
            }

            JObject j = new JObject();
            JProperty total = new JProperty("total", branchInfos.Count);
            j.Add(total);
            JProperty rows = new JProperty("rows", ja);
            j.Add(rows);

            return j.ToString();

        }

 

 

Ext.js项目(二)

标签:

原文地址:http://www.cnblogs.com/sunliyuan/p/5815865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!