Ver Mensaje Individual
  #1  
Antiguo 16-05-2014
jonydread jonydread is offline
Miembro
NULL
 
Registrado: nov 2011
Posts: 157
Reputación: 15
jonydread Va por buen camino
ayuda comprobando campos

Estimados tengo un problemilla con este codigo al comprobar campos, necesito comprobar primero si estan vacio campos y luego que si registro ya existe en listado, el problema que tengo es que al recorrer listview esta cuando esta vacia no hace nada pero si tiene registro funciona agregando registro pero no cancela al ya existir. agrego codigo
Código Delphi [-]
procedure TForm2.BitBtn11Click(Sender: TObject);
var
cItem: TListItem;
id,man: string;
i: integer;
begin
for i := 0 to Listview5.Items.Count -1 do
begin
if (dblookupcombobox1.KeyValue = NULL) or (edit11.Text='') or (edit12.Text='') then
MessageDlg('complete campos', mtWarning, [mbOk],0)
else
if Listview5.Items[i].Caption = dblookupcombobox1.KeyValue  then
MessageDlg('ya existe elemento', mtWarning, [mbOk],0) else
begin
  man:= uman.Text;
  Zquery1.sql.text := 'insert into MP values (:area,:id,:elemento,:frecuencia,:tipo,:umant,mant)';
  ZQuery1.ParamByName('area').AsString := label8.Caption;
  ZQuery1.ParamByName('id').AsString := dblookupcombobox1.KeyValue;
  ZQuery1.ParamByName('elemento').AsString := dblookupcombobox1.Text;
  ZQuery1.ParamByName('frecuencia').AsString := edit11.Text;
  ZQuery1.ParamByName('tipo').AsString := edit12.Text;
  ZQuery1.ParamByName('umant').AsString := man;
  ZQuery1.ParamByName('pmant').AsDate := Datetimepicker4.Date;
  ZQuery1.ExecSQL;
  zQuery1.SQL.Clear;
  Zquery1.Close;
  Listview5.Clear;
  Zquery1.SQL.Text := 'SELECT * From MP where area = :area';
  zQuery1.ParamByName('area').AsString:= label8.Caption;
  zquery1.Open;
while not zquery1.Eof do
begin
cItem := Listview5.Items.Add;
cItem.Caption := zQuery1.fieldbyname('id').AsString;
cItem.SubItems.Add(zQuery1.fieldbyname('elemento').AsString);
cItem.SubItems.Add(zQuery1.fieldbyname('frecuencia').AsString);
cItem.SubItems.Add(zQuery1.fieldbyname('tipo').AsString);
cItem.SubItems.Add(zQuery1.fieldbyname('umant').AsString);
cItem.SubItems.Add(zQuery1.fieldbyname('pmant').AsString);
zquery1.next;
end;
edit11.Clear;edit12.Clear;
uman.Clear;
uman.Add('no registra');
Datetimepicker3.Format:= ' ';
end;
end;
end;


gracias!
Responder Con Cita