Ver Mensaje Individual
  #1  
Antiguo 03-04-2008
Avatar de richy08
richy08 richy08 is offline
Miembro
 
Registrado: may 2007
Ubicación: Bucerias, Nayarit Mexico
Posts: 529
Reputación: 18
richy08 Va por buen camino
Problemas con el componente TTable (con BDE)

Primeramente buenas tardes, tengo todo el dia peliando con esa porqueria de componente del tatable del bde y no encuentro el por que no funciona (tampoco entiendo pro que me obligan a programar con eso existiendo ado:S) esta aplicacion se conecta a microsoft access(por si faltaba algo obsoleto)pero al grano no entiendo por que no me respeta el estado de insert este es el codigo que uso para insertar un registro yo no l oprograme solo trato de acomodarlo
Código Delphi [-]
procedure TForm1.AddItemClick(Sender: TObject);
begin

     if trim(iQUANTITY.Text)=''then
      begin
            MessageBox(Handle,'The Field Amount is empty','Error',mb_ok+mb_iconerror);
            iQUANTITY.setfocus;
            exit;
      end;
     if trim(DBLookupitemcode.Text)=''then
      begin
            MessageBox(Handle,'The Field Item is empty','Error',mb_ok+mb_iconerror);
            DBLookupitemcode.setfocus;
            exit;
      end;

data.tquotedetail.close;
data.TQuotedetail.Active:=false;
data.TQuotedetail.Filtered:=false;
data.tquotedetail.Open;
data.tquotedetail.Insert; 
 
DATA.tquotedetail.fieldbyname('nQuantity').VALUE:=trim(iquantity.TEXT);
DATA.tquotedetail.FIELDBYNAME('sITEMID').value:=trim(DBlookupitemcode.TEXT);
DATA.tquotedetail.FIELDBYNAME('sDETAILS').value:=trim(DBDESCRIPCION.Caption + DBMARCA.caption);
DATA.tquotedetail.FIELDBYNAME('nCOST').value:=(DBPRECIOP.caption);
DATA.tquotedetail.fieldbyname('sLOCATION').VALUE:=trim(SLOCATION.TEXT);
DATA.tquotedetail.FIELDBYNAME('nfloor').VALUE:=trim(SFLOOR.text);
 try
  if DATA.tquotedetail.state in [dsedit, dsinsert] then //valida si esta editando o insertando en la tabla
  begin
     DATA.tquotedetail.POST;
  end;

    laborbtn.Enabled:=true;
    data.tQuotedetail.Close;
    data.tQuotedetail.Filtered:=true;
    data.tQuotedetail.Filter:=' nQuoteID='+trim(dbedit1.text);
    data.tQuotedetail.Open;
 except
 on EDBEngineError do begin
    Messagebox(Handle,'Duplicate Guest Export','Key Violation', 0);
    data.Tquotedetail.cancel;
    data.Tquotedetail.edit;
 end;
 end;
end;

esto esta dentro de un boton para insertar el registro

y este otro codigo es para hacer una busqueda

Código Delphi [-]
procedure TForm2.DBGrid1DblClick(Sender: TObject);
var 
   filtro:string; 
begin
punta:=   data.qrymasterpick.fieldbyname('nQuoteid').value;
form1.DBEdit1.Text:=punta;
data.Qry_detail.Close;
data.Qry_detail.prepare;
data.Qry_detail.parambyname('code').value:= data.qrymasterpick.fieldbyname('nQuoteid').value;
data.Qry_detail.open;
form2.Close;
data.tQuotedetail.close;
data.tQuotedetail.open;
filtro:=' nQuoteID='+punta;
data.tQuotedetail.Filter:=filtro;

Form1.sClientID.Visible:=false;
Form1.DBDESCRIPCION.Visible:=false;
Form1.DBMARCA.Visible:=false;
Form1.DBPRECIOP.Visible:=false;
Form1.DBTYPE.Visible:=false;
Form1.DESCRIPCION.Visible:=true;
Form1.MARCA.Visible:=true;
Form1.PRECIOP.Visible:=true;
Form1.LTYPE.Visible:=true;
Form1.SUPPLIER.Visible:=true;
data.Qry_Master.Close;
data.Qry_Master.prepare;
data.Qry_Master.parambyname('code').value:= data.tQuotedetail.fieldbyname('sitemid').value;
data.Qry_Master.open;
if not (data.Qry_Master.IsEmpty) then
begin
 Form1.DESCRIPCION.Caption:=data.Qry_Master.Fieldbyname('descripcion').Value;
 Form1.MARCA.Caption:=data.Qry_Master.Fieldbyname('MArca').Value;
 Form1.PRECIOP.Caption:=data.Qry_Master.Fieldbyname('PRECIO PUBLICO').Value;
 Form1.LTYPE.Caption:=data.Qry_Master.Fieldbyname('Type').Value;
 Form1.SUPPLIER.Caption:=data.Qry_Master.Fieldbyname('supplier').Value;
 Form1.edt_item.text:=data.Qry_Master.Fieldbyname('DESCRIPCION').Value;
end;
 //Form1.DBLookupclientid
Form1.Edt_Comment.Text:=data.qrymasterpick.fieldbyname('scomments').value;
Form1.Edt_client.Text:=data.qrymasterpick.fieldbyname('sCompany').value;
data.qrymasterpick.Close;
Form1.iQUANTITY.enabled:=true;
Form1.DBLookupitemcode.enabled:=true;
Form1.SLOCATION.enabled:=true;
Form1.sFLOOR.enabled:=true;
Form1.iQUANTITY.Color:=clwindow;
Form1.DBLookupitemcode.Color:=clwindow;
Form1.SLOCATION.Color:=clwindow;
Form1.sFLOOR.Color:=clwindow;
Form1.DBLookupclientid.enabled:=false;
Form1.Edt_Comment.enabled:=false;
Form1.DBLookupclientid.Color:=clbtnface;
Form1.Edt_Comment.Color:=clbtnface;
Form1.AddItem.enabled:=true;
Form1.laborbtn.enabled:=true;
Form1.Button1.enabled:=false;
Form1.Button3.enabled:=true;

if not (data.Qry_detail.isempty) then
begin
  Form1.iQUANTITY.Text:=data.Qry_detail.Fieldbyname('nquantity').Value;
  //Form1.DBLookupitemcode.ListFieldIndex:=Qry_detail.Fieldbyname('').Value;
  Form1.SLOCATION.Text:=data.Qry_detail.Fieldbyname('slocation').Value;
  Form1.sFLOOR.Text:=data.Qry_detail.Fieldbyname('nfloor').Value;
end;
Form1.DBLookupclientid.Visible:=false;
Form1.DBLookupitemcode.Visible:=false;
Form1.edt_Client.Visible:=true;
Form1.edt_Client.enabled:=false;
Form1.edt_Client.color:=clbtnface;
Form1.Edt_item.Visible:=true;
end;

extrañamente cuando hago puras busquedas funciona bien o cuando creo un nuevo registro y estoy insertando al detalle tambien, pero cuando hago una busqueda y quiero insertarle algo ya no lo hace, o despues de crear un registro e insertarle a lhacer una busque da no hace nada.

muchas gracias uqine me pueda decir que le pasa a estos componentes obsoletos
Responder Con Cita