예제 #1
0
        //删除
        protected void Del_Click(object sender, EventArgs e)
        {
            //Demo
            if (hkdb.IsDemo("Y") == "true")
            {
                return;
            }

            if (superpwd.Text != "Aa123456")
            {
                mydb.Alert("密钥错误!");
                return;
            }

            string cal = "";
            int    i   = 0;

            for (i = 0; i <= GridView1.Rows.Count - 1; i++)
            {
                CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[1].FindControl("del");
                if (cb.Checked == true)
                {
                    if (string.IsNullOrEmpty(cal))
                    {
                        cal = GridView1.DataKeys[i].Value.ToString();
                    }
                    else
                    {
                        cal = cal + "','" + GridView1.DataKeys[i].Value.ToString();
                    }
                }
            }

            if (!string.IsNullOrEmpty(cal))
            {
                SqlDataReader dr = SqlHelper.ExecuteReader("SELECT SourceName FROM hk_DBSource WHERE ProduID='" + xt.SelectedValue + "' AND SourceDesc IN ('" + cal + "')");
                while (dr.Read())
                {
                    SqlHelper.ExecuteSql("TRUNCATE TABLE " + dr["SourceName"] + "");
                }
                dr.Close();

                mydb.Alert("系统数据删除完成!");

                //日志
                mydb.InsertLog("批量删除系统数据【" + hkdb.GetStrClr(cal) + "】", "60113");

                GridViewBind();
            }
            else
            {
                mydb.Alert("删除失败,请先选中记录!");
            }
        }