继续贴代码

来源:互联网 发布:阿里云 修改帐号密码 编辑:程序博客网 时间:2024/05/17 06:17

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))
            {
                return;
            }
            int paramcount = 0;
            StringBuilder sbparam = new StringBuilder();
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                if (dataGridView1.Rows[i] == null)
                {
                    continue;
                }

                if (dataGridView1.Rows[i].Cells[0] == null)
                {
                    continue;
                }

                if (dataGridView1.Rows[i].Cells[0].Value == null)
                {
                    continue;
                }

                if (dataGridView1.Rows[i].Cells[0].Value.Equals(""))
                {
                    continue;
                }
                paramcount++;
                sbparam.Append("<PARAMENT ID=/"");
                sbparam.Append(dataGridView1.Rows[i].Cells[0].Value);
                sbparam.Append("/" TYPE=/"");
                sbparam.Append(dataGridView1.Rows[i].Cells[1].Value);
                sbparam.Append("/" />");
            }

            StringBuilder sb = new StringBuilder();
            sb.Append("<SQL ID=/"");
            sb.Append(textBox3.Text);
            sb.Append("/" PARAMCOUNT=/"");
            sb.Append(paramcount);
            sb.Append("/" >");

            sb.Append("<STATMENT>");
            sb.Append(textBox1.Text);
            sb.Append("</STATMENT>");

            sb.Append(sbparam);


            sb.Append("</SQL>");

            textBox2.Text = sb.ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn)dataGridView1.Columns[1];
            column.Items.AddRange(Enum.GetNames(typeof(MySql.Data.MySqlClient.MySqlDbType)));
        }
    }
}

原创粉丝点击