123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 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 Management : System.Web.UI.Page
- {
- string StrDB = Admin.PublicClass.myDB.ToString();
- string Strsql = Admin.PublicClass.mysqls.ToString();
- string Strurl = Admin.PublicClass.myurl.ToString();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void Page_Load(object sender, EventArgs e)
- {
- Admin.PublicClass.chkLogin(this);
- if (!IsPostBack)
- {
- bind();
- string type = "";
- if (Request.QueryString["type"] != null)
- {
- type = Request.QueryString["type"].ToString();
- }
- if (type=="add")
- {
- anzhuang();
- }
- else if (type == "update")
- {
- string Strtxt = this.Server.MapPath("~/version.txt");
- string str = string.Empty;
- string phone = Request.QueryString["phone"].ToString();
- this.shengji();
- string mes = Ajax.HttpWebRequestGET("" + Strurl + "/wzyx" + phone + "/index.php?c=updatesql&f=update");
- if (mes.Contains("数据库升级成功"))
- {
- StreamReader reader2 = new StreamReader(Strtxt, System.Text.Encoding.GetEncoding("GB2312"));
- str = reader2.ReadToEnd();
- string vae = str.Split(':')[1].ToString();
- if (vae == Request.QueryString["Versions"])
- {
- Response.Write("<script>alert('已经是最新版本!');</script>");
- }
- else
- {
- string Strupdet = "UPDATE admin SET Versions='" + vae + "' WHERE id=" + Request.QueryString["id"] + "";
- MySqlConnection cons = new MySql.Data.MySqlClient.MySqlConnection(StrDB);
- MySqlCommand das = new MySql.Data.MySqlClient.MySqlCommand(Strupdet, cons);
- try
- {
- cons.Open();
- das.ExecuteNonQuery();
- Response.Write("<script>alert('更新成功!');</script>");
- }
- catch
- {
- Response.Write("<script>alert('更新失败!');</script>");
- }
- finally
- {
- cons.Close();
- }
- }
- }
- else {
- Response.Write("<script>alert('" + mes + "');</script>");
- }
- }
- }
- }
- /// <summary>
- /// 分页绑定数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void AspNetPager1_PageChanged(object sender, EventArgs e)
- {
- bind();
- }
- public void bind()
- {
- string qu = "select id,Name,Contacts,Phone,Address,RegistrationTime,EffectiveTime,Versions,Reception,Backstage,Account,Password,Remark from admin order by id desc";
- MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(StrDB);
- MySqlCommand da = new MySql.Data.MySqlClient.MySqlCommand(qu, con);
- con.Open();
- MySqlDataReader date = da.ExecuteReader();
- DataTable dt = new DataTable();
- dt.Columns.Add("id");
- dt.Columns.Add("Name");
- dt.Columns.Add("Contacts");
- dt.Columns.Add("Phone");
- dt.Columns.Add("Address");
- dt.Columns.Add("RegistrationTime");
- dt.Columns.Add("EffectiveTime");
- dt.Columns.Add("Versions");
- dt.Columns.Add("Reception");
- dt.Columns.Add("Backstage");
- dt.Columns.Add("Account");
- dt.Columns.Add("Password");
- dt.Columns.Add("Remark");
- while (date.Read() == true)
- {
- DataRow row = dt.NewRow();
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- row[i] = date[i];
- } dt.Rows.Add(row);
- }
- date.Close();
- con.Clone();
- PagedDataSource pds = new PagedDataSource();
- AspNetPager1.RecordCount = dt.Rows.Count;
- pds.AllowPaging = true;
- pds.PageSize = AspNetPager1.PageSize;
- pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
- pds.DataSource = dt.DefaultView;
- ret.DataSource = pds;
- ret.DataBind();
- }
- /// <summary>
- /// 安装
- /// </summary>
- public void anzhuang()
- {
- CheckBox cbs = (CheckBox)FindControl("hidi");
- string Strming = Request.QueryString["Phone"];
- string qus = "CREATE DATABASE wzyx" + Strming + "";
- MySqlConnection con = new MySqlConnection(Strsql);
- con.Open();
- try
- {
- MySqlCommand da = new MySqlCommand(qus, con);
- da.ExecuteNonQuery();
- }
- catch
- { Response.Write("<script>alert('数据已经安装过,无须再安装!');</script>"); return; }
- finally
- { con.Clone(); }
- string srcPathS = this.Server.MapPath("~/WZYXInstall");
- string srcPath = this.Server.MapPath("~/wzyx" + Strming + "");
- AddCustomer.CopyFolder(srcPathS, srcPath);//document.location=
- string gourl = Strurl + "/wzyx" + Strming + "/install/index.php?act=setconfig&dbpass=" + Admin.PublicClass.mysqlpwd + "&dbname=wzyx" + Strming + "&adminpass=" + Strming;
- Response.Write("<script>document.location='" + gourl + "';</script>"); return;
- // Response.Redirect("" + Strurl + "/wzyx" + Strming + "/install/index.php?act=setconfig&dbpass=" + mysqlpwd + "&dbname=wzyx" + Strming + "&adminpass=" + Strming + "");
- }
- /// <summary>
- /// 升级
- /// </summary>
- public void shengji()
- {
- string Strming = Request.QueryString["Phone"];
- string srcPathS = this.Server.MapPath("~/WZYXUpdate");
- string srcPath = this.Server.MapPath("~/wzyx" + Strming + "");
- AddCustomer.CopyFolder(srcPathS, srcPath);
- }
- /// <summary>
- /// 一键备份
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void txtbeifen_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < ret.Items.Count; i++)
- {
- string Phone = ((HiddenField)ret.Items[i].FindControl("hidId")).Value;
- string mes = Ajax.HttpWebRequestGET("" + Strurl + "/wzyx" + Phone + "/index.php?c=backupsql&f=backup");
- }
- Response.Write("<script>alert('数据备份完成!');</script>");
- }
- }
- }
|