📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication1
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
DBClass db = new DBClass();
private void button1_Click(object sender, EventArgs e)
{
try
{
string sql_class = "select * from class "; //取各个大类名称和编码
DataSet ds_class = db.GetDataSet(sql_class);
foreach (DataRow dr_class in ds_class.Tables[0].Rows)
{
string sql = "select * from Type_" + dr_class["ClassCode"]; //读取行业、地区、概念等分类列表
DataSet ds = db.GetDataSet(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
string TypeName = dr["TypeName"].ToString(); //分类名称 如:上海板块、金融行业等
label1.Text = TypeName;
label1.Refresh();
string sql2 = "select FullCode from type_blockcode where TypeName='" + TypeName + "' and fullCode in (select name from " + Settings1.Default.FenBi.Substring(50, 7) + "..sysobjects where type='U' ) "; //取此行业包括的股票
DataSet ds_stock = db.GetDataSet(sql2);
if (ds_stock.Tables[0].Rows.Count > 0)
{
if (ds_stock.Tables[0].Rows.Count <= 250)
{
string sql_view = "create view " + dr_class["ClassCode"] + "_" + TypeName + " as";
sql_view = sql_view + " select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[0]["FullCode"];
for (int i = 1; i < ds_stock.Tables[0].Rows.Count; i++)
{
sql_view = sql_view + " union select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[i]["FullCode"]; //此行业所有的股票和起来建成一个视图
}
int j = db.ExcuteSQLFB(sql_view);
}
else
{
string sql_view = "create view " + dr_class["ClassCode"] + "_" + TypeName + " as";
sql_view = sql_view + " select * from " + ds_stock.Tables[0].Rows[0]["FullCode"];
string duoge = "create view " + dr_class["ClassCode"] + "_" + TypeName + "_1 as";
duoge = duoge + " select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[0]["FullCode"];
int index = 1;
for (int i = 1; i <= ds_stock.Tables[0].Rows.Count; i++)
{
if (i <= 250)
{
duoge = duoge + " union select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[i]["FullCode"];
if (i == 250)
{
int k = db.ExcuteSQLFB(duoge);
}
}
else if (i > 250)
{
if ((i - 1) % 250 == 0)
{
index = index + 1;
duoge = "create view " + dr_class["ClassCode"] + "_" + TypeName + "_" + index + " as";
duoge = duoge + " select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[i]["FullCode"];
}
if (i < ds_stock.Tables[0].Rows.Count - 1)
{
duoge = duoge + " union select '" + ds_stock.Tables[0].Rows[0]["FullCode"] + "' as FullCode,* from " + ds_stock.Tables[0].Rows[i + 1]["FullCode"];
}
if ((i - 250) % 250 == 0 || i == ds_stock.Tables[0].Rows.Count)
{
int k2 = db.ExcuteSQLFB(duoge);
}
}
}
string view_sum = "create view " + dr_class["ClassCode"] + "_" + TypeName + " as";
view_sum = view_sum + " select * from " + dr_class["ClassCode"] + "_" + TypeName + "_1";
for (int j = 2; j <= index; j++)
{
view_sum = view_sum + " union select * from " + dr_class["ClassCode"] + "_" + TypeName + "_" + j;
}
int k3 = db.ExcuteSQLFB(view_sum);
//StockTime,Price,Volume,Amount,SP1,SP2,SP3,SP4,SP5,SV1,SV2,SV3,SV4,SV5,
// BP1,BP2,BP3,BP4,BP5,BV1,BV2,BV3,BV4,BV5,isBuy
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btWatch_Click(object sender, EventArgs e)
{
WatchFenBi wfb = new WatchFenBi();
wfb.Show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -