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

📄 unit1.pas

📁 软件简介:1.数据库技术 2.stringgrid的大量操作应用 加入edit、combox计算等 3.报表 4.注册表的应用
💻 PAS
📖 第 1 页 / 共 2 页
字号:

procedure TForm1.ToolButton1Click(Sender: TObject);
var
    s, SQLTXT: string;
    xh_rows, I, i1, f1, I2, I3, I4, I5, I6: Integer;
begin
    if ComboBoxIsEmpty(ecj, '车间没有输入!') = false then exit;
    if ComboBoxIsEmpty(egyy, '工艺员没有输入!') = false then exit;
    if EditIsEmpty(Eljh, '零件号不能为空!') = false then exit;
    if EditIsEmpty(Ebh, '编号不能为空!') = false then exit;
    if EditIsEmpty(Erq, '日期没有输入!') = false then exit;
    s := Eljh.text;
    OPENAdoQ(DM.ADOQ1, 'select ljh from ljxx where ljh=''' + Eljh.text + '''');
    if DM.ADOQ1.RecordCount >= 1 then
    begin
        if Application.MessageBox(PChar(Eljh.text +
            ' 已经存在,修改覆盖原有的吗?'), '提示', mb_okcancel) = idok then
        begin
            ExecAdoQuery(DM.ADOQ2, 'delete * from ljxx where ljh=''' + s +
                '''');

            ExecAdoQuery(DM.ADOQ2,
                'insert into ljxx(ljh,bh,cj,cx,gyy,rq) values(''' + Eljh.text +
                    ''''
                + ',' + '''' + Ebh.text + '''' + ',' + '''' + ecj.text + ''''
                + ',' + '''' + Ecx.text + '''' + ',' + '''' + egyy.text + '''' +
                ',' + '''' + Erq.text + '''' + ')');

            ExecAdoQuery(DM.ADOQ2, 'delete * from mx where ljh=''' + s + '''');

            for I := 1 to 25 do
            begin
                if StringGrid1.Cells[0, I] = '' then
                begin
                    xh_rows := I - 1;
                    BREAK;
                end;
            end;
            for I2 := 1 to xh_rows do
            begin
                if StringGrid1.Cells[1, I2] = '' then
                begin

                    BREAK;
                end;
            end;
            for I3 := 1 to xh_rows do
            begin
                if StringGrid1.Cells[2, I3] = '' then
                begin

                    BREAK;
                end;
            end;
                for I4 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[9, I4] = '' then
                    begin

                        BREAK;
                    end;
                end;
                for I5 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[10, I5] = '' then
                    begin

                        BREAK;
                    end;
                end;
                for I6 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[11, I6] = '' then BREAK ;
               end;

               xh_rows:=MIN(I,I2);
               xh_rows:=MIN(xh_rows,I3);
               xh_rows:=MIN(xh_rows,I4);
               xh_rows:=MIN(xh_rows,I5);
               xh_rows:=MIN(xh_rows,I6);
               xh_rows:= xh_rows-1;
              // showmessage(inttostr(xh_rows));
                for i1 := 1 to xh_rows do
                begin

                    SQLTXT := 'Insert into mx(ljh,gxh,gxmc,sbxh,sbmc,mcjs,zysj,jbsj,fzsj,fjsj,czrs,bcde,djgf,mcgf,djgzf,bzyc) values('''
                        +
                        s + '''' + ',' + '''' + StringGrid1.Cells[0, i1] + '''' +
                            ','
                        +
                        '''' + StringGrid1.Cells[1, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[2, i1] + '''' + ',' +
                        '''' + StringGrid1.Cells[3, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[4, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[5, i1] + '''' + ',' +
                        '''' + StringGrid1.Cells[6, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[7, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[8, i1] + ''''
                        + ',' + '''' + StringGrid1.Cells[9, i1] + '''' + ',' +
                            ''''
                        + StringGrid1.Cells[10, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[11, i1] +
                        '''' + ',' + '''' + StringGrid1.Cells[12, i1] + '''' +
                            ',' +
                        '''' + StringGrid1.Cells[13, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[14, i1] + '''' + ')';

                    // SHOWMESSAGE(SQLTXT);
                    ExecAdoQuery(DM.ADOQ2, SQLTXT);
                end;
            end;
        end;

        if DM.ADOQ1.RecordCount = 0 then
        begin
            if Application.MessageBox(PChar(Eljh.text +
                ' 是新的零件号您将新增加它吗?'), '提示', mb_okcancel) = idok
                    then
            begin
                // ExecAdoQuery(DM.ADOQ2, 'delete * from ljxx where ljh=''' + s +'''');

                ExecAdoQuery(DM.ADOQ2,
                    'insert into ljxx(ljh,bh,cj,cx,gyy,rq) values(''' + Eljh.text
                        + ''''
                    + ',' + '''' + Ebh.text + '''' + ',' + '''' + ecj.text + ''''
                    + ',' + '''' + Ecx.text + '''' + ',' + '''' + egyy.text +
                        '''' +
                    ',' + '''' + Erq.text + '''' + ')');

                //ExecAdoQuery(DM.ADOQ2, 'delete * from mx where ljh=''' + s + '''');
                for I := 1 to 25 do
                begin
                    if StringGrid1.Cells[0, I] = '' then
                    begin
                        xh_rows := I - 1;
                        BREAK;
                    end;
                end;
                  for I2 := 1 to xh_rows do
            begin
                if StringGrid1.Cells[1, I2] = '' then
                begin

                    BREAK;
                end;
            end;
            for I3 := 1 to xh_rows do
            begin
                if StringGrid1.Cells[2, I3] = '' then
                begin

                    BREAK;
                end;
            end;
                for I4 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[9, I4] = '' then
                    begin

                        BREAK;
                    end;
                end;
                for I5 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[10, I5] = '' then
                    begin

                        BREAK;
                    end;
                end;
                for I6 := 1 to xh_rows do
                begin
                    if StringGrid1.Cells[11, I6] = '' then BREAK ;
               end;

               xh_rows:=MIN(I,I2);
               xh_rows:=MIN(xh_rows,I3);
               xh_rows:=MIN(xh_rows,I4);
               xh_rows:=MIN(xh_rows,I5);
               xh_rows:=MIN(xh_rows,I6);
               xh_rows:= xh_rows-1;
                for i1 := 1 to xh_rows do
                begin

                    SQLTXT := 'Insert into mx(ljh,gxh,gxmc,sbxh,sbmc,mcjs,zysj,jbsj,fzsj,fjsj,czrs,bcde,djgf,mcgf,djgzf,bzyc) values('''
                        +
                        s + '''' + ',' + '''' + StringGrid1.Cells[0, i1] + '''' +
                            ','
                        +
                        '''' + StringGrid1.Cells[1, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[2, i1] + '''' + ',' +
                        '''' + StringGrid1.Cells[3, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[4, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[5, i1] + '''' + ',' +
                        '''' + StringGrid1.Cells[6, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[7, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[8, i1] + ''''
                        + ',' + '''' + StringGrid1.Cells[9, i1] + '''' + ',' +
                            ''''
                        + StringGrid1.Cells[10, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[11, i1] +
                        '''' + ',' + '''' + StringGrid1.Cells[12, i1] + '''' +
                            ',' +
                        '''' + StringGrid1.Cells[13, i1] + '''' + ',' + '''' +
                        StringGrid1.Cells[14, i1] + '''' + ')';

                    // SHOWMESSAGE(SQLTXT);
                    ExecAdoQuery(DM.ADOQ2, SQLTXT);
                end;
            end;
        end;
    end;

procedure TForm1.TB_kctjClick(Sender: TObject);
var
    s: string;
    i1, f1: Integer;
begin
    s := Eljh.text;
    if EditIsEmpty(Eljh, '无零件!') = false then exit;
    if Application.MessageBox(PChar('确认要删除 "' + s +
        '" 吗?'), '提示', mb_okcancel) = idok then

    begin
        ExecAdoQuery(DM.ADOQ1, 'delete * from ljxx where ljh=''' + s + '''');
        ExecAdoQuery(DM.ADOQ1, 'delete * from mx where ljh=''' + s + '''');
        Eljh.text := '';
        Ebh.text := '';
        Erq.text := '';
        Ecx.text := '';
        ecj.text := '';
        egyy.text := '';
        //stringgrid1.cl
        for i1 := 1 to 25 do
        begin
            for f1 := 0 to 14 do
            begin
                StringGrid1.Cells[f1, i1] := '';
            end;
        end;
    end;

end;

procedure TForm1.ToolButton4Click(Sender: TObject);
begin
    CLOSE;
end;

procedure TForm1.ErqDblClick(Sender: TObject);
begin
    DateSeparator := '-';
    ShortTimeFormat := 'yyyy-mm-dd';
    longtimeformat := 'yyyy-mm-dd';

    Erq.text := datetostr(date);

end;

procedure TForm1.TB_spfbClick(Sender: TObject);
var
    SQLTXT: string;
    n, I: Integer;
begin
    if trim(Eljh.text) = '' then
    begin
        showmessage('无数据');
        exit;
    end;
    ExecAdoQuery(DM.ADOQu3, 'delete * from temp');
    OPENAdoQ(DM.ADOQu2, 'select * from ljxx where ljh=''' + Eljh.text + '''');

    OPENAdoQ(DM.ADOQu3, 'select * from mx where ljh=''' + Eljh.text + '''');
    n := DM.ADOQu3.RecordCount;
    ExecAdoQuery(DM.ADOQu3, 'insert into temp select * from mx where ljh=''' +
        Eljh.text + '''');

    if n < 15 then
    begin
        for I := n + 1 to 14 do
        begin

            SQLTXT := 'Insert into temp(ljh) values(''' + Eljh.text + '''' +
                ')';

            //  showmessage(sqltxt);
            ExecAdoQuery(DM.ADOQu3, SQLTXT);
        end;
    end;
    if (n > 15) and (n < 30) then
    begin
        for I := n + 1 to 30 do
        begin

            SQLTXT := 'Insert into temp(ljh) values(''' + Eljh.text + '''' +
                ')';

            //  showmessage(sqltxt);
            ExecAdoQuery(DM.ADOQu3, SQLTXT);
        end;
    end;

    OPENAdoQ(DM.ADOQu3, 'select * from temp where ljh=''' + Eljh.text + '''' +
        ' order by id');

    with DM.ADOQu2 do
    begin
        Fprint.QRLabel23.Caption := FieldByName('ljh').AsString;
        Fprint.QRLabel24.Caption := FieldByName('bh').AsString;
        Fprint.QRLabel20.Caption := FieldByName('rq').AsString;
        Fprint.QRLabel22.Caption := FieldByName('cj').AsString;
        Fprint.QRLabel25.Caption := FieldByName('cx').AsString;
        Fprint.QRLabel46.Caption := FieldByName('gyy').AsString;
    end;

    Fprint.QR_YBB.PreviewModal;

end;

procedure TForm1.N2Click(Sender: TObject);
var
    k: Integer;
begin
    if StringGrid1.row > 0 then
    begin
        with StringGrid1 do
        begin
            for k := row to RowCount - 1 do
                Rows[k] := Rows[k + 1];
            RowCount := RowCount - 1;
        end;
    end;

end;

procedure TForm1.N1Click(Sender: TObject);

begin
    StringGrid1.RowCount := StringGrid1.RowCount + 1;
    TMyGrid(StringGrid1).MoveRow(StringGrid1.RowCount - 1,
        StringGrid1.Selection.Top);

end;

procedure TForm1.ToolButton3Click(Sender: TObject);
begin
    FSZ.ShowModal;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
    R: TRegistry;
    R1: string;
    pWindowsList: pointer;
    hActiveWindow: HWnd;
    hExeHandle: THandle;
begin
    R := TRegistry.Create;
    R.RootKey := HKEY_LOCAL_MACHINE;
    R.OpenKey('Software\microsoft', true);
    R1 := R.ReadString('APP');
    if R1 = '' then
    begin
        showmessage('没有找到路径,重新设置“编号本”的路径');
        exit;
    end;
    shellexecute(Handle, 'open', PChar(R1), '', '', sw_shownormal);

end;

end.

⌨️ 快捷键说明

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