Example #1
0
        /// <summary>
        /// 修改或删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GVinfo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    Id     = 0;  // 保存ID
            int    theRow = 0;  // 保存行号
            string theCol = ""; // 保存列位置信息

            theRow = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            theCol = e.CommandName.ToString();
            Id     = Convert.ToInt32(GVinfo.DataKeys[theRow].Value);
            BLL.CMS_AdminUser bau = new BLL.CMS_AdminUser();

            switch (e.CommandName)
            {
            case "MyDel": bau.Delete(Id); break;     // 删除操作

            case "MyUp":
            {
                Model.CMS_AdminUser user = new Model.CMS_AdminUser();
                user                  = bau.GetModel(Id);
                Panel1.Visible        = true;
                tbUserName.Text       = user.Name;
                ddlRole.SelectedValue = user.RoleId.ToString();

                break;
            }
            }

            Flush();
        }
Example #2
0
        /// <summary>
        /// 新增保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            BLL.CMS_AdminUser   bau  = new BLL.CMS_AdminUser();
            Model.CMS_AdminUser user = new Model.CMS_AdminUser();
            user.Name   = tbUserName.Text;
            user.Pwd    = FormsAuthentication.HashPasswordForStoringInConfigFile(tbUserPwd.Text, "MD5");
            user.RoleId = Convert.ToInt32(ddlRole.Text);

            bau.Add(user);

            Flush();
        }