コード例 #1
0
        public IEnumerable <SystemDictionary> Query()
        {
            string sql = "SELECT [TYPE],[ID],[NAME],[VALUE],[REMARK] FROM [T_SystemDictionary] ORDER BY TYPE";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    var result = new List <SystemDictionary>();
                    SystemDictionary dictionary = null;
                    while (reader.Read())
                    {
                        SystemDictionaryType currentType = (SystemDictionaryType)reader.GetInt32(0);
                        if (null == dictionary || dictionary.Type != currentType)
                        {
                            dictionary = new SystemDictionary(currentType);
                            result.Add(dictionary);
                        }
                        dictionary.AddItem(new SystemDictionaryItem(
                                               reader.GetGuid(1),
                                               reader.IsDBNull(2) ? string.Empty : reader.GetString(2),
                                               reader.IsDBNull(3) ? string.Empty : reader.GetString(3),
                                               reader.IsDBNull(4) ? string.Empty : reader.GetString(4)));
                    }
                    return(result);
                }
            }
        }
コード例 #2
0
ファイル: Dictionary_new.aspx.cs プロジェクト: 842549829/Pool
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["action"] != null)
     {
         SystemDictionaryType systemDictionaryType = (SystemDictionaryType)Enum.Parse(typeof(SystemDictionaryType), Request.QueryString["type"].ToString());
         SystemDictionaryItem systemDictionaryItem = null;
         if (Request.QueryString["action"].ToString() == "add")
         {
             try
             {
                 systemDictionaryItem = new SystemDictionaryItem(this.txtName.Text.Trim(), this.txtValue.Text.Trim(), this.ttRemark.InnerText.Trim());
                 SystemDictionaryService.AddItem(systemDictionaryType, systemDictionaryItem, CurrentUser.UserName);
                 RegisterScript("alert('添加成功!'); window.location.href='Dictionary.aspx';");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "添加");
             }
         }
         else if (Request.QueryString["action"].ToString() == "update")
         {
             try
             {
                 systemDictionaryItem = new SystemDictionaryItem(new Guid(Request.QueryString["Id"]), this.txtName.Text.Trim(), this.txtValue.Text.Trim(), this.ttRemark.InnerText.Trim());
                 SystemDictionaryService.UpdateItem(systemDictionaryType, systemDictionaryItem, CurrentUser.UserName);
                 RegisterScript("alert('修改成功!'); window.location.href='Dictionary.aspx';");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "修改");
             }
         }
     }
 }
コード例 #3
0
ファイル: Dictionary_new.aspx.cs プロジェクト: 842549829/Pool
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         SystemDictionaryType systemDictionaryType = (SystemDictionaryType)Enum.Parse(typeof(SystemDictionaryType), Request.QueryString["type"].ToString());
         this.lblDictionaryName.Text = systemDictionaryType.GetDescription();
         if (Request.QueryString["action"] != null && Request.QueryString["action"].ToString() == "update")
         {
             IEnumerable <SystemDictionaryItem> systemDictionaryItems = SystemDictionaryService.Query(systemDictionaryType);
             var itemId         = new Guid(Request.QueryString["Id"]);
             var dictionaryItem = systemDictionaryItems.FirstOrDefault(item => item.Id == itemId);
             if (dictionaryItem == null)
             {
                 return;
             }
             if (dictionaryItem.Name != null)
             {
                 this.txtName.Text = dictionaryItem.Name;
             }
             if (dictionaryItem.Value != null)
             {
                 this.txtValue.Text = dictionaryItem.Value;
             }
             if (dictionaryItem.Remark != null)
             {
                 this.ttRemark.InnerText = dictionaryItem.Remark;
             }
         }
     }
 }
コード例 #4
0
 public void DeleteItem(SystemDictionaryType type, Guid item)
 {
     deleteItem(type, item);
     _datasCache.Save(type, (dictionaryItem) => {
         dictionaryItem.RemoveItem(item);
         return(true);
     });
 }
コード例 #5
0
 public void UpdateItem(SystemDictionaryType type, SystemDictionaryItem item)
 {
     updateItem(type, item);
     _datasCache.Save(type, (dictionaryItem) => {
         dictionaryItem[item.Id].Name   = item.Name;
         dictionaryItem[item.Id].Value  = item.Value;
         dictionaryItem[item.Id].Remark = item.Remark;
         return(true);
     });
 }
コード例 #6
0
        /// <summary>
        /// 查询字典表子项
        /// </summary>
        public static IEnumerable <SystemDictionaryItem> Query(SystemDictionaryType type)
        {
            var systemDictionary = SystemDictionarys.Instance[type];

            if (systemDictionary != null)
            {
                return(systemDictionary.Items);
            }
            return(new List <SystemDictionaryItem>());
        }
コード例 #7
0
        public int DeleteItem(SystemDictionaryType type, Guid id)
        {
            string sql = "DELETE FROM [T_SystemDictionary] WHERE [TYPE]=@TYPE AND [ID]=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("TYPE", (int)type);
                dbOperator.AddParameter("ID", id);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
コード例 #8
0
        public int UpdateItem(SystemDictionaryType type, SystemDictionaryItem item)
        {
            string sql = "UPDATE [T_SystemDictionary] SET [NAME]=@NAME,[VALUE]=@VALUE,[REMARK]=@REMARK WHERE [TYPE]=@TYPE AND [ID]=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("NAME", item.Name);
                dbOperator.AddParameter("VALUE", item.Value);
                dbOperator.AddParameter("REMARK", item.Remark);
                dbOperator.AddParameter("TYPE", (int)type);
                dbOperator.AddParameter("ID", item.Id);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
コード例 #9
0
        public int InsertItem(SystemDictionaryType type, SystemDictionaryItem item)
        {
            string sql = "INSERT INTO [T_SystemDictionary] ([TYPE],[ID],[NAME],[VALUE],[REMARK]) VALUES (@TYPE,@ID,@NAME,@VALUE,@REMARK)";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("TYPE", (int)type);
                dbOperator.AddParameter("ID", item.Id);
                dbOperator.AddParameter("NAME", item.Name);
                dbOperator.AddParameter("VALUE", item.Value);
                dbOperator.AddParameter("REMARK", item.Remark);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
コード例 #10
0
 public void AddItem(SystemDictionaryType type, SystemDictionaryItem item)
 {
     insertItem(type, item);
     _datasCache.Save(type,
                      () => {
         var data = new SystemDictionary(type);
         data.AddItem(item);
         return(data);
     },
                      (dictionaryItem) => {
         dictionaryItem.AddItem(item);
         return(true);
     });
 }
コード例 #11
0
        /// <summary>
        /// 添加字典表子项
        /// </summary>
        public static void AddItem(SystemDictionaryType type, SystemDictionaryItem item, string account)
        {
            if (null == item)
            {
                throw new ArgumentNullException("item");
            }
            // 添加数据
            SystemDictionarys.Instance.AddItem(type, item);
            // 记录日志
            var logContent = string.Format("添加字典表 [{0}] 的子项。内容:{1}", type.GetDescription(), item.ToString());
            var log        = new Service.Log.Domain.OperationLog(OperationModule.系统字典表, OperationType.Insert, account, OperatorRole.Platform, item.Id.ToString(), logContent, DateTime.Now);

            Service.LogService.SaveOperationLog(log);
        }
コード例 #12
0
ファイル: Dictionary.aspx.cs プロジェクト: 842549829/Pool
        private void Refresh()
        {
            SystemDictionaryType dictionaryType = SystemDictionaryType.FirstOrBusinessBunkDescription;

            if (Request.QueryString["categoryId"] != null)
            {
                string categoryId = Request.QueryString["categoryId"].ToString();
                dictionaryType = (SystemDictionaryType)Enum.Parse(typeof(SystemDictionaryType), categoryId);
            }
            this.lblDictionaryName.Text   = dictionaryType.GetDescription();
            this.gvSpecialType.DataSource = SystemDictionaryService.Query(dictionaryType);
            this.gvSpecialType.DataBind();
            this.iType.Value = ((int)dictionaryType).ToString();
        }
コード例 #13
0
        /// <summary>
        /// 删除字典表子项
        /// </summary>
        public static void DeleteItem(SystemDictionaryType type, Guid item, string account)
        {
            var originalItem = SystemDictionarys.Instance[type][item];

            if (null == originalItem)
            {
                throw new ChinaPay.Core.CustomException("原子项不存在");
            }
            var originalContent = originalItem.ToString();

            // 删除数据
            SystemDictionarys.Instance.DeleteItem(type, item);
            // 记录日志
            var logContent = string.Format("删除字典表 [{0}] 的子项。内容:{1}", type.GetDescription(), originalContent);
            var log        = new Service.Log.Domain.OperationLog(OperationModule.系统字典表, OperationType.Delete, account, OperatorRole.Platform, item.ToString(), logContent, DateTime.Now);

            Service.LogService.SaveOperationLog(log);
        }
コード例 #14
0
        /// <summary>
        /// 修改字典表子项
        /// </summary>
        public static void UpdateItem(SystemDictionaryType type, SystemDictionaryItem item, string account)
        {
            if (null == item)
            {
                throw new ArgumentNullException("item");
            }
            var originalItem = SystemDictionarys.Instance[type][item.Id];

            if (null == originalItem)
            {
                throw new ChinaPay.Core.CustomException("原子项不存在");
            }
            var originalContent = originalItem.ToString();

            // 修改数据
            SystemDictionarys.Instance.UpdateItem(type, item);
            // 记录日志
            var logContent = string.Format("修改字典表 [{0}] 的子项。由 {1} 修改为 {2}", type.GetDescription(), originalContent, item.ToString());
            var log        = new Service.Log.Domain.OperationLog(OperationModule.系统字典表, OperationType.Update, account, OperatorRole.Platform, item.Id.ToString(), logContent, DateTime.Now);

            Service.LogService.SaveOperationLog(log);
        }
コード例 #15
0
ファイル: Dictionary.aspx.cs プロジェクト: 842549829/Pool
 protected void gvSpecialType_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "update")
     {
         string id = e.CommandArgument.ToString();
         if (iType.Value.ToString() == "0")
         {
             Response.Redirect("Dictionary_new.aspx?action=update&Id=" + id + "&type=FirstOrBusinessBunkDescription");
         }
         else
         {
             Response.Redirect("Dictionary_new.aspx?Id=" + id + "&action=update&type=" + iType.Value.ToString());
         }
     }
     else if (e.CommandName == "dictionaryDel")
     {
         if (e.CommandArgument != null)
         {
             string type = string.Empty;
             if (iType.Value.ToString() == "0")
             {
                 type = "FirstOrBusinessBunkDescription";
             }
             else
             {
                 type = iType.Value.ToString();
             }
             try
             {
                 SystemDictionaryType systemDictionaryType = (SystemDictionaryType)Enum.Parse(typeof(SystemDictionaryType), type);
                 SystemDictionaryService.DeleteItem(systemDictionaryType, new Guid(e.CommandArgument.ToString()), "");
                 RegisterScript("alert('删除成功!'); window.location.href='Dictionary.aspx';");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "删除");
             }
         }
     }
 }
コード例 #16
0
        void updateItem(SystemDictionaryType type, SystemDictionaryItem item)
        {
            var repository = getRepository();

            repository.UpdateItem(type, item);
        }
コード例 #17
0
 /// <summary>
 /// 获取字典表子项
 /// </summary>
 /// <param name="sdType"> </param>
 /// <returns></returns>
 public object GetDictionaryItems(SystemDictionaryType sdType)
 {
     return(SystemDictionaryService.Query(sdType));
 }
コード例 #18
0
 /// <summary>
 /// 查询推退改签规定
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public object QueryRegulations(SystemDictionaryType type)
 {
     return(SystemDictionaryService.Query(type));
 }
コード例 #19
0
 public SystemDictionary this[SystemDictionaryType type] {
     get {
         return(_datasCache[type]);
     }
 }
コード例 #20
0
        void deleteItem(SystemDictionaryType type, Guid item)
        {
            var repository = getRepository();

            repository.DeleteItem(type, item);
        }
コード例 #21
0
        void insertItem(SystemDictionaryType type, SystemDictionaryItem item)
        {
            var repository = getRepository();

            repository.InsertItem(type, item);
        }
コード例 #22
0
ファイル: SystemDictionary.cs プロジェクト: 842549829/Pool
 internal SystemDictionary(SystemDictionaryType type)
 {
     this.Type   = type;
     _itemsCache = new ChinaPay.Data.Cache <Guid, SystemDictionaryItem>();
 }