Example #1
0
 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, "修改");
             }
         }
     }
 }