You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

122 lines
3.1 KiB

unit ufrmEscolheCampanha;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Vcl.StdCtrls, Vcl.ComCtrls,
Data.DB, ZAbstractRODataset, ZAbstractDataset, ZDataset;
type
TfrmEscolheCampanha = class(TmstMaster)
cb_campanhas: TComboBox;
btn_ok: TButton;
btn_cancel: TButton;
Label1: TLabel;
queryLimpaCamp: TZQuery;
procedure FormShow(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
{ Private declarations }
public
{ Public declarations }
end;
var
frmEscolheCampanha: TfrmEscolheCampanha;
implementation
{$R *.dfm}
uses udtmSystem, ufrmCobranca;
procedure TfrmEscolheCampanha.btn_okClick(Sender: TObject);
begin
dtmSystem.qryConsulta.RecNo := cb_campanhas.ItemIndex + 1;
dtmSystem.tblCobCampanha.Locate('ID_CAMPANHA',
dtmSystem.qryConsulta.FieldByName('ID_CAMPANHA').AsInteger, []);
frmCobranca.campanha := dtmSystem.tblCobCampanhaID_CAMPANHA.AsInteger;
end;
procedure TfrmEscolheCampanha.FormCreate(Sender: TObject);
begin
inherited;
queryLimpaCamp.SQL.Text :=
'select * from chg_campanhas_devedores where id_campanha in (' +
'select id_campanha from chg_campanhas where id_campanha not in (' +
'select id_campanha from chg_campanhas_cobradores where id_cobrador =' +
inttostr(dtmSystem.id_usuario) + ' ))' + 'and tp_cobrando = ' +
inttostr(dtmSystem.id_usuario);
queryLimpaCamp.Open;
if not queryLimpaCamp.IsEmpty then
begin
queryLimpaCamp.First;
if not dtmSystem.tblCampanhaDevedores.Active then
begin
dtmSystem.tblCampanhaDevedores.Open;
end;
while not queryLimpaCamp.Eof do
begin
dtmSystem.tblCampanhaDevedores.Locate('ID_ITEM',
queryLimpaCamp.FieldByName('ID_ITEM').AsInteger, []);
dtmSystem.tblCampanhaDevedores.Edit;
dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger := -1;
dtmSystem.tblCampanhaDevedores.Post;
queryLimpaCamp.Next;
end;
end;
dtmSystem.tblCampanhaDevedores.Close;
queryLimpaCamp.Close;
end;
procedure TfrmEscolheCampanha.FormShow(Sender: TObject);
begin
with dtmSystem do
begin
if not tblCobCampanha.Active then
begin
tblCobCampanha.Open;
end;
qryConsulta.Refresh;
qryConsulta.First;
while not qryConsulta.Eof do
begin
cb_campanhas.Items.Add(qryConsulta.FieldByName('tx_nome').AsString);
qryConsulta.Next;
end;
end;
cb_campanhas.ItemIndex := 0;
end;
procedure TfrmEscolheCampanha.WMMoving(var Msg: TWMMoving);
var
workArea: TRect;
begin
workArea := Screen.WorkareaRect;
with Msg.DragRect^ do
begin
if left < workArea.left then
OffsetRect(Msg.DragRect^, workArea.left - left, 0);
if top < workArea.top then
OffsetRect(Msg.DragRect^, 0, workArea.top - top);
if Right > workArea.Right then
OffsetRect(Msg.DragRect^, workArea.Right - Right, 0);
if Bottom > workArea.Bottom then
OffsetRect(Msg.DragRect^, 0, workArea.Bottom - Bottom);
end;
end;
end.