unithuizongrep.pas

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

PAS
972
字号
 if Radiobutton1.Checked then
 begin
  strSQL:='Select Sum(MaoZhong) as 毛重(kg),Sum(PiZhong) as 皮重(kg),Sum(JingZhong) as 净重(kg), JingZhongRQ as 日期 from uMaster '+
          'Where (JingZhongSJ Between CDate(' + quotedstr(TimeTostr(DateTimePicker2.Time)) + ') and  CDate(' +
          quotedstr(TimeTostr(DateTimePicker4.Time)) + ')) and (JingZhongRQ Between CDate(' +
          quotedstr(DateTostr(DateTimePicker1.Date)) + ') and CDate(' +
          quotedstr(DateTostr(DateTimePicker3.Date)) + '))'  + strCase + strCase2 + strCase3 + strCase4 +' Group by JingZhongRQ';
  if Not adoConn.Connected then
  begin
  adoConn.Open;
  end;
  qCarHistory.Connection:=adoConn;
  qCarHistory.Close;
  qCarHistory.SQL.Clear;
  qCarHistory.SQL.Add(strSQL);
  qCarHistory.Open;
  DBGridEh1.Columns[0].Alignment:=taCenter;
  DBGridEh1.Columns[1].Alignment:=taCenter;
  DBGridEh1.Columns[2].Alignment:=taCenter;
  DBGridEh1.Columns[3].Alignment:=taCenter;
  DBGridEh1.Columns[0].Width:=153;
  DBGridEh1.Columns[1].Width:=153;
  DBGridEh1.Columns[2].Width:=153;
  DBGridEh1.Columns[3].Width:=200;
  DBGridEh1.Columns[0].Footer.alignment:=taCenter;
  DBGridEh1.Columns[0].Footer.ValueType:=fvtSum;
  DBGridEh1.Columns[1].Footer.alignment:=taCenter;
  DBGridEh1.Columns[1].Footer.ValueType:=fvtSum;
  DBGridEh1.Columns[2].Footer.alignment:=taCenter;
  DBGridEh1.Columns[2].Footer.ValueType:=fvtSum;
  DBGridEh1.Columns[3].Footer.alignment:=taCenter;
  DBGridEh1.Columns[3].Footer.valuetype:=fvtStaticText;
  DBGridEh1.Columns[3].Footer.Value:='合计';
  DBGridEh1.SumList.Active:=true;
  PrintDBGridEh1.Title.Clear;
  PrintDBGridEh1.Title.Add(' 日 期 统 计 报 表 ');
  PrintDBGridEh1.Title.Add('范围:  从 ' +  strTimeI  + ' 到 ' +  strTimeX  + ' 之间');
  PrintDBGridEh1.PageHeader.CenterText.Clear;
  PrintDBGridEh1.PageHeader.CenterText.Add(ClientUSN);
 end
 else
   if RadioButton2.Checked then
    begin
      strSQL:='Select Sum(MaoZhong) as 毛重(kg),Sum(PiZhong) as 皮重(kg),Sum(JingZhong) as 净重(kg),HuoPin as 货品 from uMaster '+
          'Where (JingZhongSJ Between CDate(' + quotedstr(TimeTostr(DateTimePicker2.Time)) + ') and  CDate(' +
          quotedstr(TimeTostr(DateTimePicker4.Time)) + ')) and (JingZhongRQ Between CDate(' +
          quotedstr(DateTostr(DateTimePicker1.Date)) + ') and CDate(' +
          quotedstr(DateTostr(DateTimePicker3.Date)) + '))'  + strCase + strCase2 + strCase3 + strCase4 +' Group by HuoPin';
          if Not adoConn.Connected then
          begin
          adoConn.Open;
          end;
          qCarHistory.Connection:=adoConn;
          qCarHistory.Close;
          qCarHistory.SQL.Clear;
          qCarHistory.SQL.Add(strSQL);
          qCarHistory.Open;
          DBGridEh1.AutoFitColWidths:=False;
          DBGridEh1.Columns[0].Alignment:=taCenter;
          DBGridEh1.Columns[1].Alignment:=taCenter;
          DBGridEh1.Columns[2].Alignment:=taCenter;
          DBGridEh1.Columns[3].Alignment:=taCenter;
          DBGridEh1.Columns[0].Width:=153;
          DBGridEh1.Columns[1].Width:=153;
          DBGridEh1.Columns[2].Width:=153;
          DBGridEh1.Columns[3].Width:=200;
          DBGridEh1.Columns[0].Footer.alignment:=taCenter;
          DBGridEh1.Columns[0].Footer.ValueType:=fvtSum;
          DBGridEh1.Columns[1].Footer.alignment:=taCenter;
          DBGridEh1.Columns[1].Footer.ValueType:=fvtSum;
          DBGridEh1.Columns[2].Footer.alignment:=taCenter;
          DBGridEh1.Columns[2].Footer.ValueType:=fvtSum;
          DBGridEh1.Columns[3].Footer.alignment:=taCenter;
          DBGridEh1.Columns[3].Footer.valuetype:=fvtStaticText;
          DBGridEh1.Columns[3].Footer.Value:='合计';
          DBGridEh1.SumList.Active:=true;
          PrintDBGridEh1.Title.Clear;
          PrintDBGridEh1.Title.Add(' 货 品 统 计 报 表 ');
          PrintDBGridEh1.Title.Add('范围:  从 ' +  strTimeI  + ' 到 ' +  strTimeX  + ' 之间');
          PrintDBGridEh1.PageHeader.CenterText.Clear;
          PrintDBGridEh1.PageHeader.CenterText.Add(ClientUSN);
    end
     else
       if RadioButton3.Checked then
          begin
            strSQL:='Select ListID as 磅单号,Trim(Left(ChePai+ChePaiN,Len(chePai+ChePaiN))) as 车牌号,MaoZhong as 毛重(kg),PiZhong as 皮重(kg),JingZhong as 净重(kg),JingZhongRQ+JingZhongSJ as 时间 from uMaster '+
                'Where (JingZhongSJ Between CDate(' + quotedstr(TimeTostr(DateTimePicker2.Time)) + ') and  CDate(' +
                quotedstr(TimeTostr(DateTimePicker4.Time)) + ')) and (JingZhongRQ Between CDate(' +
                quotedstr(DateTostr(DateTimePicker1.Date)) + ') and CDate(' +
                quotedstr(DateTostr(DateTimePicker3.Date)) + '))'  + strCase + strCase2 + strCase3 + strCase4 ;
                if Not adoConn.Connected then
                begin
                adoConn.Open;
                end;
                qCarHistory.Connection:=adoConn;
                qCarHistory.Close;
                qCarHistory.SQL.Clear;
                qCarHistory.SQL.Add(strSQL);
                qCarHistory.Open;
                DBGridEh1.AutoFitColWidths:=False;
                DBGridEh1.Columns[0].Alignment:=taCenter;
                DBGridEh1.Columns[1].Alignment:=taCenter;
                DBGridEh1.Columns[2].Alignment:=taCenter;
                DBGridEh1.Columns[3].Alignment:=taCenter;
                DBGridEh1.Columns[4].Alignment:=taCenter;
                DBGridEh1.Columns[5].Alignment:=taCenter;
                DBGridEh1.Columns[1].Width:=150;
                DBGridEh1.Columns[2].Width:=80;
                DBGridEh1.Columns[3].Width:=80;
                DBGridEh1.Columns[4].Width:=80;
                DBGridEh1.Columns[5].Width:=158;
                DBGridEh1.Columns[0].Footer.ValueType:=fvtStaticText;
                DBGridEh1.Columns[0].Footer.Value:='合 计:';
                DBGridEh1.Columns[2].Footer.ValueType:=fvtSum;
                DBGridEh1.Columns[3].Footer.ValueType:=fvtSum;
                DBGridEh1.Columns[4].Footer.valuetype:=fvtSum;
                DBGridEh1.SumList.Active:=true;
                PrintDBGridEh1.Title.Clear;
                PrintDBGridEh1.Title.Add(' 磅 单 统 计 报 表 ');
                PrintDBGridEh1.Title.Add('范围:  从 ' +  strTimeI  + ' 到 ' +  strTimeX  + ' 之间');
                PrintDBGridEh1.PageHeader.CenterText.Clear;
                PrintDBGridEh1.PageHeader.CenterText.Add(ClientUSN);
          end
             else
                 if RadioButton4.Checked then   //分类
                    begin
                           if (strGroup1<>'') or (strGroup2<>'') or (strGroup3<>'') or (strGroup4<>'') then
                           begin
                            strGroup:=' Group By ';
                           end
                           else
                            begin
                            strGroup:='';
                            end;
                           if (strGroup1='') and (strGroup2<>'') then
                            strGroup2:=' ShouHuoDW ';
                           if (strGroup1='') and (strGroup2='') and (strGroup3<>'') then
                            strGroup3:=' HuoPin ';
                           if (strGroup1='') and (strGroup2='') and (strGroup3='') and (strGroup4<>'') then
                            strGroup4:=' ChePai+ChePaiN ';
                          strSQL:='Select Sum(MaoZhong) as 毛重(kg),Sum(PiZhong) as 皮重(kg),Sum(JingZhong) as 净重(kg)'+
                          strTitle1+ strTitle2 + strTitle3 + strTitle4 + ' from uMaster '+
                          'Where (JingZhongSJ Between CDate(' + quotedstr(TimeTostr(DateTimePicker2.Time)) + ') and  CDate(' +
                          quotedstr(TimeTostr(DateTimePicker4.Time)) + ')) and (JingZhongRQ Between CDate(' +
                          quotedstr(DateTostr(DateTimePicker1.Date)) + ') and CDate(' +
                          quotedstr(DateTostr(DateTimePicker3.Date)) + '))'  + strCase + strCase2 + strCase3 + strCase4 + strGroup + strGroup1 + strGroup2 + strGroup3 + strGroup4 ;
                          if Not adoConn.Connected then
                          begin
                          adoConn.Open;
                          end;
                          qCarHistory.Connection:=adoConn;
                          qCarHistory.Close;
                          qCarHistory.SQL.Clear;
                          qCarHistory.SQL.Add(strSQL);
                          qCarHistory.Open;
                          DBGridEh1.AutoFitColWidths:=False;
                          DBGridEh1.Columns[0].Alignment:=taCenter;
                          DBGridEh1.Columns[1].Alignment:=taCenter;
                          DBGridEh1.Columns[2].Alignment:=taCenter;
                          if (strTitle1<>'') or (strTitle2<>'') or (strTitle3<>'') or (strTitle4<>'') then
                          begin
                          DBGridEh1.Columns[0].Width:=75;
                          DBGridEh1.Columns[1].Width:=75;
                          DBGridEh1.Columns[2].Width:=75;
                          end
                          else
                          begin
                          DBGridEh1.Columns[0].Width:=220;
                          DBGridEh1.Columns[1].Width:=220;
                          DBGridEh1.Columns[2].Width:=220;
                          end;
                          if (strTitle1='') and (strTitle2='') and (strTitle3='') and (strTitle4<>'') then
                           begin
                              DBGridEh1.Columns[3].Alignment:=taCenter;    //t4-3
                              DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                              DBGridEh1.Columns[3].Width:=435;
                              DBGridEh1.Columns[3].Footer.Value:='合 计';
                           end
                             else
                              if ((strTitle1<>'') and (strTitle2='') and (strTitle3='')) or ((strTitle1='') and (strTitle2<>'') and (strTitle3='')) or ((strTitle1='') and (strTitle2='') and (strTitle3<>'')) and (strTitle4<>'') then
                               begin
                                  DBGridEh1.Columns[3].Alignment:=taCenter;    //t4-3
                                  DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                  DBGridEh1.Columns[3].Footer.Value:='合 计';
                                  DBGridEh1.Columns[3].Width:=335;
                                  DBGridEh1.Columns[4].Alignment:=taCenter;    //t4-4
                                  DBGridEh1.Columns[4].Width:=100;
                               end
                                else
                                 if ((strTitle1<>'') and (strTitle2<>'') and (strTitle3='')) or ((strTitle1<>'') and (strTitle2='') and (strTitle3<>'')) or ((strTitle1='') and (strTitle2<>'') and (strTitle3<>'')) and (strTitle4<>'') then
                                  begin
                                  DBGridEh1.Columns[3].Alignment:=taCenter;    //t4-3
                                  DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                  DBGridEh1.Columns[3].Footer.Value:='合 计';
                                  DBGridEh1.Columns[3].Width:=167;
                                  DBGridEh1.Columns[4].Alignment:=taCenter;    //t4-4
                                  DBGridEh1.Columns[4].Width:=168;
                                  DBGridEh1.Columns[5].Alignment:=taCenter;    //t4-5
                                  DBGridEh1.Columns[5].Width:=96;
                                  end
                                   else
                                     if (strTitle1<>'') and (strTitle2<>'') and (strTitle3<>'') and (strTitle4<>'') then
                                      begin
                                      DBGridEh1.Columns[3].Alignment:=taCenter;    //t4-3
                                      DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                      DBGridEh1.Columns[3].Footer.Value:='合 计';
                                      DBGridEh1.Columns[3].Width:=137;
                                      DBGridEh1.Columns[4].Alignment:=taCenter;    //t4-4
                                      DBGridEh1.Columns[4].Width:=138;
                                      DBGridEh1.Columns[5].Alignment:=taCenter;    //t4-5
                                      DBGridEh1.Columns[5].Width:=60;
                                      DBGridEh1.Columns[6].Alignment:=taCenter;    //t4-6
                                      DBGridEh1.Columns[6].Width:=96;
                                      end;
                                      
                          if  (strTitle1='') and (strTitle2='') and (strTitle3<>'') and (strTitle4='') then
                           begin
                             DBGridEh1.Columns[3].Alignment:=taCenter;    //t3-3
                             DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                             DBGridEh1.Columns[3].Footer.Value:='合 计';
                             DBGridEh1.Columns[3].Width:=435;
                           end
                             else
                               if ((strTitle1<>'') and (strTitle2='')) or ((strtitle1='') and (strTitle2<>'')) and (strTitle3<>'')  and (strTitle4='') then
                                begin
                                  DBGridEh1.Columns[3].Alignment:=taCenter;    //t3-3
                                  DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                  DBGridEh1.Columns[3].Footer.Value:='合 计';
                                  DBGridEh1.Columns[3].Width:=335;
                                  DBGridEh1.Columns[4].Alignment:=taCenter;    //t3-4
                                  DBGridEh1.Columns[4].Width:=100;
                                end
                                  else
                                  if (strTitle1<>'') and (strTitle2<>'') and (strTitle3<>'')  and (strTitle4='') then
                                    begin
                                      DBGridEh1.Columns[3].Alignment:=taCenter;    //t3-3
                                      DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                      DBGridEh1.Columns[3].Footer.Value:='合 计';
                                      DBGridEh1.Columns[3].Width:=167;
                                      DBGridEh1.Columns[4].Alignment:=taCenter;    //t3-4
                                      DBGridEh1.Columns[4].Width:=168;
                                      DBGridEh1.Columns[5].Alignment:=taCenter;    //t3-5
                                      DBGridEh1.Columns[5].Width:=96;
                                    end;
                                                
                          if (strTitle1='') and (strTitle2<>'') and (strTitle3='') and (strTitle4='') then
                          begin
                          DBGridEh1.Columns[3].Alignment:=taCenter;    //t2-3
                          DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                          DBGridEh1.Columns[3].Footer.Value:='合 计';
                          DBGridEh1.Columns[3].Width:=435;
                          end
                           else
                             if (strTitle1<>'') and (strTitle2<>'') and (strTitle3='') and (strTitle4='') then
                              begin
                                  DBGridEh1.Columns[3].Alignment:=taCenter;    //t2-3
                                  DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                                  DBGridEh1.Columns[3].Footer.Value:='合 计';
                                  DBGridEh1.Columns[3].Width:=217;
                                  DBGridEh1.Columns[4].Alignment:=taCenter;    //t2-4
                                  DBGridEh1.Columns[4].Width:=218;
                              end;
                                       
                          if (strTitle1<>'') and (strTitle2='') and (strTitle3='') and (strTitle4='') then
                          begin
                          DBGridEh1.Columns[3].Alignment:=taCenter;    //t1-3
                          DBGridEh1.Columns[3].Footer.ValueType:=fvtStaticText;
                          DBGridEh1.Columns[3].Footer.Value:='合 计';
                          DBGridEh1.Columns[3].Width:=435;
                          end;
                          
                          DBGridEh1.Columns[0].Footer.ValueType:=fvtSum;
                          DBGridEh1.Columns[1].Footer.ValueType:=fvtSum;
                          DBGridEh1.Columns[2].Footer.valuetype:=fvtSum;
                          DBGridEh1.SumList.Active:=true;
                          PrintDBGridEh1.Title.Clear;
                          PrintDBGridEh1.Title.Add(' 分 类 统 计 报 表 ');
                          PrintDBGridEh1.Title.Add('范围:  从 ' +  strTimeI  + ' 到 ' +  strTimeX  + ' 之间');
                          PrintDBGridEh1.PageHeader.CenterText.Clear;
                          PrintDBGridEh1.PageHeader.CenterText.Add(ClientUSN);
                    end;
 BitBtn7.Enabled:=True;
except
end;
end;

procedure TfrmHuiZongRep.CheckBox1Click(Sender: TObject);
begin
 if (checkbox1.Checked) then
 begin
  Combobox5.Enabled:=true;
 end
 else
 begin
  Combobox5.Enabled:=false;
 end;
end;

procedure TfrmHuiZongRep.CheckBox2Click(Sender: TObject);
begin
 if (checkbox2.Checked) then
 begin
  Combobox1.Enabled:=true;
 end
 else
 begin
  Combobox1.Enabled:=false;
 end;
end;

procedure TfrmHuiZongRep.FormCreate(Sender: TObject);
var
 Connstr:string;
begin
 if Not ADOConn.Connected then
 begin
    Connstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
    adoConn.ConnectionString:=Connstr;
    adoCOnn.Open;
 end;
end;

end.

⌨️ 快捷键说明

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