Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-05-2011
Rofocale Rofocale is offline
Miembro
 
Registrado: mar 2010
Posts: 182
Poder: 15
Rofocale Va por buen camino
Actualizar registro.. ayuda

Código Delphi [-]
  icodex := strtoint(txtcodigo.Text);

        with dmDatos.qryventarea do begin
         Close;
        SQL.Clear;
        SQL.Add('SELECT * FROM ventasareas');
        open;
        if(not Eof)then begin
        if icodex <> FieldByName('codigo').value then
        begin
     // dmDatos.cdsventarea.Active := false;
        Close;
        SQL.Clear;
        SQL.Add('INSERT INTO ventasareas (areaventa, orden, articulo, codigo, descrip, cantidad, precio, cliente, categoria, fecha)');
        SQL.Add('VALUES(:areaventa, rden, :articulo, :codigo, :descrip, :cantidad, recio, :cliente, :categoria, :fecha)');
            params.ParamByName('areaventa').Value := sAreaVenta;
             if(iCliente < 1) then
               params.ParamByName('orden').Value := NULL
            else
               params.ParamByName('orden').Value := iorden;

            params.ParamByName('articulo').Value := txtclave.Text;
            params.ParamByName('codigo').Value := txtcodigo.Text;
            params.ParamByName('descrip').Value := txtdescripc.Text;
            params.ParamByName('cantidad').Value := txtcantidad.Text;
            params.ParamByName('precio').Value := txtprecio.Text;

            if(iCliente < 1) then
               params.ParamByName('cliente').Value := NULL
            else
               params.ParamByName('cliente').Value := IntToStr(iCliente);

            if(Length(txtcategoria.Text) > 0) then
               params.ParamByName('categoria').Value := txtcategoria.Text
            else
               params.ParamByName('categoria').Value := NULL;


            params.ParamByName('fecha').Value := FormatDateTime('dd/mm/yyyy',Date);
            ExecSQL;
            Close;
        end;
        end
        else begin
          Close;
            SQL.Clear;
            SQL.Add('UPDATE ventasareas SET areaventa = :areaventa,orden = rden,');
            SQL.Add('articulo = :articulo,codigo = :codigo,descripcion = :descripcion,');
            SQL.Add('cantidad = :cantidad,precio = recio,cliente = :cliente,');
            SQL.Add('categoria = :categoria,fecha = :fecha WHERE codigo = :codigo');

            params.ParamByName('areaventa').Value := sAreaventa;
            params.ParamByName('orden').Value := iorden;
            params.ParamByName('articulo').Value := txtclave.Text;
            params.ParamByName('codigo').Value := txtcodigo.Text;
            params.ParamByName('descripcion').Value := txtdescripc.Text;
           params.ParamByName('cantidad').Value := txtcantidad.Text;
            params.ParamByName('precio').Value := txtprecio.Text;
            params.ParamByName('cliente').Value :=IntToStr(iCliente);
            params.ParamByName('categoria').Value := txtcategoria.Text;
            params.ParamByName('fecha').Value := FormatDateTime('dd/mm/yyyy',Date);
        end;
        end;

buenas estaba haciendo este codigo para insertar articulos con un boton agregar desde una lista, lo que quiero es que si escribes en un edit el codigo y este sea igual al ya ingresado anteriormente en un grid lo actualize en ves de ponerlo en la sgte linea y si no es el mismo codigo agregarlo en la siguiente linea..

bueno el codigo no hace nada cuando apreto el boton agregar..
que estoy haciendo mal, alguna sugerencia ?
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Actualizar registro.... BlueSteel MS SQL Server 2 03-10-2008 17:08:11
Actualizar registro georgejg Conexión con bases de datos 2 26-03-2008 23:35:00
Actualizar un campo de un registro alcides Varios 6 23-05-2007 10:20:31
actualizar registro de windows jmeng2 Varios 2 08-12-2004 16:44:02
Actualizar un único registro Muten Firebird e Interbase 2 16-03-2004 16:03:30


La franja horaria es GMT +2. Ahora son las 20:48:00.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi