Exemplo n.º 1
0
        public bool AddDict(DictEntity dictEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" @JournalID");
            sqlCommandText.Append(", @DictKey");
            sqlCommandText.Append(", @Note");
            sqlCommandText.Append(", @InUserID");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Dict ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString()));

            db.AddInParameter(cmd,"@JournalID",DbType.Int64,dictEntity.JournalID);
            db.AddInParameter(cmd,"@DictKey",DbType.AnsiString,dictEntity.DictKey);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,dictEntity.Note);
            db.AddInParameter(cmd,"@InUserID",DbType.Int64,dictEntity.InUserID);
            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 public ActionResult Save(DictEntity model)
 {
     ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>();
     if (model.DictID == 0)
         model.InUserID = CurAuthor.AuthorID;
     else
         model.EditUserID = CurAuthor.AuthorID;
     //model.JournalID = CurAuthor.JournalID;
     model.DictKey = "Notice" + Guid.NewGuid().ToString();
     ExecResult result = service.SaveDict(model);
     return Json(new { result = result.result, msg = result.msg });
 }
Exemplo n.º 3
0
 public ActionResult Create(Int64 dictId = 0)
 {
     DictEntity model=null;
     if (dictId > 0)
     {
         DictQuery query = new DictQuery();
         query.JournalID = CurAuthor.JournalID;
         query.DictID = dictId;
         ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>();
         model = service.GetDictModel(query);
     }
     if (model == null)
         model = new DictEntity();
     return View(model);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateDict(DictEntity dict)
 {
     return DictDataAccess.Instance.UpdateDict(dict);
 }
Exemplo n.º 5
0
 public ExecResult SaveDict(DictEntity model)
 {
     ExecResult execResult = new ExecResult();
     IDictService service = ServiceContainer.Instance.Container.Resolve<IDictService>();
     return service.Save(model);
 }
Exemplo n.º 6
0
        public bool UpdateDict(DictEntity dictEntity)
        {
            bool flag = false;
            StringBuilder whereCommandText = new StringBuilder();
            whereCommandText.Append("  DictID=@DictID");
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" DictKey=@DictKey");
            sqlCommandText.Append(", Note=@Note");
            sqlCommandText.Append(", EditUserID=@EditUserID");
            sqlCommandText.Append(", EditDate=getdate()");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Dict SET {0} WHERE  {1}",sqlCommandText.ToString(),whereCommandText.ToString()));

            db.AddInParameter(cmd,"@DictID",DbType.Int64,dictEntity.DictID);
            db.AddInParameter(cmd,"@DictKey",DbType.AnsiString,dictEntity.DictKey);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,dictEntity.Note);
            db.AddInParameter(cmd,"@EditUserID",DbType.Int64,dictEntity.EditUserID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Exemplo n.º 7
0
 public List<DictEntity> MakeDictList(IDataReader dr)
 {
     List<DictEntity> list=new List<DictEntity>();
     while(dr.Read())
     {
      DictEntity dictEntity=new DictEntity();
     dictEntity.DictID = (Int64)dr["DictID"];
     dictEntity.JournalID = (Int64)dr["JournalID"];
     dictEntity.DictKey = (String)dr["DictKey"];
     dictEntity.Note = (String)dr["Note"];
     dictEntity.InUserID = (Int64)dr["InUserID"];
     dictEntity.EditUserID = (Int64)dr["EditUserID"];
     dictEntity.EditDate = (DateTime)dr["EditDate"];
     dictEntity.AddDate = (DateTime)dr["AddDate"];
        list.Add(dictEntity);
     }
     dr.Close();
     return list;
 }
Exemplo n.º 8
0
 /// <summary>
 /// 保存数据字典
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ExecResult Save(DictEntity model)
 {
     ExecResult execResult = new ExecResult();
     model.DictKey = model.DictKey.TextFilter();
     if (DictkeyIsExists(model))
     {
         execResult.result = EnumJsonResult.error.ToString();
         execResult.msg = "该数据字典名称已存在!";
         return execResult;
     }
     bool result = false;
     model.Note = model.Note.TextFilter();
     if (model.DictID == 0)
     {
         result = AddDict(model);
         if (result)
         {
             execResult.result = EnumJsonResult.success.ToString();
             execResult.msg = "新增数据字典成功!";
         }
         else
         {
             execResult.result = EnumJsonResult.failure.ToString();
             execResult.msg = "新增数据字典失败!";
         }
     }
     else
     {
         result = UpdateDict(model);
         if (result)
         {
             execResult.result = EnumJsonResult.success.ToString();
             execResult.msg = "修改数据字典成功!";
         }
         else
         {
             execResult.result = EnumJsonResult.failure.ToString();
             execResult.msg = "修改数据字典失败!";
         }
     }
     return execResult;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 数据字典是否已经存在
 /// </summary>
 /// <param name="model"></param>       
 /// <returns></returns>
 public bool DictkeyIsExists(DictEntity model)
 {
     return DictDataAccess.Instance.DictkeyIsExists(model);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 数据字典是否已经存在
 /// </summary>
 /// <param name="model"></param>       
 /// <returns></returns>
 public bool DictkeyIsExists(DictEntity model)
 {
     string strSql = "SELECT 1 FROM dbo.Dict a with(nolock) WHERE JournalID=@JournalID and DictKey=@DictKey";
     if (model.DictID > 0)
     {
         strSql += " and DictID<>" + model.DictID;
     }
     DbCommand cmd = db.GetSqlStringCommand(strSql);
     db.AddInParameter(cmd, "@JournalID", DbType.Int64, model.JournalID);
     db.AddInParameter(cmd, "@DictKey", DbType.AnsiString, model.DictKey);
     object obj = db.ExecuteScalar(cmd);
     if (obj == null) return false;
     return obj.TryParse<Int32>() == 1;
 }
Exemplo n.º 11
0
        public bool DeleteDict(DictEntity dictEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("DELETE FROM dbo.Dict");
            sqlCommandText.Append(" WHERE  DictID=@DictID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd,"@DictID",DbType.Int64,dictEntity.DictID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 /// <summary>
 /// 保存数据字典
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ExecResult SaveDict(DictEntity model)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     ExecResult result = clientHelper.Post<ExecResult, DictEntity>(GetAPIUrl(APIConstant.DICT_SAVE), model);
     return result;
 }
Exemplo n.º 13
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteDict(DictEntity dict)
 {
     return DictBusProvider.DeleteDict(dict);
 }
Exemplo n.º 14
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddDict(DictEntity dict)
 {
     return DictBusProvider.AddDict(dict);
 }
Exemplo n.º 15
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateDict(DictEntity dict)
 {
     return DictBusProvider.UpdateDict(dict);
 }
Exemplo n.º 16
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddDict(DictEntity dict)
 {
     return DictDataAccess.Instance.AddDict(dict);
 }
Exemplo n.º 17
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="dict">DictEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteDict(DictEntity dict)
 {
     return DictDataAccess.Instance.DeleteDict(dict);
 }
Exemplo n.º 18
0
 public DictEntity MakeDict(IDataReader dr)
 {
     DictEntity dictEntity = null;
     if(dr.Read())
     {
      dictEntity=new DictEntity();
      dictEntity.DictID = (Int64)dr["DictID"];
      dictEntity.JournalID = (Int64)dr["JournalID"];
      dictEntity.DictKey = (String)dr["DictKey"];
      dictEntity.Note = (String)dr["Note"];
      dictEntity.InUserID = (Int64)dr["InUserID"];
      dictEntity.EditUserID = (Int64)dr["EditUserID"];
      dictEntity.EditDate = (DateTime)dr["EditDate"];
      dictEntity.AddDate = (DateTime)dr["AddDate"];
     }
     dr.Close();
     return dictEntity;
 }
Exemplo n.º 19
0
 public DictEntity MakeDict(DataRow dr)
 {
     DictEntity dictEntity=null;
     if(dr!=null)
     {
          dictEntity=new DictEntity();
          dictEntity.DictID = (Int64)dr["DictID"];
          dictEntity.JournalID = (Int64)dr["JournalID"];
          dictEntity.DictKey = (String)dr["DictKey"];
          dictEntity.Note = (String)dr["Note"];
          dictEntity.InUserID = (Int64)dr["InUserID"];
          dictEntity.EditUserID = (Int64)dr["EditUserID"];
          dictEntity.EditDate = (DateTime)dr["EditDate"];
          dictEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return dictEntity;
 }
Exemplo n.º 20
0
 /// <summary>
 /// 数据字典是否已经存在
 /// </summary>
 /// <param name="model"></param>       
 /// <returns></returns>
 public bool DictkeyIsExists(DictEntity model)
 {
     return DictBusProvider.DictkeyIsExists(model);
 }