123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- 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 AddCustomer : System.Web.UI.Page
- {
-
- protected void Page_Load(object sender, EventArgs e)
- {
- Admin.PublicClass.chkLogin(this);
- if (!IsPostBack)
- {
- if (Request.QueryString["Name"] != null)
- {
- this.Panel1.Visible = true;
- this.txtname.ReadOnly = true;
- this.txtlianxi.ReadOnly = true;
- this.Button1.Text = "更 新";
- this.txtname.Text = Request.QueryString["Name"].ToString();
- this.txtdizhi.Text = Request.QueryString["Address"].ToString();
- this.txtlianxi.Text = Request.QueryString["Contacts"].ToString();
- this.txtdianhua.Value = Request.QueryString["Phone"].ToString();
- this.txtstart.Value = Request.QueryString["EffectiveTime"].ToString();
- this.txtbeizhu.Text = Request.QueryString["Remark"].ToString();
- this.txtqiantai.Text = Request.QueryString["Reception"].ToString();
- this.txthoutai.Text = Request.QueryString["Backstage"].ToString();
- }
- }
- }
- string StrDB = Admin.PublicClass.myDB.ToString();
- string Strsql = Admin.PublicClass.mysqls.ToString();
- string Strurl = Admin.PublicClass.myurl.ToString();
-
-
-
-
-
- protected void Button2_Click(object sender, EventArgs e)
- {
- string Strming = this.txtdianhua.Value;
- if (this.txtname.Text == "")
- {
- Response.Write("<script>alert('请输入客户名称!');</script>"); return;
- }
- if (this.txtdianhua.Value == "")
- {
- Response.Write("<script>alert('请输入联系电话!');</script>"); return;
- }
- this.anzhuang();
- }
-
-
-
-
-
- protected void Button1_Click(object sender, EventArgs e)
- {
- string Strhh = this.txtdianhua.Value.Trim();
- DateTime dt = DateTime.Now;
- if (this.Button1.Text == "提 交")
- {
- if (this.txtlianxi.Text == "")
- {
- Response.Write("<script>alert('请输入联系人!');</script>"); return;
- }
- if (this.txtdianhua.Value == "")
- {
- Response.Write("<script>alert('请输入联系人电话!');</script>"); return;
- }
- string cVNumber = System.IO.File.ReadAllText(Server.MapPath("~/WZYXInstall/version.txt")).Split(':')[1];
- string qu = "insert into admin(Name,Address,Contacts,Phone,Remark,RegistrationTime,EffectiveTime,Versions,Reception,Backstage,Account,Password) values('" + this.txtname.Text + "','" + this.txtdizhi.Text + "','" + this.txtlianxi.Text + "','" + this.txtdianhua.Value + "','" + this.txtbeizhu.Text + "','" + dt.Date.ToString("yyyy-MM-dd") + "','" + this.txtstart.Value + "','" + cVNumber + "','" + Strurl + "/wzyx" + Strhh + "/index.php?c=home','" + Strurl + "/wzyx" + Strhh + "/admin.php','admin','" + this.txtdianhua.Value + "')";
- MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(StrDB);
- con.Open();
- try
- {
- MySqlCommand da = new MySql.Data.MySqlClient.MySqlCommand(qu, con);
- da.ExecuteNonQuery();
- Response.Write("<script>alert('添加成功!');document.location='Management.aspx';</script>");
-
- }
- catch
- {
- Response.Write("<script>alert('添加失败!');</script>");
- }
- finally
- {
- con.Clone();
- }
- }
- else
- {
- if (Request.QueryString["id"] != null)
- {
- string sqlset = "UPDATE admin SET Name='" + this.txtname.Text + "',Address='" + this.txtdizhi.Text + "',Contacts='" + this.txtlianxi.Text + "',Phone='" + this.txtdianhua.Value + "',Remark='" + this.txtbeizhu.Text + "',EffectiveTime='" + this.txtstart.Value + "' WHERE id=" + Request.QueryString["id"] + "";
- MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(StrDB);
- con.Open();
- try
- {
- MySqlCommand da = new MySql.Data.MySqlClient.MySqlCommand(sqlset, con);
- da.ExecuteNonQuery();
- Response.Write("<script>alert('更新成功!');document.location='Management.aspx';</script>");
- }
- catch
- {
- Response.Write("<script>alert('更新失败!');</script>");
- }
- finally
- {
- con.Clone();
- }
- }
- }
- }
- public static bool CopyFolder(string strFromPath, string strToPath)
- {
-
- if (!Directory.Exists(strFromPath))
- {
- return false;
- }
-
- string strFolderName = strFromPath.Substring(strFromPath.LastIndexOf("\\") + 1, strFromPath.Length - strFromPath.LastIndexOf("\\") - 1);
-
- if (!Directory.Exists(strToPath))
- {
- Directory.CreateDirectory(strToPath);
- }
-
- string[] strFiles = Directory.GetFiles(strFromPath);
-
- for (int i = 0; i < strFiles.Length; i++)
- {
-
- string strFileName = strFiles[i].Substring(strFiles[i].LastIndexOf("\\") + 1, strFiles[i].Length - strFiles[i].LastIndexOf("\\") - 1);
-
-
-
- File.Copy(strFiles[i], strToPath + "\\" + strFileName, true);
- }
-
- DirectoryInfo dirInfo = new DirectoryInfo(strFromPath);
-
- DirectoryInfo[] ZiPath = dirInfo.GetDirectories();
- for (int j = 0; j < ZiPath.Length; j++)
- {
-
- string strZiPath = strFromPath + "\\" + ZiPath[j].ToString();
- string dirName = System.IO.Path.GetFileName(strZiPath);
-
- CopyFolder(strZiPath, strToPath + "\\" + dirName);
- }
- return true;
- }
-
-
-
- public void anzhuang()
- {
- string Strming = this.txtdianhua.Value;
- string qus = "CREATE DATABASE wzyx" + txtdianhua.Value + "";
- 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 + "");
- CopyFolder(srcPathS, srcPath);
-
-
- Response.Redirect("" + Strurl + "/wzyx" + Strming + "/install/index.php?act=setconfig&dbpass=root&dbname=wzyx" + Strming + "&adminpass=" + Strming + "");
- }
- }
- }
|