public void deleteMysql(object state)
        {
            int    id  = int.Parse(state.ToString());
            string sql = "select * from mysql where id=" + id;

            if (!DbHelperSQLite.Exists(sql))
            {
                MessageBox.Show("查询此数据库失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DataSet ds = DbHelperSQLite.Query(sql);

            int res = this.deleteMysqlDataFromMySqlCommand(id, ds.Tables[0].Rows[0]["dbname"].ToString(), ds.Tables[0].Rows[0]["dbuser"].ToString());

            if (res == 1)
            {
                string sql_insertmysql = "delete from mysql where id=" + id;


                DbHelperSQLite.ExecuteSql(sql_insertmysql);

                SetLoadingHide hideloding = new SetLoadingHide(Load_Mysql_List_Invoke);
                this.Invoke(hideloding);

                this.writeLog("删除数据库[" + ds.Tables[0].Rows[0]["dbname"].ToString() + "]");
                MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("删除失败,请自行删除,code:102", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from [S_WebSite] where ID=" + ID + " ");
            return(DbHelperSQLite.Exists(strSql.ToString()));
        }
Пример #3
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from SystemGroup");
            strSql.Append(" where Id=" + Id + " ");
            return(DbHelperSQLite.Exists(strSql.ToString()));
        }
Пример #4
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string SERVER_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from IO_SERVER");
            strSql.Append(" where SERVER_ID='" + SERVER_ID + "' ");
            return(DbHelperSQLite.Exists(strSql.ToString()));
        }
Пример #5
0
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int aid)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from BlogArticle");
			strSql.Append(" where aid=@aid");
			SQLiteParameter[] parameters = {
					new SQLiteParameter("@aid", DbType.Int32,4)
			};
			parameters[0].Value = aid;

			return DbHelperSQLite.Exists(strSql.ToString(),parameters);
		}
Пример #6
0
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from insurance_compare");
			strSql.Append(" where id=@id");
			SQLiteParameter[] parameters = {
					new SQLiteParameter("@id", DbType.Int32,4)
			};
			parameters[0].Value = id;

			return DbHelperSQLite.Exists(strSql.ToString(),parameters);
		}
Пример #7
0
        //在这里可以更换数据库,支持多数据库,支持采用加密方式实现
        //DbHelperSQLP DbHelperSQL = new DbHelperSQLP(PubConstant.GetConnectionString("ConnectionString2"));

        #region  基本成员方法

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string ProductId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from UserInfo");
            strSql.Append(" where ID= @Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32)
            };
            parameters[0].Value = ProductId;
            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #8
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int NodeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from S_Tree where NodeID=@NodeID");

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@NodeID")
            };
            parameters[0].Value = NodeID;
            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #9
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from BranchInfo");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.String, 2147483647)
            };
            parameters[0].Value = ID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string CardID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from BlackListCardInfo");
            strSql.Append(" where CardID=@CardID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@CardID", DbType.String)
            };
            parameters[0].Value = CardID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #11
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int paid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from BlogPhotoAlblum");
            strSql.Append(" where paid=@paid");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@paid", DbType.Int32, 4)
            };
            parameters[0].Value = paid;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ExpansionBoardPointID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from ExpansionBoardPointInfo");
            strSql.Append(" where ExpansionBoardPointID=@ExpansionBoardPointID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ExpansionBoardPointID", DbType.Int32, 4)
            };
            parameters[0].Value = ExpansionBoardPointID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #13
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int e_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from Enumeration");
            strSql.Append(" where e_id=@e_id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@e_id", DbType.Int32, 4)
            };
            parameters[0].Value = e_id;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #14
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ICPID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from InterControlProgram");
            strSql.Append(" where ICPID=@ICPID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ICPID", DbType.Int32, 4)
            };
            parameters[0].Value = ICPID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #15
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string ProjectId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from ScadaFlowProject");
            strSql.Append(" where ProjectId=@ProjectId");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ProjectId", DbType.String)
            };
            parameters[0].Value = ProjectId;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #16
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int Lid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from Log");
            strSql.Append(" where Lid=@Lid ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Lid", DbType.Int32, 8)
            };
            parameters[0].Value = Lid;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int SOPID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from StandardOperateProcedure");
            strSql.Append(" where SOPID=@SOPID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@SOPID", DbType.Int32, 4)
            };
            parameters[0].Value = SOPID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #18
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from Classify_DRIVER");
            strSql.Append(" where Id=@Id ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32, 8)
            };
            parameters[0].Value = Id;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ReaderID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from ReaderInfo");
            strSql.Append(" where ReaderID=@ReaderID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ReaderID", DbType.Int32, 4)
            };
            parameters[0].Value = ReaderID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #20
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int MendiaPictureGroupID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from MendiaPictureGroup");
            strSql.Append(" where MendiaPictureGroupID=@MendiaPictureGroupID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@MendiaPictureGroupID", DbType.Int32, 4)
            };
            parameters[0].Value = MendiaPictureGroupID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #21
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int AU_LayerNodeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from AU_LayerNode");
            strSql.Append(" where AU_LayerNodeID=@AU_LayerNodeID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@AU_LayerNodeID", DbType.Int32, 4)
            };
            parameters[0].Value = AU_LayerNodeID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #22
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int WebAttitudesID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from WebAttitudes");
            strSql.Append(" where WebAttitudesID=@WebAttitudesID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@WebAttitudesID", DbType.Int32, 4)
            };
            parameters[0].Value = WebAttitudesID;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #23
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string userName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from users");
            strSql.Append(" where userName=@userName ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@userName", DbType.String, 25)
            };
            parameters[0].Value = userName;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #24
0
        public bool Exists(string ZJ)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from uc_jsgngl");
            strSql.Append(" where ");
            strSql.Append(" ZJ = @ZJ  ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ZJ", DbType.String)
            };
            parameters[0].Value = ZJ;

            return(DbHelperSQLite.Exists(strSql.ToString(), parameters));
        }
Пример #25
0
        public bool Exists(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from MapElement");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
                return(DbHelperSQLite.Exists(strSql.ToString()));
            }
            else
            {
                return(false);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string dbname = this.textBox1.Text.Trim();
                string dbuser = this.textBox4.Text.Trim();
                string dbpass = this.textBox2.Text;
                if (dbname == null || dbname.Equals(""))
                {
                    MessageBox.Show("数据库名必须填写", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (dbuser == null || dbuser.Equals(""))
                {
                    MessageBox.Show("用户名不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (dbpass == null || dbpass.Equals(""))
                {
                    MessageBox.Show("用户密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //--start 判断库里是否已经存在同名数据库信息
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select count(1) from mysql");
                strSql2.Append(" where dbname=@dbname ");
                SQLiteParameter[] parameters2 =
                {
                    new SQLiteParameter("@dbname")
                };
                parameters2[0].Value = dbname;
                if (DbHelperSQLite.Exists(strSql2.ToString(), parameters2))
                {
                    MessageBox.Show("此同名数据库已存在,请删除或手动添加其他名称数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //--end 判断库里是否已经存在同名数据库信息


                //--start 插入一条数据库站信息入软件Sqlite数据库
                string            sql   = "insert into mysql(dbname,dbuser,dbpass) values(@dbname,@dbuser,@dbpass)";
                SQLiteParameter[] paras = new SQLiteParameter[] { new SQLiteParameter("@dbname", dbname), new SQLiteParameter("@dbuser", dbuser), new SQLiteParameter("@dbpass", dbpass) };
                int res = DbHelperSQLite.ExecuteSql(sql, paras);


                //--end 插入一条数据库信息入软件Sqlite数据库

                if (res == 1)
                {
                    AddApacheWeb apacheWeb   = new AddApacheWeb();
                    int          mysqlCreate = apacheWeb.CreateMysqlDataBase(dbname, dbuser, dbpass);
                    if (mysqlCreate == 1)
                    {
                        MessageBox.Show("数据库添加成功");
                        Form1.form1.load_mysql_list();
                        this.Hide();
                    }
                    else
                    {
                        StringBuilder delete_strSql = new StringBuilder();
                        delete_strSql.Append("delete from mysql ");
                        delete_strSql.Append(" where dbname=@dbname ");
                        SQLiteParameter[] delete_parameters =
                        {
                            new SQLiteParameter("@dbname")
                        };
                        delete_parameters[0].Value = dbname;
                        int rows = DbHelperSQLite.ExecuteSql(delete_strSql.ToString(), delete_parameters);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("新增数据库失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #27
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string domain     = this.textBox1.Text.Trim();
                string domain2    = this.textBox4.Text.Trim();
                string webindex   = this.textBox7.Text;
                string port       = this.textBox2.Text.Trim();
                string rewrite    = this.textBox5.Text;
                string path       = this.textBox3.Text.Trim();
                string ca         = this.textBox6.Text;
                string key        = this.textBox8.Text;
                string webtype    = this.comboBox2.Text;
                string proxy_path = this.textBox10.Text;
                string proxy_url  = this.textBox9.Text;

                int    gzip    = 0;
                int    https   = 0;
                int    proxy   = 0;
                string str_add = "";

                if (domain == null || domain.Equals(""))
                {
                    MessageBox.Show("主域名必须填写", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (port == null || port.Equals(""))
                {
                    MessageBox.Show("端口不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (path == null || path.Equals(""))
                {
                    MessageBox.Show("根目录不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (webindex == null || webindex.Equals(""))
                {
                    MessageBox.Show("默认首页不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (this.checkBox3.Checked)
                {
                    https = 1;
                    if (ca == null || ca.Equals(""))
                    {
                        MessageBox.Show("CA证书不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (key == null || key.Equals(""))
                    {
                        MessageBox.Show("证书私钥不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }


                if (this.checkBox4.Checked)
                {
                    proxy = 1;
                    if (proxy_path == null || proxy_path.Equals(""))
                    {
                        MessageBox.Show("反代配置目录不能为空,根目录请填写/", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (proxy_url == null || proxy_url.Equals(""))
                    {
                        MessageBox.Show("反代URL不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }



                //--start 判断库里是否已经存在此网站信息
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select count(1) from apacheweblist");
                strSql.Append(" where domain=@domain ");
                SQLiteParameter[] parameters =
                {
                    new SQLiteParameter("@domain")
                };
                parameters[0].Value = domain;
                if (DbHelperSQLite.Exists(strSql.ToString(), parameters))
                {
                    MessageBox.Show("此域名网站已经存在,请勿重复添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //--end 判断库里是否已经存在此网站信息

                if (checkBox1.Checked)
                {
                    //--start 判断库里是否已经存在同名数据库信息
                    StringBuilder strSql2 = new StringBuilder();
                    strSql2.Append("select count(1) from mysql");
                    strSql2.Append(" where dbname=@dbname ");
                    SQLiteParameter[] parameters2 =
                    {
                        new SQLiteParameter("@dbname")
                    };
                    parameters2[0].Value = domain.Replace(".", "_");
                    if (DbHelperSQLite.Exists(strSql2.ToString(), parameters2))
                    {
                        MessageBox.Show("此同名数据库已存在,请删除或手动添加其他名称数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //--end 判断库里是否已经存在同名数据库信息
                }

                if (checkBox2.Checked)
                {
                    gzip = 1;
                }

                //--start 插入一条网站信息入软件Sqlite数据库
                string            sql   = "insert into apacheweblist(domain,domain2,webindex,port,path,rewrite,gzip,https,https_ca,https_key,proxy,proxy_path,proxy_url,type) values(@domain,@domain2,@webindex,@port,@path,@rewrite,@gzip,@https,@https_ca,@https_key,@proxy,@proxy_path,@proxy_url,@type)";
                SQLiteParameter[] paras = new SQLiteParameter[] { new SQLiteParameter("@domain", domain), new SQLiteParameter("@domain2", domain2), new SQLiteParameter("@webindex", webindex), new SQLiteParameter("@port", port), new SQLiteParameter("@path", path), new SQLiteParameter("@rewrite", rewrite), new SQLiteParameter("@gzip", gzip), new SQLiteParameter("@https", https), new SQLiteParameter("@https_ca", ca), new SQLiteParameter("@https_key", key), new SQLiteParameter("@proxy", proxy), new SQLiteParameter("@proxy_path", proxy_path), new SQLiteParameter("@proxy_url", proxy_url), new SQLiteParameter("@type", webtype) };


                int res = DbHelperSQLite.ExecuteSql(sql, paras);


                //--end 插入一条网站信息入软件Sqlite数据库

                if (res == 1)
                {
                    //--start 选中了创建mysql数据库,执行数据库创建操作
                    if (checkBox1.Checked)
                    {
                        MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                        Random   rd      = new Random();
                        TimeSpan ts      = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                        string   nowRand = Convert.ToInt64(ts.TotalSeconds).ToString() + "qwe@123@asd@456@zxc@789" + rd.Next().ToString();

                        string dbpass = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(nowRand), 4, 8));
                        dbpass = dbpass.Replace("-", "");
                        dbpass = dbpass.ToLower();
                        int mysqlCreate = this.CreateMysqlDataBase(domain.Replace(".", "_"), domain.Replace(".", "_"), dbpass);
                        if (mysqlCreate == 1)
                        {
                            str_add = "";
                            string            sql_insertmysql   = "insert into mysql(dbname,dbpass,dbuser) values(@dbname,@dbpass,@dbuser)";
                            SQLiteParameter[] paras_insertmysql = new SQLiteParameter[] { new SQLiteParameter("@dbname", domain.Replace(".", "_")), new SQLiteParameter("@dbpass", dbpass), new SQLiteParameter("@dbuser", domain.Replace(".", "_")) };

                            DbHelperSQLite.ExecuteSql(sql_insertmysql, paras_insertmysql);
                            Form1.form1.load_mysql_list();
                        }
                        else
                        {
                            str_add = "mysql 创建失败!";
                        }
                    }
                    //--end 选中了创建mysql数据库,执行数据库创建操作

                    //
                    if (this.comboBox2.Text.Equals("JAVA"))
                    {
                        webindex = "";
                        int createTomcatConf = this.add_tomcat_web_xml(domain, path, tomcat_port.ToString());
                        if (createTomcatConf != 1)
                        {
                            str_add += "Tomcat配置文件写入失败!";
                        }
                        else
                        {
                            Form1.form1.button13_Click(null, null);
                        }
                    }
                    //

                    Form1.form1.writeLog("网站添加成功 " + str_add);
                    MessageBox.Show("网站添加成功\n" + str_add);
                    this.setApacheConf(domain, domain2, webindex, port, path, https);
                    Form1.form1.load_apache_web();
                    Form1.form1.button3_Click(null, null);
                    this.Hide();
                }
            }
            catch (Exception ep)
            {
                MessageBox.Show("新增网站失败:" + ep.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Form1.form1.writeLog("新增网站失败");
            }
        }