unithuizongrep.pas

来自「绿色衡器称重系统(串口)」· PAS 代码 · 共 972 行 · 第 1/3 页

PAS
972
字号
            begin
             strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
             'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
             'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
             'SiBangYuan as 司磅员 '+
             'From uMaster Where MaoZhong = ' + floattostr(sInt);
            end
              else
               if (Trim(cbType.Text)='皮重') and (sCode=0) then
                begin
                 strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
                 'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
                 'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
                 'SiBangYuan as 司磅员 '+
                 'From uMaster Where PiZhong = ' + floattostr(sInt);
                end
                 else
                   if (Trim(cbType.Text)='净重') and (sCode=0) then
                    begin
                     strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
                      'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
                      'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
                      'SiBangYuan as 司磅员 '+
                      'From uMaster Where JingZhong = ' + floattostr(sInt);
                    end
                      else
                       if Trim(cbType.Text)='发货单位' then
                        begin
                         strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
                         'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
                         'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
                         'SiBangYuan as 司磅员 '+
                         'From uMaster Where FaHuoDW = ' + quotedstr( edtInfo.Text );
                        end
                          else
                           if Trim(cbType.Text)='收货单位' then
                            begin
                             strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
                             'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
                             'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
                             'SiBangYuan as 司磅员 '+
                             'From uMaster Where ShouHuoDW = ' + quotedstr(edtInfo.Text );
                            end;
  end;
end;
if strSQL='' then
begin
 strSQL:='Select ListID as 磅单号,ChePai+ChePaiN as 车牌号,'+
 'ShouHuoDW as 收货单位, FaHuoDW as 发货单位,HuoPin as 货品,MaoZhong as 毛重,'+
 'PiZhong as 皮重,JingZhong as 净重,JingZhongRQ as 日期,'+
 'SiBangYuan as 司磅员 from uMaster';
end;
qCarHistory.Close;
qCarHistory.SQL.Clear;
qCarHistory.SQL.Add(strSQL);
qCarHistory.open;
DBGridEh1.AutoFitColWidths:=False;
DBGridEh1.Columns[0].Width:=78;
DBGridEh1.Columns[1].Width:=90;
DBGridEh1.Columns[2].Width:=115;
DBGridEh1.Columns[3].Width:=115;
DBGridEh1.Columns[4].Width:=50;
DBGridEh1.Columns[5].Width:=50;
DBGridEh1.Columns[6].Width:=50;
DBGridEh1.Columns[7].Width:=100;

PrintDBGridEh1.Title.Clear;
PrintDBGridEh1.Title.Add(' 信 息 查 询 报 表 ');
PrintDBGridEh1.PageHeader.CenterText.Clear;
PrintDBGridEh1.PageHeader.CenterText.Add(ClientUSN);
BitBtn7.Enabled:=True;
Except
//
end;
end;

procedure TfrmHuiZongRep.BitBtn7Click(Sender: TObject);
begin
if MessageBox(handle,'你要直接打印吗?(否则进入预览界面)'+chr(13)+chr(10)+'注意:打印格式随网格中内容的位置变化而变化!',pChar(ClientUSN),MB_OKCANCEL+MB_ICONINFORMATION)=ID_OK then
begin
PrintDBGridEh1.Print;
end
else
begin
PrintDBGridEh1.Preview;
end;
BitBtn7.Enabled:=False;
end;

procedure TfrmHuiZongRep.BitBtn2Click(Sender: TObject);
begin
try
if qCarHistory.Active then
begin
qCarHistory.First;
end;
except
end;
end;

procedure TfrmHuiZongRep.BitBtn3Click(Sender: TObject);
begin
try
if qCarHistory.Active then
begin
qCarHistory.Prior;
end;
except
end;
end;

procedure TfrmHuiZongRep.BitBtn4Click(Sender: TObject);
begin
try
if qCarHistory.Active then
begin
qCarHistory.Next;
end;
except
end;
end;

procedure TfrmHuiZongRep.BitBtn5Click(Sender: TObject);
begin
try
if qCarHistory.Active then
begin
qCarHistory.Last;
end;
except
end;
end;

procedure TfrmHuiZongRep.HuiZongComContrl(bInfo:boolean);
begin
 Combobox2.Enabled:=bInfo;
 Combobox3.Enabled:=bInfo;
 Combobox4.Enabled:=bInfo;
end;

procedure TfrmHuiZongRep.RadioButton1Click(Sender: TObject);
begin
  HuiZongComContrl(false);
end;

procedure TfrmHuiZongRep.RadioButton3Click(Sender: TObject);
begin
  HuiZongComContrl(false);
end;

procedure TfrmHuiZongRep.RadioButton4Click(Sender: TObject);
begin
 HuiZongComContrl(true);
end;

procedure TfrmHuiZongRep.RadioButton2Click(Sender: TObject);
begin
 HuiZongComContrl(false);
 Combobox2.Enabled:=true;
end;

procedure TfrmHuiZongRep.IniDictInfomation;
var
strSQL:String;
begin
 //
 strSQL:='Select * from dDanWei';
 qDict.Close;
 qDict.SQL.Clear;
 qDict.SQL.Add(strSQL);
 Combobox1.Clear;
 qDict.Open;
 if qDict.RecordCount>0 then
  begin
     while not qDict.Eof do
     begin
       Combobox1.Items.Add(qDict.FieldByName('name').AsString);
       qDict.Next;
     end;
  end;
 ComBobox1.Refresh;
  //
 strSQL:='Select * from dHuoPin';
 qDict.Close;
 qDict.SQL.Clear;
 qDict.SQL.Add(strSQL);
 Combobox2.Clear;
  qDict.Open;
 if qDict.RecordCount>0 then
  begin
     while not qDict.Eof do
     begin
       Combobox2.Items.Add(qDict.FieldByName('name').AsString);
       qDict.Next;
     end;
  end;
 ComBobox2.Refresh;
    //
 strSQL:='Select * from dChePaiQ';
 qDict.Close;
 qDict.SQL.Clear;
 qDict.SQL.Add(strSQL);
 Combobox3.Clear;
  qDict.Open;
 if qDict.RecordCount>0 then
  begin
     while not qDict.Eof do
     begin
       Combobox3.Items.Add(qDict.FieldByName('name').AsString);
       qDict.Next;
     end;
  end;
 ComBobox3.Refresh;
     //
 strSQL:='Select * from dChePaiN';
 qDict.Close;
 qDict.SQL.Clear;
 qDict.SQL.Add(strSQL);
 Combobox4.Clear;
  qDict.Open;
 if qDict.RecordCount>0 then
  begin
     while not qDict.Eof do
     begin
       Combobox4.Items.Add(qDict.FieldByName('name').AsString);
       qDict.Next;
     end;
  end;
 ComBobox4.Refresh;
  //
 strSQL:='Select * from dDanWei';
 qDict.Close;
 qDict.SQL.Clear;
 qDict.SQL.Add(strSQL);
 Combobox5.Clear;
 qDict.Open;
 if qDict.RecordCount>0 then
  begin
     while not qDict.Eof do
     begin
       Combobox5.Items.Add(qDict.FieldByName('name').AsString);
       qDict.Next;
     end;
  end;
 ComBobox5.Refresh;
 Combobox5.Enabled:=false;
 Combobox1.Enabled:=false;
 DateTimePicker1.Date:=Date-31;
 DateTimePicker3.Date:=Date;
 DateTimePicker2.Time:=strTotime('00:00:00');
 DateTimePicker4.Time:=strToTime('23:59:59');
end;

procedure TfrmHuiZongRep.BitBtn6Click(Sender: TObject);
var
 strSQL,strCase,strCase2,strCase3,strCase4:String;
 strGroup,strGroup1,strGroup2,strGroup3,strGroup4:String;
 strTitle1,strTitle2,strTitle3,strTitle4:string;
 strTimeI,strTimeX:String;
begin
 try
 FHelper.Speak('统计后的结果在打印时,打印格式由网格决定!','');
 strTimeI:=datetostr(strtodatetime(datetostr(DateTimePicker1.Date) + ' ' +timetostr(DateTimePicker2.Time)));
 strTimeX:=datetostr(strtodatetime(datetostr(DateTimePicker3.Date) + ' ' +timetostr(DateTimePicker4.Time)));
 if (Checkbox2.Checked) and (Trim(Combobox1.Text)='') then
 begin
  MessageBox(handle,'既然您选择了发货单位就不要空着发货单位的信息,请选择!',pChar(ClientUSN),MB_OK+MB_ICONERROR);
  Exit;
 end
   else
   if (Checkbox2.Checked) and (trim(combobox1.Text)<>'') then
   begin
     strCase:=' and FaHuoDW=' + quotedstr(Trim(Combobox1.Text));
     strGroup1:= ' FaHuoDW ';
     strTitle1:= ', FaHuoDW as 发货单位 ';
   end
     else
     begin
       strCase:='';
       StrGroup1:='';
       strTitle1:='';
     end;
  if (Checkbox1.Checked) and (Trim(Combobox5.Text)='') then
 begin
  MessageBox(handle,'既然您选择了收货单位就不要空着收货单位的信息,请选择!',pChar(ClientUSN),MB_OK+MB_ICONERROR);
  Exit;
 end
  else
   if (Checkbox1.Checked) and (trim(combobox5.Text)<>'') then
   begin
     strCase2:=' and ShouHuoDW=' + quotedstr(Trim(Combobox5.Text));
     strGroup2:=' ,ShouHuoDW ';
     strTitle2:=' ,ShouHuoDW as 收货单位 ';
   end
     else
       begin
       strCase2:='';
       strGroup2:='';
       strTitle2:='';
       end;
  if (Trim(Combobox2.Text))<>'' then
  begin
    strCase3:=' and HuoPin=' + quotedstr(Trim(combobox2.Text));
    strGroup3:=' ,HuoPin ';
    strTitle3:=' ,HuoPin as 货品 ';
  end
   else
     begin
     strCase3:='';
     strGroup3:='';
     strTitle3:='';
     end;
  if (trim(comboBox3.Text)<>'') and (trim(combobox4.Text)<>'') then
  begin
    strCase4:=' and ChePai+ChepaiN=' + quotedstr(Trim(combobox3.Text)+trim(combobox4.Text));
    strGroup4:=' ,ChePai+ChePaiN ';
    strTitle4:=' ,ChePai+ChePaiN as 车牌号';
  end
   else
     begin
     strCase4:='';
     strGroup4:='';
     strTitle4:='';
     end;

⌨️ 快捷键说明

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