在所有工作中需要显示taskid 为1 和0 的记录 但是我们领导要求分别用不同颜色区别,这个俺不会阿。高手来帮忙啊!!谢谢了!!procedure TForm4.Button1Click(Sender: TObject);
begin
if ComboBox2.Text = '计划内工作' then
begin
Query1.Close;
Query1.SQL.Clear;
//showmessage('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '0' + ''' ');
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '0' + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else if ComboBox2.Text = '计划外工作' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '1' + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else if ComboBox2.Text = '所有工作' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else
exit;
end;
begin
if ComboBox2.Text = '计划内工作' then
begin
Query1.Close;
Query1.SQL.Clear;
//showmessage('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '0' + ''' ');
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '0' + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else if ComboBox2.Text = '计划外工作' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + '''and taskid= ''' + '1' + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else if ComboBox2.Text = '所有工作' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from ZHAOWEI.BZGZ where workdate = ''' + DateToStr(Self.DateTimePicker1.Date) + '''and banzu= ''' + Trim(ComboBox1.Text) + ''' ');
Query1.ExecSQL;
Query1.Open;
end
else
exit;
end;
Begin
oldpm:= Canvas.pen.mode;
oldcolor:= Canvas.Brush.color;
Canvas.Brush.color:=newColor;
Canvas.pen.mode:=pmmask;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
Canvas.Brush.color:=oldcolor;
Canvas.pen.mode:=oldpm;
End;
if Query1.FieldByName('taskid').AsInteger=1 then
DBGrid1.Canvas.Brush.Color := clBlue
else DBGrid1.Canvas.Brush.Color := clRed; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Query1.FieldByName('taskid').AsString='1' then
DBGrid1.Canvas.Font.Color:= clblue
else
DBGrid1.Canvas.Font.Color:= clwindowText;
dbGrid1.DefaultDrawColumnCell(rect, datacol, column, state);end;end.可以了