예제 #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDel_Click(object sender, EventArgs e)
        {
            String strUrids = string.Empty;
            String strNames = string.Empty;

            foreach (GridViewRow gvrow in gvUsers.Rows)
            {
                CheckBox CheckBox = gvrow.FindControl("chbSelect") as CheckBox;
                if (CheckBox.Checked)
                {
                    strUrids += this.gvUsers.DataKeys[gvrow.RowIndex]["Ur_id"].ToString() + "|";
                    strNames += this.gvUsers.DataKeys[gvrow.RowIndex]["Ur_name"].ToString() + ",";
                }
            }
            if (strUrids == "" && strUrids.Length == 0)
            {
                //Jswork.Alert("请至少选择一条记录进行删除", this.Page);

                this.divAlert.Visible = true;
                this.lblAlert.Text    = Resources.Resource.tip_only_delete; //"请至少选择一条记录进行删除";

                return;
            }

            strUrids = strUrids.TrimEnd('|');

            UsersMO usersMO = new UsersMO();

            int iSuccess = 0;

            for (int i = 0; i < strUrids.Split('|').Length; i++)
            {
                StringBuilder strWhere = new StringBuilder();
                strWhere.Append(" 1=1");
                IList <MySqlParameter> parm = new List <MySqlParameter>();

                strWhere.Append(" and Ur_id =@Rl_id");
                parm.Add(new MySqlParameter("@Rl_id", strUrids.Split('|')[i]));
                if (userManage.DelUsers("Ur_del = 1", strWhere.ToString(), parm) > 0)
                //if (userManage.DelUsers("Ur_del = 1", string.Format(" Ur_id = '{0}'", strUrids.Split('|')[i])) > 0)
                {
                    //插入操作日志表
                    InsertLog("删除用户", string.Format("username:{0},id:{1}", strNames.Split(',')[i], strUrids.Split('|')[i]), 3, GetPlatformIdByValue(1));

                    iSuccess += 1;
                }
            }

            if (iSuccess > 0)
            {
                //Jswork.Alert("删除成功", this.Page);
                Jswork.Alert(Resources.Resource.tip_delete_success, this.Page);

                this.BindUsers();
            }
        }