⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 对已往的3D彩票号码进行统计
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "stdlib.h"
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
AnsiString SqlText[15];
int listIndex=-1;
int num[7];
int k,l,m,o; 
TForm1 *Form1;
void Qsort(int nstart,int nstop);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  ADOConnection1->Connected = true;
  ADOQuery1->SQL->Text ="select *  from List order by uid desc";
  ADOQuery1->Active = true;
  Label1->Caption = IntToStr(ADOQuery1->RecordCount);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

AnsiString t;
int chk,num[3];
int i;
  Form2->Series1->DataSource= NULL;
  Form3->Series1->DataSource= NULL;
  Form3->Series2->DataSource= NULL;
  Form3->Series3->DataSource= NULL;
  if( listIndex<9 || listIndex>12)
    ADOQuery1->SQL->Text = Memo1->Text;
  else
    ADOQuery1->SQL->Text = SqlText[listIndex];
  if( listIndex==9)
  {
    ADOQuery1->Parameters->ParamByName("1")->Value = StrToInt(ComboBox1->Text);
    ADOQuery1->Parameters->ParamByName("2")->Value = StrToInt(ComboBox1->Text);
    ADOQuery1->Parameters->ParamByName("3")->Value = StrToInt(ComboBox1->Text);
  }
  else if( listIndex==10)
  {
    ADOQuery1->Parameters->ParamByName("1")->Value = StrToInt(ComboBox1->Text);
    ADOQuery1->Parameters->ParamByName("2")->Value = StrToInt(ComboBox2->Text);
    ADOQuery1->Parameters->ParamByName("3")->Value = StrToInt(ComboBox3->Text);
  }
  else if( listIndex==11)
  {
    t = ADOQuery1->SQL->Text ;
    chk=0;
    for(i=0;i<3;i++)
      num[i]=0;
    //确定数值个数及其数值
    if(CheckBox2->Checked)
    {
     chk++;
     num[chk-1]=StrToInt(ComboBox1->Text);
    }
    if(CheckBox3->Checked)
    {
     chk++;
     num[chk-1]=StrToInt(ComboBox2->Text);
    }
    if(CheckBox4->Checked)
    {
     chk++;
     num[chk-1]=StrToInt(ComboBox3->Text);
    }
    if(chk==0)
    {
       t =" select uid,d1,d2,d3 from list";
    }
    if(chk ==1)
    {
      t =" select uid,d1,d2,d3 from list where d1= :1 or d2=:2 or d3 =:3";
    }
    else if(chk ==2)
    {
      t =" select uid,d1,d2,d3 from list where (d1*10+d2 = :1 or d1*10+d2 =:2) or (d1*10+d3 = :3 or d1*10+d3 =:4) or (d2*10+d3 = :5 or d2*10+d3 =:6)";
    }
    else if(chk ==3)
    {
      t ="select a.uid,a.d1,a.d2,a.d3  from list a,";
       t+="(select  "+IntToStr(num[0]) +" as d1,"+IntToStr(num[1])+" as d2,"+IntToStr(num[2]) +" as d3 from list union ";
       t+="select  "+IntToStr(num[0]) +" as d1,"+IntToStr(num[2])+" as d2,"+IntToStr(num[1]) +" as d3 from list union ";
       t+="select  "+IntToStr(num[1]) +" as d1,"+IntToStr(num[0])+" as d2,"+IntToStr(num[2]) +" as d3 from list union ";
       t+="select  "+IntToStr(num[1]) +" as d1,"+IntToStr(num[2])+" as d2,"+IntToStr(num[0]) +" as d3 from list union ";
       t+="select  "+IntToStr(num[2]) +" as d1,"+IntToStr(num[0])+" as d2,"+IntToStr(num[1]) +" as d3 from list union ";
       t+="select  "+IntToStr(num[2]) +" as d1,"+IntToStr(num[1])+" as d2,"+IntToStr(num[0]) +" as d3 from list ";
       t+=") b where a.d1= b.d1 and a.d2=b.d2 and a.d3= b.d3 ";
    }
    Memo1->Text = t;
    ADOQuery1->SQL->Text =t;
    if(chk==1)
    {
      ADOQuery1->Parameters->ParamByName("1")->Value = num[0];
      ADOQuery1->Parameters->ParamByName("2")->Value = num[0];
      ADOQuery1->Parameters->ParamByName("3")->Value = num[0];
    }
    else if(chk==2)
    {
      ADOQuery1->Parameters->ParamByName("1")->Value = num[0]*10+num[1];
      ADOQuery1->Parameters->ParamByName("2")->Value = num[1]*10+num[0];
      ADOQuery1->Parameters->ParamByName("3")->Value = num[0]*10+num[1];
      ADOQuery1->Parameters->ParamByName("4")->Value = num[1]*10+num[0];
      ADOQuery1->Parameters->ParamByName("5")->Value = num[1]*10+num[0];
      ADOQuery1->Parameters->ParamByName("6")->Value = num[0]*10+num[1];
    }
  }
  else if( listIndex==12)
  {
    t = ADOQuery1->SQL->Text ;
    if(CheckBox2->Checked)
      t +=" and d1=:1";
    if(CheckBox3->Checked)
      t +=" and d2=:2";
    if(CheckBox4->Checked)
      t +=" and d3=:3";
    t +="\r\n";
    Memo1->Text = t;
    ADOQuery1->SQL->Text =t;
    if(CheckBox2->Checked)
      ADOQuery1->Parameters->ParamByName("1")->Value = StrToInt(ComboBox1->Text);
    if(CheckBox3->Checked)
      ADOQuery1->Parameters->ParamByName("2")->Value = StrToInt(ComboBox2->Text);
    if(CheckBox4->Checked)
      ADOQuery1->Parameters->ParamByName("3")->Value = StrToInt(ComboBox3->Text);
  }

  ADOQuery1->Active = true;
  Label1->Caption = IntToStr(ADOQuery1->RecordCount);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
   Memo1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
  Memo1->Text="select * from list order by uid desc";
  listIndex = -1;
}
//---------------------------------------------------------------------------
/* int i;
  for(i=0;i<305;i++)
  {
    ADOCommand1->CommandText="update list set uid = :1 where id= :2";
    ADOCommand1->Parameters->ParamByName("1")->Value="2005D"+IntToStr(305-i);
    ADOCommand1->Parameters->ParamByName("2")->Value=306+i;
    ADOCommand1->Execute();
   ADOQuery1->SQL->Text ="select * from list";
   ADOQuery1->Active = true;

   }    */
void __fastcall TForm1::Button4Click(TObject *Sender)
{
//---------------------------------------------------------------------------
/* int i;
  for(i=0;i<305;i++)
  {
    ADOCommand1->CommandText="update list set s2 = :1 where Uid= :2";
    ADOCommand1->Parameters->ParamByName("2")->Value="2005D"+IntToStr(305-i);
    ADOCommand1->Parameters->ParamByName("1")->Value=305-i;
    ADOCommand1->Execute();
   }
   ADOQuery1->SQL->Text ="select * from list";
   ADOQuery1->Active = true;*/
   ADOCommand1->CommandText=Memo1->Text;
   ADOCommand1->Execute();
   ADOQuery1->SQL->Text ="select * from list order by uid desc";
   ADOQuery1->Active = true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
      const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)
{
 /* with Sender As TDBGrid do
  begin
    if DataSource.DataSet.FieldByName('FLAG').Value = 0 then
       Canvas.Font.Color:=clRed
    else
       Canvas.Font.Color:=clGreen;
     DefaultDrawColumnCell(Rect, DataCol, Column, State);
  end;  */
  if(CheckBox1->Checked )
  {
    if (DBGrid1->DataSource->DataSet->RecNo%2==0)
      DBGrid1->Canvas->Brush->Color = clSilver;
    else
      DBGrid1->Canvas->Brush->Color = clWhite;
    DBGrid1->DefaultDrawColumnCell(Rect, DataCol, Column, State);
  }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
  DBGrid1->Refresh();     
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
  if(ListBox1->ItemIndex == 0)   //细明
  {
    Memo1->Text = "select * from list order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 1)      //所有顺子
  {
    Memo1->Text = "select * from List where (d1-d2=-1 and d2-d3=-1) or (d1-d2=1 and d2-d3=1) order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 2)     //所有组3
  {
    Memo1->Text = "select * from list where s1=0 order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 3)    //所有组6
  {
    Memo1->Text = "select * from list where s1=1 order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 4)    //和值
  {
    Memo1->Text = "select uid,d1+d2+d3 as AllNum,d1,d2,d3,s2 from list order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 5)    //和值统计
  {
    Memo1->Text = "select (d1+d2+d3) as Totalnum,count(*) as NumCount from list group by (d1+d2+d3) ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 6)   //各位统计
  {
    Memo1->Text = "select a.*,d.M2,d.M3 ,M1+M2+M3 as 总次数 from  (select d1,count(*) as M1 from list  group by d1) a left join( select b.*,c.M3 from  (select d2,count(*) as M2 from list  group by d2) b  left join( select d3,count(*) as M3 from list   group by d3 ) c on b.d2=c.d3) d on d.d2=a.d1 ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 7)    //组三详细
  {
    Memo1->Text = "select uid,d1,d2,d3,iif(d1=d2 ,d1,iif(d1=d3,d1,d2)) as 组数,iif(d1=d2 ,d3,iif(d1=d3,d2,d1))  as 和数 from list where s1=0";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 8)    //组三组数统计
  {
    Memo1->Text ="select iif(d1=d2 ,d1,iif(d1=d3,d1,d2)) as 组数,count(*) as 数量  from list where s1=0 group by iif(d1=d2 ,d1,iif(d1=d3,d1,d2))";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 9)    //查询D出现情况
  {
    Memo1->Text = "select uid,d1,d2,d3 from list where d1=:1 or d2=:2 or d3=:3 order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 10)    //精确查询
  {
    Memo1->Text = "select uid,d1,d2,d3 from list where d1=:1 and d2=:2 and d3=:3 order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 11)    //模糊查询
  {
    Memo1->Text = "select uid,d1,d2,d3 from list where 1=1 ";
    Memo2->Text ="模糊查询可以确定0-3个数查询其分布情况,当查询3个数时相当于组6";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 12)    //定位查询
  {
    Memo1->Text = "select uid,d1,d2,d3 from list where 1=1 ";
    Memo2->Text  = "定位查询:确定某位(1-2)的数值查询存在情况,注:组3无效";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 13)    //全奇查询
  {
    Memo1->Text = "select * from list where d1 Mod 2 =1  and d2 Mod 2 = 1 and d3 Mod 2 =1 order by uid desc ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 14)    //全偶查询
  {
    Memo1->Text = "select * from list where d1 Mod 2 =0  and d2 Mod 2 = 0 and d3 Mod 2 =0 order by uid desc ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 15)    //全奇组3查询
  {
    Memo1->Text = "select * from list where (d1 Mod 2 =1  and d2 Mod 2 = 1 and d3 Mod 2 =1 ) and s1 =0 order by uid desc ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 16)    //全偶组3查询
  {
    Memo1->Text = "select * from list where (d1 Mod 2 =0  and d2 Mod 2 = 0 and d3 Mod 2 =0) and s1=0 order by uid desc ";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 17)   //路数查询
  {
    Memo1->Text = "  select uid,d1,d2,d3,s1,format(road,'000') as road from list order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 18)   //路数明细
  {
    Memo1->Text ="select uid,s2,d1 mod 3 as road1,d2 mod 3 as road2 ,d3 mod 3 as road3 from list order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
  else if(ListBox1->ItemIndex == 19)   //详细数据
  {
    Memo1->Text = "select uid,d1,d2,d3,borl,format(road,'000') from List order by uid desc";
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }
    else if(ListBox1->ItemIndex == 20)   //组数查询
  {
    Memo1->Text ="";
    Memo1->Lines->Add("select uid,a.onum,tnum from list a,(");
    Memo1->Lines->Add("select onum,count(*) as tnum from list group by onum)b where a.onum=b.onum ");
    Memo1->Lines->Add("order by uid desc");
    SqlText[ListBox1->ItemIndex ]= Memo1->Text;
  }

  listIndex = ListBox1->ItemIndex;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -