📄 frmhistoryview.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;
using ZedGraph;
namespace cpzh
{
public partial class frmHistoryView : Form
{
private HistoryData awardData; //中奖数据
private OLEDBAccessObj dbObj;
private HistoryAnalyse historyAnalyse;
private RedBall redBall;
struct StatResult //红球统计结果
{
public string CurRedBallNo; //当前红球号码
public int CurValue; //当前期数
public int Average; //平均期数
public int HitAward; //中奖次数
public int Appear; //当前期数出现次数
public int Appear1; //当前期数正负一期出现次数
public int Commend; //推荐指数,
//300期没有出现过大于当前期数 加**
//200期没有出现过大于当前期数 加*
//大于40 加*
//大于60 加**
//300期内出现超过40 加*
//200期内正负两期范围出现超过3次 加*
//200期内正负3期范围出现超过3次 加*
}
private StatResult statResult; //红球统计结果
public frmHistoryView()
{
awardData = new HistoryData();
this.dbObj = new OLEDBAccessObj();
this.dbObj.ConnectDB();
this.historyAnalyse = new HistoryAnalyse(this.dbObj);
this.redBall = new RedBall(); ;
InitializeComponent();
}
private void frmHistoryView_Load(object sender, EventArgs e)
{
InitCBRedNo();
ShowChartPanl("");
//SetDgwType();
}
#region//设置dgw样式
/// <summary>
/// 设置dgw样式
/// </summary>
/// <param name="btnName">调用此过程的按钮名字</param>
private void SetDgwType(string btnName)
{
//设置列标题的样式
DataGridViewCellStyle chdcstyle = dgwHistoryView.ColumnHeadersDefaultCellStyle;
chdcstyle.BackColor = Color.LightGray ;
chdcstyle.ForeColor = Color.White;
chdcstyle.Font = new Font(dgwHistoryView.Font, FontStyle.Bold);
dgwHistoryView.ColumnHeadersHeight = 30;
//设置单元格的样式
DataGridViewCellStyle style = new DataGridViewCellStyle();
{
style.BackColor = Color.Beige;
style.ForeColor = Color.Brown;
style.Font = new Font("Verdana", 8);
}
dgwHistoryView.AlternatingRowsDefaultCellStyle = style;
dgwHistoryView.RowHeadersVisible = false;
switch (btnName )
{
case "btnStatAll":
dgwHistoryView.DataSource = null;
dgwHistoryView.Rows.Clear();
dgwHistoryView.ColumnCount = 7;
for (int i = 0; i < 7; i++)
{
dgwHistoryView.Columns[i].Width = 80;
}
dgwHistoryView.Columns[0].Width = 50;
dgwHistoryView.Columns[3].Width = 85;
dgwHistoryView.Columns[0].Name = "红球号";
dgwHistoryView.Columns[1].Name = "当前期数";
dgwHistoryView.Columns[2].Name = "相同期数";
dgwHistoryView.Columns[3].Name = "+-一期数";
dgwHistoryView.Columns[4].Name = "出现次数";
dgwHistoryView.Columns[5].Name = "平均期数";
dgwHistoryView.Columns[6].Name = "推荐指数";
dgwHistoryView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
break;
case "btnQuery":
//设置列标题的样式
DataGridViewCellStyle chdcstyle1 = dgvQuery.ColumnHeadersDefaultCellStyle;
chdcstyle1.BackColor = Color.LightGray;
chdcstyle1.ForeColor = Color.White;
chdcstyle1.Font = new Font(dgvQuery.Font, FontStyle.Bold);
dgvQuery.ColumnHeadersHeight = 30;
//设置单元格的样式
DataGridViewCellStyle style1 = new DataGridViewCellStyle();
{
style1.BackColor = Color.Beige;
style1.ForeColor = Color.Brown;
style1.Font = new Font("Verdana", 8);
}
dgvQuery.AlternatingRowsDefaultCellStyle = style1;
dgvQuery.RowHeadersVisible = false;
dgvQuery.Columns[0].Width = 40;
dgvQuery.Columns[1].Width = 20;
dgvQuery.Columns[2].Width = 70;
dgvQuery.Columns[3].Width = 140;
dgvQuery.Columns[4].Width = 30;
dgvQuery.Columns[5].Width = 20;
dgvQuery.Columns[6].Width = 20;
dgvQuery.Columns[7].Width = 20;
dgvQuery.Columns[8].Width = 20;
dgvQuery.Columns[9].Width = 20;
dgvQuery.Columns[10].Width = 20;
dgvQuery.Columns[11].Width = 20;
dgvQuery.Columns[12].Width = 20;
dgvQuery.Columns[13].Width = 20;
dgvQuery.Columns[14].Width = 20;
dgvQuery.Columns[15].Width = 25;
dgvQuery.Columns[16].Width = 30;
dgvQuery.ColumnHeadersHeight = 70;
dgvQuery.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
break;
case "btnStat":
dgwHistoryView.DataSource = null;
dgwHistoryView.Rows.Clear();
dgwHistoryView.ColumnCount = 34;
dgwHistoryView.Columns[0].Name = "开奖期号";
dgwHistoryView.Columns[0].Width = 85;
for (int i = 1; i < 34; i++)
{
dgwHistoryView.Columns[i].Name = i.ToString();
dgwHistoryView.Columns[i].Width = 25;
}
dgwHistoryView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
break;
case "btnStatMap":
dgwHistoryView.DataSource = null;
dgwHistoryView.Rows.Clear();
dgwHistoryView.ColumnCount = 51;
dgwHistoryView.RowHeadersVisible = false;
dgwHistoryView.Columns[0].Name = "ID";
dgwHistoryView.Columns[0].Width = 30;
dgwHistoryView.Columns[1].Name = "开奖期号";
dgwHistoryView.Columns[1].Width = 80;
for (int i = 2; i < 35; i++)
{
dgwHistoryView.Columns[i].Name = Convert.ToString((i - 1));
dgwHistoryView.Columns[i].Width = 25;
}
for (int i = 35; i < 45; i++)
{
dgwHistoryView.Columns[i].Name = Convert.ToString((i - 34));
dgwHistoryView.Columns[i].Width = 25;
}
for (int i = 45; i < 51; i++)
{
dgwHistoryView.Columns[i].Name = Convert.ToString((i - 44));
dgwHistoryView.Columns[i].Width = 25;
}
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.Silver;
this.dgwHistoryView.RowsDefaultCellStyle = dataGridViewCellStyle1;
dgwHistoryView.SelectionMode = DataGridViewSelectionMode.CellSelect ;
break;
}
}
#endregion
private void btnQuery_Click(object sender, EventArgs e)
{
int AnnalNum;
ShowChartPanl("btnQuery");
//验证输入数据是否有
if (mtbAnnalNum.Text.Trim().ToString().Length < 1 || mtbAnnalNum.Text.Trim().ToString()=="0")
{
MessageBox.Show("请输入有效记录数,如:50");
mtbAnnalNum.Text = "50";
return;
}
AnnalNum = int.Parse(mtbAnnalNum.Text.Trim().ToString());
if (dgvQuery.DataSource != null)
{
dgvQuery.DataSource = null;
}
dgvQuery.Rows.Clear();
dgvQuery.DataSource = historyAnalyse.GetLatelyData(AnnalNum).Tables["TwinColorBall"];
SetDgwType("btnQuery");
}
private void btnStat_Click(object sender, EventArgs e)
{
int AnnalNum,tempNum;
ArrayList arrayList;
ArrayList resultList;
int[][] resultArray;
string[] sTemp;
arrayList = new ArrayList();
resultList = new ArrayList();
ShowChartPanl("btnStat");
//验证输入数据是否有
if (mtbStatDate.Text.Trim().ToString().Length < 1 || mtbStatDate.Text.Trim().ToString() == "0")
{
MessageBox.Show("请输入有效记录数,如:50");
mtbStatDate.Text = "50";
return;
}
//获得统计数+33期的中奖结果
AnnalNum = int.Parse(mtbStatDate.Text.Trim().ToString()) + 33;
arrayList=historyAnalyse.GetFrequency(AnnalNum);
resultArray = new int[arrayList.Count][];
arrayList.CopyTo(resultArray);
DataGridViewRowCollection rows = this.dgwHistoryView.Rows;
SetDgwType("btnStat");
//计算近33期某数出现频率向最终显示控件输出数据
for (int i = 0; i < resultArray.Length-33; i++)
{
//外层行循环33
sTemp = new string[34];
sTemp[0] = resultArray[i][0].ToString();
for (int j =1; j <34; j++)
{
tempNum = 0;
//内层列循环
for (int g = i+1; g < i+ 34; g++)
{
//6位中奖号循环
for (int k = 1; k < 7; k++)
{
if (int.Parse(resultArray[g][k].ToString()) == j)
{
tempNum += 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -