123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using MySql.Data.MySqlClient;
- using System.Diagnostics;
- using System.Collections;
- using System.IO;
- using Microsoft.Win32;
- using System.Data;
- using System.Text.RegularExpressions;
- using System.Web.UI.HtmlControls;
- using System.Configuration;
- namespace LYFZ.NationalMarketing
- {
- public partial class Check : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- { }
- string strDB = Admin.PublicClass.myDB.ToString();
- string strchuuang = Admin.PublicClass.mysqls.ToString();
- protected void Button1_Click(object sender, EventArgs e)
- {
- Admin.PublicClass.chkLogin(this);
- string[] StrID = Request.QueryString["id"].Split(',');
- if (Request.QueryString["id"] == "")
- {
- Response.Write("<script>alert('请选择要删除的数据!');</script>"); return;
- }
- if (this.shujuku.Checked == true)
- {
- for (int i = 0; i < StrID.Length - 1; i++)
- {
- string StrPhone = StrID[i].Split('_')[1];
- string Strshujuku = "SELECT `SCHEMA_NAME` FROM `information_schema`.`SCHEMATA` WHERE SCHEMA_NAME='wzyx" + StrPhone + "'";
- string Strdelete = "DROP DATABASE wzyx" + StrPhone + "";
- MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(strchuuang);
- MySqlCommand da = new MySql.Data.MySqlClient.MySqlCommand(Strshujuku, con);
- con.Open();
- MySqlDataReader date = da.ExecuteReader();
- int leng = 0;
- while (date.Read())
- {
- leng++;
- }
- con.Clone();
- if (leng > 0)
- {
- MySqlConnection cons = new MySql.Data.MySqlClient.MySqlConnection(strchuuang);
- MySqlCommand das = new MySql.Data.MySqlClient.MySqlCommand(Strdelete, cons);
- cons.Open();
- das.ExecuteNonQuery();
- cons.Clone();
- }
- else
- {
- Response.Write("<script>alert('数据库不存在!');</script>"); return;
- }
- con.Close();
- }
- // Response.Write("<script>alert('数据库删除成功!');</script>");
- }
- if (this.shuju.Checked == true)
- {
- string Sphone = Request.QueryString["id"].Split('_')[1].Split(',')[0].ToString();
- string Strjies = this.Server.MapPath("~/wzyx" + Sphone + "");
- if (!Directory.Exists(Strjies))
- {
- Response.Write("<script>alert('源站点不存在!');</script>"); return;
- }
- for (int i = 0; i < StrID.Length - 1; i++)
- {
- string StrPhone = StrID[i].Split('_')[1].ToString();
- string Strjie = this.Server.MapPath("~/wzyx" + StrPhone + "");
- if (Directory.Exists(Strjie))
- {
- Directory.Delete(Strjie, true);
- }
- else { return; }
- }
- // Response.Write("<script>alert('源站点删除成功!');</script>");
- }
- this.Delete();
- Response.Write("<script>alert('删除成功!');window.close(); parent.location = 'Management.aspx';</script> ");
- }
- public void Delete()
- {
- string[] StrID = Request.QueryString["id"].Split(',');
- for (int i = 0; i < StrID.Length - 1; i++)
- {
- string ID = StrID[i].Split('_')[0];
- string Delete = "DELETE FROM admin WHERE id=" + ID + "";
- MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(strDB);
- MySqlCommand da = new MySql.Data.MySqlClient.MySqlCommand(Delete, con);
- con.Open();
- da.ExecuteNonQuery();
- con.Close();
- }
- }
- }
- }
|