示例#1
0
        protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int id = int.Parse(e.CommandArgument.ToString());

            switch (e.CommandName)
            {
            case "sel":
            {
                EnuminfoBLL   con  = new EnuminfoBLL();
                EnumInfoModel info = con.GetModel(id);
                txtName.Text        = info.enumName;
                txtDescription.Text = info.enumDescription;
                txtValueInfo.Text   = info.enumValueInfo;
                AddorEditMode(true);
                EditKey.Text = e.CommandArgument.ToString();
            }
            break;

            case "del":
            {
                EnuminfoBLL con = new EnuminfoBLL();
                con.Delete(id);
                Bind();
            }
            break;
            }
        }
示例#2
0
        private void Bind()
        {
            EnuminfoBLL dal = new EnuminfoBLL();

            GridView.DataSource = dal.GetList(SlnID);
            GridView.DataBind();
        }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Bind();
         if (!string.IsNullOrEmpty(Request["enum"]))
         {
             string enumName = Request["enum"].Trim(new char[] { '【', '】' });
             txtName.Text = enumName;
             EnuminfoBLL   dal  = new EnuminfoBLL();
             EnumInfoModel info = dal.GetModel(enumName, SlnID.ToString());
             if (info != null)
             {
                 txtDescription.Text = info.enumDescription;
                 txtValueInfo.Text   = info.enumValueInfo;
                 AddorEditMode(true);
                 EditKey.Text = info.ID.ToString();
             }
             else
             {
                 txtName.Text = enumName;
                 AddorEditMode(false);
             }
         }
     }
 }
示例#4
0
 protected void butSubmit_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(EditKey.Text))
     {
         try
         {
             EnuminfoBLL   con   = new EnuminfoBLL();
             EnumInfoModel model = new EnumInfoModel();
             model.enumName        = txtName.Text;
             model.enumDescription = txtDescription.Text;
             model.enumValueInfo   = txtValueInfo.Text;
             model.SlnID           = SlnID;
             if (con.Add(model))
             {
                 Bind();
                 btCancelButton_Click(null, null);
                 return;
             }
         }
         catch (Exception ex)
         {
             Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败!')</script>");
         }
     }
     else
     {
         try
         {
             EnuminfoBLL   con   = new EnuminfoBLL();
             EnumInfoModel model = new EnumInfoModel();
             model.enumName        = txtName.Text;
             model.enumDescription = txtDescription.Text;
             model.enumValueInfo   = txtValueInfo.Text;
             model.SlnID           = SlnID;
             model.ID = int.Parse(EditKey.Text);
             if (con.Update(model))
             {
                 Bind();
                 btCancelButton_Click(null, null);
                 return;
             }
         }
         catch (Exception ex)
         {
             Page.RegisterStartupScript("", "<script language=javascript>alert('编辑失败!')</script>");
         }
     }
 }
示例#5
0
 public static Hashtable LoadEnumApplication(int slnid, bool clean)
 {
     if (System.Web.HttpContext.Current.Application[slnid.ToString()] == null || clean)
     {
         Hashtable   ht  = new Hashtable();
         EnuminfoBLL dal = new EnuminfoBLL();
         DataTable   dt  = dal.GetList(slnid).Tables[0];
         foreach (DataRow dr in dt.Rows)
         {
             string key = "【" + dr["enumName"].ToString() + "】";
             if (!ht.Contains(key))
             {
                 ht.Add(key, string.Format("{0}\n\n{1}", dr["enumDescription"].ToString(),
                                           dr["enumValueInfo"].ToString()));
             }
         }
         System.Web.HttpContext.Current.Application[slnid.ToString()] = ht;
         return(ht);
     }
     else
     {
         return((Hashtable)System.Web.HttpContext.Current.Application[slnid.ToString()]);
     }
 }