Beispiel #1
0
        private void excel2btn_Click(object sender, EventArgs e)
        {
            var inputlist = new Dictionary <string, List <string> >();

            for (var i = 0; i < node.Nodes.Count; i++)
            {
                var curnode = node.Nodes[i];

                var str     = new StringBuilder();
                var dicitem = dic[curnode.Text];
                if (curnode.Checked)
                {
                    var alldata = new List <string>();


                    var cols = ds.Data.Tables[curnode.Text];
                    //处理表名
                    str.Append($"{curnode.Text}\t{dicitem}");
                    str.Append("\n");
                    //处理header
                    foreach (DataColumn item in cols.Columns)
                    {
                        str.Append($"{item.Caption}\t");
                    }
                    str.Append("\n");
                    //处理行
                    foreach (DataRow item in cols.Rows)
                    {
                        StringBuilder sb = new StringBuilder();
                        for (var p = 0; p < cols.Columns.Count; p++)
                        {
                            sb.Append($"{item[p].ToString()}\t");
                        }
                        sb.Append("\n");
                        str.Append(sb.ToString());
                    }
                    alldata = str.ToString().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                    inputlist.Add(curnode.Text, alldata);
                }
            }
            var db = new Datebasemodel();

            db.Dbip         = Dbip.Text;
            db.Dbtype       = Dbtype.SelectedItem.ToString();
            db.Dbname       = Dbname.Text;
            db.Dbport       = Dbport.Text;
            db.Useraccount  = Useraccount.Text;
            db.Userpassword = Userpassword.Text;
            db.Name         = Name.Text;

            //结果str
            StringBuilder resstr = new StringBuilder();

            foreach (var item in inputlist)
            {
                var res = CreateTableLogic.CreateTble(item.Value, true, db);
                resstr.AppendLine($"{item.Key}表:{res.Message}");
            }
            this.excel2result.Text = resstr.ToString();
        }
Beispiel #2
0
        private void consql_Click(object sender, EventArgs e)
        {
            var model = new Datebasemodel();

            model.Dbip         = Dbip.Text;
            model.Dbport       = Dbport.Text;
            model.Dbtype       = Dbtype.Text;
            model.Useraccount  = Useraccount.Text;
            model.Userpassword = Userpassword.Text;

            DbConnection conn = CreateTableLogic.GetConnByType(model);

            if (conn == null)
            {
                MessageBox.Show("连接失败");
            }
            else
            {
                MessageBox.Show("连接成功");
            }
        }
Beispiel #3
0
        private void Createtablebtn_Click(object sender, EventArgs e)
        {
            var db = new Datebasemodel();

            db.Dbip         = Dbip.Text;
            db.Dbtype       = Dbtype.SelectedItem.ToString();
            db.Dbname       = Dbname.Text;
            db.Dbport       = Dbport.Text;
            db.Useraccount  = Useraccount.Text;
            db.Userpassword = Userpassword.Text;
            db.Name         = Name.Text;

            var alldata = this.tableinfo.Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
            var res     = CreateTableLogic.CreateTble(alldata, this.Isdrop.Checked, db);

            if (res.IsSucceed)
            {
                this.Resultrichnew.Text = res.Message;
            }
            else
            {
                this.Resultrichnew.Text = "创建失败";
            }
        }