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

📄 unit1.pas

📁 此系统完成了单向复费率电能表的抄表以及编程
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB, Buttons, Mask;

type
  TForm1 = class(TForm)
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit3: TEdit;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    ComboBox2: TComboBox;
    ComboBox4: TComboBox;
    ComboBox3: TComboBox;
    ComboBox1: TComboBox;
    ComboBox5: TComboBox;
    Label10: TLabel;
    ComboBox6: TComboBox;
    ADOTable2: TADOTable;
    ADOTable3: TADOTable;
    ComboBox7: TComboBox;
    ComboBox8: TComboBox;
    ADOTable4: TADOTable;
    BitBtn4: TBitBtn;
    ComboBox9: TComboBox;
    ADOTable5: TADOTable;
    ComboBox10: TComboBox;
    ADOTable6: TADOTable;
    MaskEdit1: TMaskEdit;
    BitBtn5: TBitBtn;
    Label11: TLabel;
    Label12: TLabel;
    ADOTable7: TADOTable;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  i:integer;
  m:integer;
begin
     if  combobox7.Text<>''   then
         begin
              if  not  adotable1.Locate('命令编码',combobox7.Text,[]) then
                  begin
                     for  i:= 0  to  15  do
                       begin
                       adotable1.Insert;
                       adotable1.Fields[0].AsString:=copy(combobox7.Text,1,3)+ IntToHex(i,1);
                       adotable1.Fields[1].AsString:=combobox1.Text;
                       adotable1.Fields[2].AsString:=combobox6.Text;
                       adotable1.Fields[3].AsString:=edit3.Text;
                       adotable1.Fields[4].AsString:=combobox3.Text;
                       adotable1.Fields[5].AsString:=combobox5.Text;
                       adotable1.Fields[6].AsString:=edit4.Text;
                       adotable1.Fields[7].AsString:=combobox2.Text;
                       adotable1.Fields[8].AsString:=combobox4.Text;

                       case i  of

                       0:adotable1.Fields[9].AsString:=combobox8.Text;
                       1..14:adotable1.Fields[9].AsString:=maskedit1.Text+ inttostr(i) +  combobox9.Text;
                       15:
                       begin
                       adotable1.Fields[9].AsString:=combobox10.Text;
                       adotable1.Fields[1].AsString:='1';
                        end;
                        end;


                       adotable1.Post;
                       end;
                   end
              else
                  showmessage('该命令编码已存在,请重新输入');

            if not adotable2.Locate('命令编码',combobox7.text,[]) and (combobox7.Text<>'')  then
               begin
                adotable2.Insert;

                adotable2.Fields[1].AsString:=combobox7.Text;
                combobox7.Items.Add(adotable2.Fields[1].AsString);
                next;
                adotable2.Post;
               end;

            if not adotable3.Locate('数据格式',combobox3.text,[]) and (combobox3.Text<>'')  then
               begin
                adotable3.Insert;

                adotable3.Fields[1].AsString:=combobox3.Text;
                combobox3.Items.Add(adotable3.Fields[1].AsString);
                next;
                adotable3.Post;
               end;
            if not adotable4.Locate('数据项名称1',combobox8.text,[]) and (combobox8.Text<>'')  then
               begin
                adotable4.Insert;

                adotable4.Fields[1].AsString:=combobox8.Text;
                combobox8.Items.Add(adotable4.Fields[1].AsString);
                next;
                adotable4.Post;
               end;
            if not adotable5.Locate('数据项名称2',combobox9.text,[]) and (combobox9.Text<>'')  then
               begin
                adotable5.Insert;

                adotable5.Fields[1].AsString:=combobox9.Text;
                combobox9.Items.Add(adotable5.Fields[1].AsString);
                next;
                adotable5.Post;
               end;
            if not adotable6.Locate('数据项名称3',combobox10.text,[]) and (combobox10.Text<>'')  then
               begin
                adotable6.Insert;

                adotable6.Fields[1].AsString:=combobox10.Text;
                combobox10.Items.Add(adotable6.Fields[1].AsString);
                next;
                adotable6.Post;
               end;
            if not adotable7.Locate('单位',combobox4.text,[]) and (combobox4.Text<>'')  then
               begin
                adotable7.Insert;

                adotable7.Fields[1].AsString:=combobox4.Text;
                combobox4.Items.Add(adotable7.Fields[1].AsString);
                next;
                adotable7.Post;
               end;
         end
       else
             showmessage('序号不能为空,请输入');



end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    adotable2.Open;
    adotable3.Open;
    adotable4.Open;
    adotable5.Open;
    adotable6.Open;
    adotable7.Open;
    with  adotable2  do
      begin
        first;

      while not eof do
        begin
          combobox7.Items.Add(fields[1].AsString);
          next;
         end;
      end;
      
     with  adotable3  do
      begin
        first;

      while not eof do
        begin
          combobox3.Items.Add(fields[1].AsString);
          next;
         end;
      end;
      with  adotable4  do
      begin
        first;

      while not eof do
        begin
          combobox8.Items.Add(fields[1].AsString);
          
          next;
         end;
      end;
      with  adotable5  do
      begin
        first;

      while not eof do
        begin

          combobox9.Items.Add(fields[1].AsString);
          next;
         end;
      end;
      with  adotable6  do
      begin
        first;

      while not eof do
        begin

          combobox10.Items.Add(fields[1].AsString);
          next;
         end;
      end;
       with  adotable7  do
      begin
        first;
      while not eof do
        begin

          combobox4.Items.Add(fields[1].AsString);
          next;
         end;
      end;
     
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
    if  combobox7.Text<>''   then
         begin
              if  not  adotable1.Locate('命令编码',combobox7.Text,[]) then


                       begin
                       adotable1.edit;
                       adotable1.Fields[0].AsString:=combobox7.Text;
                       adotable1.Fields[1].AsString:=combobox1.Text;
                       adotable1.Fields[2].AsString:=combobox6.Text;
                       adotable1.Fields[3].AsString:=edit3.Text;
                       adotable1.Fields[4].AsString:=combobox3.Text;
                       adotable1.Fields[5].AsString:=combobox5.Text;
                       adotable1.Fields[6].AsString:=edit4.Text;
                       adotable1.Fields[7].AsString:=combobox2.Text;
                       adotable1.Fields[8].AsString:=combobox4.Text;
                       adotable1.Fields[9].AsString:=combobox8.Text;

                       adotable1.Post;
                      
                   end
              else
                  showmessage('该命令编码已存在,请重新输入');
         end
         else
             showmessage('序列号不能为空');
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
    //adotable1.Edit;
    with  adotable1  do
      begin
        first;

      while not eof do
        begin
          //Delete;
          next;
          delete;
         end;
      end;
end;

procedure TForm1.BitBtn4Click(Sender: TObject);
begin
    adotable1.Locate('命令编码',combobox7.Text,[]);
end;

procedure TForm1.BitBtn5Click(Sender: TObject);
begin
    if  combobox7.Text<>''   then
         begin
              if  not  adotable1.Locate('命令编码',combobox7.Text,[]) then
                  begin


                       adotable1.Insert;
                       adotable1.Fields[0].AsString:=combobox7.Text;
                       adotable1.Fields[1].AsString:=combobox1.Text;
                       adotable1.Fields[2].AsString:=combobox6.Text;
                       adotable1.Fields[3].AsString:=edit3.Text;
                       adotable1.Fields[4].AsString:=combobox3.Text;
                       adotable1.Fields[5].AsString:=combobox5.Text;
                       adotable1.Fields[6].AsString:=edit4.Text;
                       adotable1.Fields[7].AsString:=combobox2.Text;
                       adotable1.Fields[8].AsString:=combobox4.Text;
                       adotable1.Fields[9].AsString:=combobox8.Text;



                       adotable1.Post;

                     end
              else
                  showmessage('该命令编码已存在,请重新输入');

            if not adotable2.Locate('命令编码',combobox7.text,[]) and (combobox7.Text<>'')  then
               begin
                adotable2.Insert;

                adotable2.Fields[1].AsString:=combobox7.Text;
                combobox7.Items.Add(adotable2.Fields[1].AsString);
                next;
                adotable2.Post;
               end;

            if not adotable3.Locate('数据格式',combobox3.text,[]) and (combobox3.Text<>'')  then
               begin
                adotable3.Insert;

                adotable3.Fields[1].AsString:=combobox3.Text;
                combobox3.Items.Add(adotable3.Fields[1].AsString);
                next;
                adotable3.Post;
               end;
            if not adotable4.Locate('数据项名称1',combobox8.text,[]) and (combobox8.Text<>'')  then
               begin
                adotable4.Insert;

                adotable4.Fields[1].AsString:=combobox8.Text;
                combobox8.Items.Add(adotable4.Fields[1].AsString);
                next;
                adotable4.Post;
               end;
            if not adotable7.Locate('单位',combobox4.text,[]) and (combobox4.Text<>'')  then
               begin
                adotable7.Insert;

                adotable7.Fields[1].AsString:=combobox4.Text;
                combobox4.Items.Add(adotable7.Fields[1].AsString);
                next;
                adotable7.Post;
               end;
            
         end
       else
             showmessage('序号不能为空,请输入');

end;

end.



⌨️ 快捷键说明

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