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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 22-06-2011
sleep25000 sleep25000 is offline
Miembro
NULL
 
Registrado: jun 2011
Posts: 29
Poder: 0
sleep25000 Va por buen camino
Relacion Maestro-Detalle

Buenas noches,
He creado una relacion maestro-detalles con las propiedades MasterSource y MasterFields, tengo tres DBGrid, productos, productosProveedor, Stock, de inicio todo funciona bien, pero al moverme por productos, en los demas DBGrid se van creando automaticamente registros, he probado todo, pero no hay forma de solucionarlo, me pueden ayudar? gracias.
Responder Con Cita
  #2  
Antiguo 22-06-2011
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.042
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
¿Y el código fuente de lo que estás haciendo?, explica con detalle lo que haces y lo que necesitas, componentes, base de datos, etc.
Responder Con Cita
  #3  
Antiguo 22-06-2011
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
se van creando registros?
que quieres decir con eso?
cual es la finalidad de este Maestro-Detalle?
solo consultar?
adiccionar datos?
cual es el flujo?

debes ser un poquito mas explicito para tener una mejor idea y ayudarte
saludos
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
  #4  
Antiguo 23-06-2011
sleep25000 sleep25000 is offline
Miembro
NULL
 
Registrado: jun 2011
Posts: 29
Poder: 0
sleep25000 Va por buen camino
Relacion Maestro-Detalle

Les Comento:
Tengo estas cuatro tablas:
Código SQL [-]
CREATE TABLE Items (
  ItemID varchar(25) NOT NULL,
  ItemType int NOT NULL,
  TaxID int NOT NULL,
  MetricUnitID int NOT NULL,
  FamilyID int NOT NULL,
  ProviderID integer NOT NULL,
  BarrCode varchar(25) NULL,
  Capacity float NOT NULL,
  ItemName varchar(255) NOT NULL,
  ItemDescription Text NULL,
  CostPrice float NULL,
  Percentage1 float NULL,
  Percentage2 float NULL,
  Percentage3 float NULL,
  PV1 float NOT NULL,
   PV2 float NOT NULL,
  PV3 float NOT NULL,
  PVP1 float NOT NULL,
   PVP2 float NOT NULL,
  PVP3 float NOT NULL,
  ImageDir varchar(255) NULL,
  BoImageStrech bit NULL,
  Weigth float NULL,
  Width float NULL,
  Length float NULL,
  Heigth float NULL,
  Warranty integer NULL,
  MinStock integer NULL,
  BoStock bit NULL,
  BoItemSerial bit NULL,
  BoDescription bit NULL,
  User int NULL,
  Date datetime NULL,
  Terminal int NULL,

 PRIMARY KEY (ItemID)
);


CREATE TABLE Stock (
  IntCodID int NOT NULL AUTO_INCREMENT,
  ItemID varchar(25) NOT NULL,
  WarehouseID int NOT NULL,
  ColorID int NULL,
  SizeID int  NULL,
  AviableQty float  NULL,
  PhisicalQty integer NULL,
  SuppliersOrderQty integer NULL,
  CustomersOrderQty integer NULL,
  LastPurchase DateTime NULL,
  LastSale DateTime NULL,
  DocumentPurchase varchar(15) NULL,
  DocumentSale varchar(15) NULL,
  User int NULL,
  Date datetime NULL,
  Terminal int NULL,

 PRIMARY KEY (IntCodID,ItemID,WareHouseID)
);
CREATE TABLE ItemBarCodes (
  ItemID  varchar(25) NOT NULL,
  BarCode varchar(25) NOT NULL,
  ItemName varchar(255) NOT NULL,
  Qty float NOT NULL,
  PriceID varchar(5) NULL,
  Price float NULL,
  User int NULL,
  Date datetime NULL,
  Terminal int NULL,
  
 PRIMARY KEY (ItemID),
); 

CREATE TABLE ItemProvider (
  ItemID varchar(25) NOT NULL,
  ItemProvider varchar(25) NOT NULL,
  ProviderID integer NOT NULL,
  CostPrice float NULL,
  BuyDate datetime NULL,
  User int NULL,
  Date datetime NULL,
  Terminal int NULL,

 PRIMARY KEY (ItemID, ItemProvider,ProviderID)  
);
De momento no tengo código, solo componentes:
TADOQuery, TDataSetProvider, TClientDataSet para cada componente, también un TDataSource enlazado al TClientDataSet Items que es la tabla maestra, y en el resto que son los detalles, através de la propiedad MasterSource apunta al TDataSource Items, y MasterField con ItemID > ItemID, en el formulario tengo cuatro DBGrid,todos enlazados con un DataSource.
Inicio el formulario y todo esta correcto, DBGrid Items está situado en el primer registro y todos los demás DBGrid muestran los registros correspondientes, selecciono otro registro en DBGrid Items y los DBGrid Detalle
esta todo correcto, pero ahora selecciono el registro anterior y los DBGrid que apuntan a ItemProvider y Stock, automaticamente se duplican los registros, selecciono otro registro, y vuelvo al registro otra vez y se vuelve a duplicar, no hay codigo, estoy trabajando con delphi 2010 y MySql, es posible que sea
por el primary Key, ya que el DBGrid ItemBarCodes no se duplica y da la casualidad que sus claves primarias son ItemID, en cambio en ItemProvider es
PRIMARY KEY (ItemID, ItemProvider,ProviderID) y en Stock PRIMARY KEY (IntCodID,ItemID,WareHouseID), espero que asi puedan entender mi problema, gracias.

Última edición por Casimiro Notevi fecha: 23-06-2011 a las 10:20:44. Razón: Poner etiquetas [sql] [/sql]
Responder Con Cita
Respuesta



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
Saber si el DBGrid (Detalle) esta Vacio en Relacion Maestro/Detalle Adrian Murua Conexión con bases de datos 2 03-01-2009 13:48:46
Relacion Maestro Detalle einarcito Varios 7 09-10-2008 13:56:41
Respecto a la relacion maestro detalle detalle ilichhernandez Conexión con bases de datos 0 15-05-2007 18:13:54
relacion maestro detalle TDBGrid caperucitaazul C++ Builder 0 08-02-2006 00:40:49
Relacion Maestro Detalle oneromm Conexión con bases de datos 3 18-12-2003 21:57:40


La franja horaria es GMT +2. Ahora son las 17:24:06.


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