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

📄 unit2.pas

📁 材料管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    begin
      FrmWeekRep := TFrmWeekRep.Create(NIL);
      FrmWeekRep.QRLabel5.Caption   := DateToStr(DateTimePicker5.Date);
      FrmWeekRep.QRLabel7.Caption   := DateToStr(DateTimePicker6.Date);
      FrmWeekRep.ADOQuery1.SQL.Text := 'Select * from WeekHaoCai where class='''+clclass+
      ''' and nian='+IntToStr(YearOf(DateTimePicker5.Date))+' and zhou='+
      IntToStr(WeekOfTheYear(DateTimepicker5.Date));
      FrmWeekRep.ADOQuery1.Open;
      if FrmWeekRep.ADOQuery1.Eof then
      begin
        Application.MessageBox('不存在本周明细表','提示',MB_OK);
        Exit;
      end;
      FrmWeekRep.QuickRep1.PreviewModal;
    end
    else
    begin
      Application.MessageBox('两次的时间不在同一周!'+chr(13)+chr(10)+'请选择本周的第一天和最后一天','错误',MB_OK OR MB_ICONERROR);
      Exit;
    end;
  end;
  FreeAndNil(FrmWeekRep);
  FreeAndNil(FrmYMRep);
end;


procedure Tfrmmain.Button22Click(Sender: TObject);
begin
  FrmYMRep := TFrmYMRep.Create(NIL);
  if ComboBox5.Text = '' then
  begin
    Application.MessageBox('请选择查询条件。','提示',MB_OK or MB_ICONINFORMATION);
    Exit;
  end;
  if (Trim(Edit7.Text) = '') and (ComboBox5.Text <> '周') then
  begin
    Application.MessageBox('请输入年份','提示',MB_OK);
    Exit;
  end;
  if ComboBox5.Text = '年' then
  begin
    FrmYMRep.QRLabel10.Caption  := IntToStr(StrToInt(Edit7.Text)-1)+'年'+'12月25日库存';
    FrmYMRep.QRLabel19.Caption  := Edit7.Text+'年'+'12月24日结存';
    FrmYMRep.QRLabel13.Caption  := '本年入库';
    FrmYMRep.QRLabel16.Caption  := '本年出库';
    FrmYMRep.ADOQuery1.SQL.Text :='select * from YearHaoCai where class='''+clclass+
      ''' and nian='+Edit7.Text;
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本年度报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox5.Text = '月' then
  begin
    if Trim(Edit14.Text) = '' then
      Exit;
    if (Edit7.Text = '') or (StrToInt(Edit14.Text) > 12)or (StrToInt(Edit14.Text) = 0) then
    begin
      Application.MessageBox('请输入月份','提示',MB_OK);
      Exit;
    end;
    if StrToInt(Edit14.Text) <= 1 then
      FrmYMRep.QRLabel10.Caption := IntToStr(StrToInt(Edit7.Text)-1)+'年12月25日库存'
    else
      FrmYMRep.QRLabel10.Caption := Edit7.Text+'年'+IntToStr(StrToInt(Edit14.Text)-1)+'月25日库存';
    FrmYMRep.QRLabel19.Caption   := Edit7.Text+'年'+Edit14.Text+'月24日结存';
    FrmYMRep.ADOQuery1.SQL.Text  := 'Select * from MonthHaoCai where class='''+clclass+
      ''' and riqi='''+DateToStr(StrToDate(Edit7.Text+'-'+Edit14.Text+'-24'))+'''';
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本月报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox5.Text = '周' then
  begin
    if WeekOfTheYear(DateTimePicker7.Date) = WeekOfTheYear(DateTimePicker8.Date) then
    begin
      FrmWeekRep := TFrmWeekRep.Create(NIL);
      FrmWeekRep.QRLabel5.Caption := DateToStr(DateTimePicker7.Date);
      FrmWeekRep.QRLabel7.Caption := DateToStr(DateTimePicker8.Date);
      FrmWeekRep.ADOQuery1.SQL.Text := 'Select * from WeekHaoCai where class='''+clclass+
      ''' and nian='+IntToStr(YearOf(DateTimePicker7.Date))+' and zhou='+
      IntToStr(WeekOfTheYear(DateTimepicker7.Date));
      FrmWeekRep.ADOQuery1.Open;
      if FrmWeekRep.ADOQuery1.Eof then
      begin
        Application.MessageBox('不存在本周明细表','提示',MB_OK);
        Exit;
      end;
      FrmWeekRep.QuickRep1.PreviewModal;
    end
    else
    begin
      Application.MessageBox('两次的时间不在同一周!'+chr(13)+chr(10)+'请选择本周的第一天和最后一天','错误',MB_OK OR MB_ICONERROR);
      Exit;
    end;
  end;
  FreeAndNIl(FrmWeekRep);
  FreeAndNil(FrmYMRep);
end;

procedure Tfrmmain.Button26Click(Sender: TObject);
begin
  FrmYMRep := TFrmYMRep.Create(NIL);
  if ComboBox7.Text = '' then
  begin
    Application.MessageBox('请选择查询条件。','提示',MB_OK or MB_ICONINFORMATION);
    Exit;
  end;
  if (Trim(Edit9.Text) = '') and (ComboBox7.Text <> '周') then
  begin
    Application.MessageBox('请输入年份','提示',MB_OK);
    Exit;
  end;
  if ComboBox7.Text = '年' then
  begin
    FrmYMRep.QRLabel10.Caption := IntToStr(StrToInt(Edit9.Text)-1)+'年'+'12月25日库存';
    FrmYMRep.QRLabel19.Caption := Edit9.Text+'年'+'12月24日结存';
    FrmYMRep.QRLabel13.Caption := '本年入库';
    FrmYMRep.QRLabel16.Caption := '本年出库';
    FrmYMRep.ADOQuery1.SQL.Text :='select * from YearHaoCai where class='''+clclass+
      ''' and nian='+Edit9.Text;
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本年度报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox7.Text = '月' then
  begin
    if Trim(Edit15.Text) = '' then
      Exit;
    if (Edit9.Text = '') or (StrToInt(Edit15.Text) > 12)or (StrToInt(Edit15.Text) = 0) then
    begin
      Application.MessageBox('请输入月份','提示',MB_OK);
      Exit;
    end;
    if StrToInt(Edit15.Text) <= 1 then
      FrmYMRep.QRLabel10.Caption := IntToStr(StrToInt(Edit9.Text)-1)+'年12月25日库存'
    else
      FrmYMRep.QRLabel10.Caption := Edit9.Text+'年'+IntToStr(StrToInt(Edit15.Text)-1)+'月25日库存';
    FrmYMRep.QRLabel19.Caption   := Edit9.Text+'年'+Edit15.Text+'月24日结存';
    FrmYMRep.ADOQuery1.SQL.Text  := 'Select * from MonthHaoCai where class='''+clclass+
      ''' and riqi='''+DateToStr(StrToDate(Edit9.Text+'-'+Edit15.Text+'-24'))+'''';
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本月报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox7.Text = '周' then
  begin
    if WeekOfTheYear(DateTimePicker9.Date) = WeekOfTheYear(DateTimePicker10.Date) then
    begin
      FrmWeekRep := TFrmWeekRep.Create(NIL);
      FrmWeekRep.QRLabel5.Caption   := DateToStr(DateTimePicker9.Date);
      FrmWeekRep.QRLabel7.Caption   := DateToStr(DateTimePicker10.Date);
      FrmWeekRep.ADOQuery1.SQL.Text := 'Select * from WeekHaoCai where class='''+clclass+
      ''' and nian='+IntToStr(YearOf(DateTimePicker9.Date))+' and zhou='+
      IntToStr(WeekOfTheYear(DateTimepicker9.Date));
      FrmWeekRep.ADOQuery1.Open;
      if FrmWeekRep.ADOQuery1.Eof then
      begin
        Application.MessageBox('不存在本周明细表','提示',MB_OK);
        Exit;
      end;
      FrmWeekRep.QuickRep1.PreviewModal;
    end
    else
    begin
      Application.MessageBox('两次的时间不在同一周!'+chr(13)+chr(10)+'请选择本周的第一天和最后一天','错误',MB_OK OR MB_ICONERROR);
      Exit;
    end;
  end;
  FreeAndNil(FrmYMRep);
  FreeAndNil(FrmYMRep);
end;

procedure Tfrmmain.Button30Click(Sender: TObject);
begin
  FrmYMRep := TFrmYMRep.Create(NIL);
  if ComboBox8.Text = '' then
  begin
    Application.MessageBox('请选择查询条件。','提示',MB_OK or MB_ICONINFORMATION);
    Exit;
  end;
  if (Trim(Edit10.Text) = '') and (ComboBox8.Text <> '周') then
  begin
    Application.MessageBox('请输入年份','提示',MB_OK);
    Exit;
  end;
  if ComboBox8.Text = '年' then
  begin
    FrmYMRep.QRLabel10.Caption := IntToStr(StrToInt(Edit10.Text)-1)+'年'+'12月25日库存';
    FrmYMRep.QRLabel19.Caption := Edit10.Text+'年'+'12月24日结存';
    FrmYMRep.QRLabel13.Caption := '本年入库';
    FrmYMRep.QRLabel16.Caption := '本年出库';
    FrmYMRep.ADOQuery1.SQL.Text :='select * from YearHaoCai where class='''+clclass+
      ''' and nian='+Edit10.Text;
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本年度报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox8.Text = '月' then
  begin
    if Trim(Edit16.Text) = '' then
      Exit;
    if (Edit10.Text = '') or (StrToInt(Edit16.Text) > 12)or (StrToInt(Edit16.Text) = 0) then
    begin
      Application.MessageBox('请输入月份','提示',MB_OK);
      Exit;
    end;
    if StrToInt(Edit16.Text) <= 1 then
      FrmYMRep.QRLabel10.Caption := IntToStr(StrToInt(Edit10.Text)-1)+'年12月25日库存'
    else
      FrmYMRep.QRLabel10.Caption := Edit10.Text+'年'+IntToStr(StrToInt(Edit16.Text)-1)+'月25日库存';
    FrmYMRep.QRLabel19.Caption := Edit10.Text+'年'+Edit13.Text+'月24日结存';
    FrmYMRep.ADOQuery1.SQL.Text := 'Select * from MonthHaoCai where class='''+clclass+
      ''' and riqi='''+DateToStr(StrToDate(Edit10.Text+'-'+Edit16.Text+'-24'))+'''';
    FrmYMRep.ADOQuery1.Open;
    if FrmYMRep.ADOQuery1.Eof then
    begin
      Application.MessageBox('不存在本月报表','提示',MB_OK);
      Exit;
    end;
    FrmYMRep.QuickRep1.PreviewModal;
  end;
  if ComboBox8.Text = '周' then
  begin
    if WeekOfTheYear(DateTimePicker11.Date) = WeekOfTheYear(DateTimePicker12.Date) then
    begin
      FrmWeekRep := TFrmWeekRep.Create(NIL);
      FrmWeekRep.QRLabel5.Caption := DateToStr(DateTimePicker11.Date);
      FrmWeekRep.QRLabel7.Caption := DateToStr(DateTimePicker12.Date);
      FrmWeekRep.ADOQuery1.SQL.Text := 'Select * from WeekHaoCai where class='''+clclass+
      ''' and nian='+IntToStr(YearOf(DateTimePicker11.Date))+' and zhou='+
      IntToStr(WeekOfTheYear(DateTimepicker11.Date));
      FrmWeekRep.ADOQuery1.Open;
      if FrmWeekRep.ADOQuery1.Eof then
      begin
        Application.MessageBox('不存在本周明细表','提示',MB_OK);
        Exit;
      end;
      FrmWeekRep.QuickRep1.PreviewModal;
    end
    else
    begin
      Application.MessageBox('两次的时间不在同一周!'+chr(13)+chr(10)+'请选择本周的第一天和最后一天','错误',MB_OK OR MB_ICONERROR);
      Exit;
    end;
  end;
  FreeAndNil(FrmWeekRep);
  FreeAndNil(FrmYMRep);
end;

procedure Tfrmmain.ChangInPutClick(Sender: TObject);
var
  nian:Integer;
  zhou:Integer;
  name:String;
  Query1:TADOQuery;
begin
  If NotRight = True then
    exit;
  If dbgrid1.DataSource.DataSet.RecordCount <=0 then
    exit;
  Query1 := TADOQuery.Create(NIL);
  Query1.ConnectionString := ADOConnection1.ConnectionString;
  if clclass='外延片' then
  begin
    name := Querywyp.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '劳保' then
  begin
    name := Querylb.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '稀贵金属' then
  begin
    name := Queryxgjs.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '化学试剂' then
  begin
    name := Queryhxsj.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '低耗' then
  begin
    name := Querydh.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '机电' then
  begin
    name := Queryjd.FieldByName('cailiaoming').AsString;
  end;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('select max(nian) as maxyear from WeekHaoCai where cailiaoming='''+name+
    ''' and class='''+clclass+'''');
  Query1.Prepared;      //最近的年
  Query1.Open;
  nian := Query1.FieldByName('maxyear').AsInteger;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('select max(zhou) as maxweek from WeekHaoCai where nian='+IntToStr(nian)+' and cailiaoming='''+name+
    ''' and class='''+clclass+'''');
  Query1.Prepared;         //最近的周
  Query1.Open;
  zhou := Query1.FieldByName('maxweek').AsInteger;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('select * from WeekHaoCai where nian='+IntToStr(nian)+' and zhou='+IntToStr(zhou)+' and cailiaoming='''+name+
    ''' and class='''+clclass+'''');
  Query1.Prepared;      //材料数据
  Query1.Open;
  if Query1.Eof then
    Exit;
  FrmCInPut := TFrmCInPut.Create(NIL);
  FrmCInPut.Caption := '['+clclass+']'+'周入库修改';
  FrmCInPut.Edit1.Text := Query1.FieldByName('cailiaoming').AsString;
  FrmCInPut.Edit2.Text := Query1.FieldByName('danwei').AsString;
  FrmCInPut.Edit3.Text := Query1.FieldByName('danjia').AsString;
  FrmCInPut.Edit4.Text := Query1.FieldByName('kucunshuliang').AsString;
  FrmCInPut.Edit5.Text := Query1.FieldByName('chukushuliang').AsString;
  FrmCInPut.Edit8.Text := Query1.FieldByName('rukushuliang').AsString;
  //FrmCInput.Edit7.Text := Query1.FieldByName('rukujine').AsString;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('Select * from LastWeeKIn where class='''+clclass+''' and cailiaoming='''+name+'''');
  Query1.Prepared;
  Query1.Open;
  if Not Query1.Eof then
  begin
    FrmCInPut.Edit6.Text := Query1.FieldByName('lastrukushu').AsString;
    FrmCInPut.ShowModal;
  end;
  FreeAndNIl(Query1);
  FreeAndNil(FrmCInPut);
end;

procedure Tfrmmain.ChangOutPutClick(Sender: TObject);
var
  Query1:TADOQuery;
  nian:Integer;
  zhou:Integer;
  name:string;
begin
  If NotRight = True then
    Exit;
  If dbgrid1.DataSource.DataSet.RecordCount <=0 then
    Exit;
  Query1 := TADOQuery.Create(NIL);
  Query1.ConnectionString := ADOConnection1.ConnectionString;
  if clclass='外延片' then
  begin
    name := Querywyp.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '劳保' then
  begin
    name := Querylb.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '稀贵金属' then
  begin
    name := Queryxgjs.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '化学试剂' then
  begin
    name := Queryhxsj.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '低耗' then
  begin
    name := Querydh.FieldByName('cailiaoming').AsString;
  end;
  if clclass = '机电' then
  begin
    name := Queryjd.FieldByName('cailiaoming').AsString;
  end;
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('select max(nian) as maxyear from WeekHaoCai where cailiaoming='''+name+
    ''' and class='''+clclass+'''');
  Query1.Prepared;      //最近的年

⌨️ 快捷键说明

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