📄 frmblueball.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;
using DataAccessLayer;
namespace cpzh
{
public partial class frmBlueBall : Form
{
private OLEDBAccessObj dbObj;
private HistoryAnalyse historyAnalyse;
public frmBlueBall()
{
this.dbObj = new OLEDBAccessObj();
this.dbObj.ConnectDB();
this.historyAnalyse = new HistoryAnalyse(this.dbObj);
InitializeComponent();
}
private void frmBlueBall_Load(object sender, EventArgs e)
{
Groups groups = new Groups();
groups.FillCB(cbBlueBallNo, 16);
//初始化dgvHistoryView
SetDgvType();
}
private void btnForecast_Click(object sender, EventArgs e)
{
int proBlueBall;
string forecaseResult;
//验证是否注册
if (!Register.IS_REGISTER)
{
MessageBox.Show("此规律为他人辛苦总结所得.\r\n请支持他人劳动成果.\r\n请联系作者获得注册号.","软件注册提示");
return;
}
proBlueBall =int.Parse (cbBlueBallNo .Text.ToString ());
if (proBlueBall < 1 || proBlueBall > 16)
{
MessageBox.Show("上期蓝球中奖号码有误,超出范围,请检查!");
return;
}
ArrayList forecast = new ArrayList();
BlueBall blueBalls = new BlueBall();
//获得预测结果
forecast = blueBalls.GetFilterResult(proBlueBall);
forecaseResult = "";
//把第一个数据赋值给结果变量
if (forecast.Capacity > 0)
{
forecaseResult = forecast[0].ToString();
}
//把其他剩余数据赋值给结果变量
for (int i = 1; i < forecast.Count ; i++)
{
forecaseResult = forecaseResult +","+ forecast[i].ToString();
}
txtForecastNo.Text = forecaseResult;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtForecastNo_TextChanged(object sender, EventArgs e)
{
}
#region//初始化dgvHistoryView
private void SetDgvType()
{
dgvHistoryView.Rows.Clear();
dgvHistoryView.DataSource = null;
dgvHistoryView.ColumnCount = 19;
//设置奇数行的样式
//DataGridViewCellStyle style = new DataGridViewCellStyle();
//{
// style.BackColor = Color.Beige;
// style.ForeColor = Color.Brown;
// style.Font = new Font("Verdana", 8);
//}
//dgvHistoryView.AlternatingRowsDefaultCellStyle = style;
dgvHistoryView.RowHeadersVisible = false;
//dgvHistoryView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvHistoryView.Columns[0].Name = "ID";
dgvHistoryView.Columns[0].Width = 30;
dgvHistoryView.Columns[1].Name = "开奖期号";
dgvHistoryView.Columns[1].Width = 80;
for (int i = 1; i < 17; i++)
{
dgvHistoryView.Columns[i + 1].Name = i.ToString();
dgvHistoryView.Columns[i + 1].Width = 25;
}
dgvHistoryView.Columns[18].Name = "符合规律";
dgvHistoryView.Columns[18].Width = 80;
}
#endregion
private void btn50_Click(object sender, EventArgs e)
{
StatHistoryBlueBall(50);
}
#region//统计历史篮球数据分布图
/// <summary>
/// 统计指定期数的历史篮球数据分布图
/// </summary>
/// <param name="awardDataNum">统计数据期数</param>
private void StatHistoryBlueBall(int awardDataNum)
{
ArrayList tempArray;
string[][] blueBall;
string[] sTemp;
tempArray = new ArrayList();
SetDgvType();
tempArray = this.historyAnalyse.GetBlueData(awardDataNum);
tempArray=BlueBall.GetStatResult(tempArray);
blueBall =new string [tempArray .Count ][];
tempArray.CopyTo(blueBall);
//显示数据
DataGridViewRowCollection rows = this.dgvHistoryView.Rows;
SetDgvType();
for (int i = 0; i < blueBall.Length; i++)
{
sTemp = new string[19];
blueBall[i].CopyTo(sTemp,0);
rows.Add(sTemp);
}
//设置单元格颜色设置
string sValue;
DataGridViewCellStyle MyStyle = new DataGridViewCellStyle();
MyStyle.BackColor = Color.Red;
MyStyle.ForeColor = Color.White;
DataGridViewCellStyle MyStyle1 = new DataGridViewCellStyle();
MyStyle1.BackColor = Color.White;
MyStyle1.ForeColor = Color.Black;
for (int i = 0; i < blueBall.Length; i++)
{
this.dgvHistoryView.Rows[i].Cells[0].Style = MyStyle1;
this.dgvHistoryView.Rows[i].Cells[1].Style = MyStyle1;
for (int j = 2; j < 18; j++)
{
DataGridViewCell cell = this.dgvHistoryView.Rows[i].Cells[j];
sValue =cell.Value.ToString ();
if(sValue .StartsWith ("-"))
{
cell.Value = sValue.Substring(1).ToString();
cell.Style = MyStyle;
}
}
if (dgvHistoryView.Rows[i].Cells[18].Value.ToString() == "1")
{
dgvHistoryView.Rows[i].Cells[18].Style = MyStyle;
}
}
}
/// <summary>
/// 统计全部历史篮球数据分布图
/// </summary>
private void StatHistoryBlueBall()
{
ArrayList tempArray;
string[][] blueBall;
string[] sTemp;
tempArray = new ArrayList();
SetDgvType();
tempArray = this.historyAnalyse.GetBlueData();
tempArray = BlueBall.GetStatResult(tempArray);
blueBall = new string[tempArray.Count][];
tempArray.CopyTo(blueBall);
//显示数据
DataGridViewRowCollection rows = this.dgvHistoryView.Rows;
SetDgvType();
for (int i = 0; i < blueBall.Length; i++)
{
sTemp = new string[19];
blueBall[i].CopyTo(sTemp, 0);
rows.Add(sTemp);
}
//设置单元格颜色设置
string sValue;
DataGridViewCellStyle MyStyle = new DataGridViewCellStyle();
MyStyle.BackColor = Color.Red;
MyStyle.ForeColor = Color.White;
DataGridViewCellStyle MyStyle1 = new DataGridViewCellStyle();
MyStyle1.BackColor = Color.White;
MyStyle1.ForeColor = Color.Black;
for (int i = 0; i < blueBall.Length; i++)
{
this.dgvHistoryView.Rows[i].Cells[0].Style = MyStyle1;
this.dgvHistoryView.Rows[i].Cells[1].Style = MyStyle1;
for (int j = 2; j < 18; j++)
{
DataGridViewCell cell = this.dgvHistoryView.Rows[i].Cells[j];
sValue = cell.Value.ToString();
if (sValue.StartsWith("-"))
{
cell.Value = sValue.Substring(1).ToString();
cell.Style = MyStyle;
}
}
if (dgvHistoryView.Rows[i].Cells[18].Value.ToString() == "1")
{
dgvHistoryView.Rows[i].Cells[18].Style = MyStyle;
}
}
}
#endregion
private void btn100_Click(object sender, EventArgs e)
{
StatHistoryBlueBall(100);
}
private void btnOneYear_Click(object sender, EventArgs e)
{
StatHistoryBlueBall(150);
}
private void btnAll_Click(object sender, EventArgs e)
{
StatHistoryBlueBall();
}
private void btnStat_Click(object sender, EventArgs e)
{
if (mtbDateNum.Text.Trim().Length < 1)
{
MessageBox.Show("请输入有效期数!");
mtbDateNum.Text = "";
mtbDateNum.Focus();
return;
}
StatHistoryBlueBall(int.Parse ( mtbDateNum .Text .Trim ().ToString ()));
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -