Exemple #1
0
        /// <summary>
        /// 区域信息修改
        /// zhoub 20150709.update by liujc 增加hAreaName
        /// </summary>
        /// <returns></returns>
        public ResultModel EditTHArea(int areaId, string cAreaName, string eAreaName, string tAreaName, string hAreaName, string shortName, int areaType)
        {
            var result = new ResultModel();

            using (var tx = _database.Db.BeginTransaction())
            {
                try
                {
                    var thAreaModel = base._database.Db.THArea.Find(base._database.Db.THArea.ShortName == shortName && base._database.Db.THArea.THAreaID != areaId);
                    if (thAreaModel == null)
                    {
                        //区域修改
                        _database.Db.THArea.UpdateByTHAreaID(THAreaID: areaId, ShortName: shortName, AreaType: areaType);
                        //区域语言添加
                        THArea_lang cLand = _database.Db.THArea_lang.Find(_database.Db.THArea_lang.THAreaID == areaId && _database.Db.THArea_lang.LanguageID == 1);
                        cLand.AreaName = cAreaName;
                        _database.Db.THArea_lang.UpdateById(cLand);

                        THArea_lang eLand = _database.Db.THArea_lang.Find(_database.Db.THArea_lang.THAreaID == areaId && _database.Db.THArea_lang.LanguageID == 2);
                        eLand.AreaName = eAreaName;
                        _database.Db.THArea_lang.UpdateById(eLand);

                        //THArea_lang tLand = _database.Db.THArea_lang.Find(_database.Db.THArea_lang.THAreaID == areaId && _database.Db.THArea_lang.LanguageID == 3);
                        //tLand.AreaName = tAreaName;
                        //_database.Db.THArea_lang.UpdateById(tLand);

                        THArea_lang hLand = _database.Db.THArea_lang.Find(_database.Db.THArea_lang.THAreaID == areaId && _database.Db.THArea_lang.LanguageID == 4);
                        hLand.AreaName = hAreaName;
                        _database.Db.THArea_lang.UpdateById(hLand);

                        tx.Commit();
                        result.Messages.Add("Modify regional information successfully.");//修改区域信息成功
                    }
                    else
                    {
                        result.IsValid = false;
                        result.Messages.Add("The area referred to as already exists.");//区域简称已经存在.
                    }
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    result.IsValid = false;
                    result.Messages.Add("Change the regional information failure.");//
                }
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 区域信息添加
        /// zhoub 20150709.update by liujc 增加hAreaName
        /// </summary>
        /// <returns></returns>
        public ResultModel AddTHArea(int parentId, string cAreaName, string eAreaName, string tAreaName, string hAreaName, string shortName, int areaType)
        {
            var result = new ResultModel();

            using (var tx = _database.Db.BeginTransaction())
            {
                try
                {
                    var thAreaModel = base._database.Db.THArea.Find(base._database.Db.THArea.ShortName == shortName);
                    if (thAreaModel == null)
                    {
                        //区域添加
                        THArea thArea = new THArea();
                        thArea.ParentID  = parentId;
                        thArea.ShortName = shortName;
                        thArea.AreaType  = areaType;
                        var th       = _database.Db.THArea.Insert(thArea);
                        int tHAreaID = th.THAreaID;
                        //区域语言添加
                        THArea_lang cLang = new THArea_lang();
                        cLang.THAreaID   = tHAreaID;
                        cLang.AreaName   = cAreaName;
                        cLang.LanguageID = 1;
                        _database.Db.THArea_lang.Insert(cLang);

                        THArea_lang eLang = new THArea_lang();
                        eLang.THAreaID   = tHAreaID;
                        eLang.AreaName   = eAreaName;
                        eLang.LanguageID = 2;
                        _database.Db.THArea_lang.Insert(eLang);

                        //THArea_lang tLang = new THArea_lang();
                        //tLang.THAreaID = tHAreaID;
                        //tLang.AreaName = tAreaName;
                        //tLang.LanguageID = 3;
                        //_database.Db.THArea_lang.Insert(tLang);

                        //add by liujc
                        THArea_lang hLang = new THArea_lang();
                        hLang.THAreaID   = tHAreaID;
                        hLang.AreaName   = hAreaName;
                        hLang.LanguageID = 4;
                        _database.Db.THArea_lang.Insert(hLang);

                        tx.Commit();
                        result.Messages.Add("Add area information to success.");//添加区域信息成功.
                    }
                    else
                    {
                        result.Messages.Add("The area referred to as already exists.");//区域简称已经存在.
                    }
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    result.IsValid = false;
                    result.Messages.Add("Add area information to fail.");//添加区域信息失败.
                }
            }

            return(result);
        }