Tema: ayuda...
Ver Mensaje Individual
  #5  
Antiguo 08-08-2006
ajmr81 ajmr81 is offline
Registrado
 
Registrado: ago 2006
Posts: 9
Reputación: 0
ajmr81 Va por buen camino
ayuda

este es el codigo de lo que estoy realizando

Código Delphi [-]
 
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, lmdctrl, lmdstdcS, wwSpeedButton, wwDBNavigator,
  wwclearpanel, wwdblook, lmdbtn, ToolWin, ComCtrls, Mask, wwdbedit,
  lmdcombo, lmdextcS, jpeg, DBTables, DBISAMTb, Grids, DBGrids, DBISAMCt;
type
  TF_Main = class(TForm)
     ToolBar1: TToolBar;
     BT_1: TLMDButton;
     BT_2: TLMDButton;
     BT_3: TLMDButton;
     LMDButton2: TLMDButton;
     N1_Code: TwwDBLookupCombo;
     ED_N1: TwwDBEdit;
     E_CODERES: TEdit;
     Label3: TLabel;
     LMDButton7: TLMDButton;
     E_N1: TwwDBEdit;
     N2_Code: TwwDBLookupCombo;
     Label1: TLabel;
     E_N2: TwwDBEdit;
     E_N3: TwwDBEdit;
     E_N6: TwwDBEdit;
     ED_N2: TwwDBEdit;
     N3_Code: TwwDBLookupCombo;
     ED_N3: TwwDBEdit;
     LMDButton10: TLMDButton;
     N6_Code: TEdit;
     E_DESCRIPCION: TEdit;
     C_Tallas: TCheckBox;
     Label2: TLabel;
     E_Grupo: TEdit;
     Label4: TLabel;
     E_Departamento: TEdit;
     E_Linea: TEdit;
     E_Marca: TEdit;
     E_TallaTamano: TEdit;
     E_Moneda: TEdit;
     E_Unidad: TEdit;
     E_Origen: TEdit;
     E_Modelo: TEdit;
     E_Referencia: TEdit;
     Label5: TLabel;
     Label7: TLabel;
     Label8: TLabel;
     Label6: TLabel;
     Label9: TLabel;
     Label10: TLabel;
     Label11: TLabel;
     Label12: TLabel;
     Label13: TLabel;
     E_InformacionAdicional: TMemo;
     GroupBox1: TGroupBox;
     E_CostoAnterior: TEdit;
     E_Pvp1: TEdit;
     E_Pvp2: TEdit;
     E_Pvp3: TEdit;
     Label14: TLabel;
     Label15: TLabel;
     Label16: TLabel;
     Label17: TLabel;
procedure LMDButton6Click(Sender: TObject);
procedure LMDButton2Click(Sender: TObject);
procedure ProcedenChange(Sender: TObject);
procedure BT_1Click(Sender: TObject);
procedure LMDButton7Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure BT_2Click(Sender: TObject);
procedure BT_3Click(Sender: TObject);
procedure BT_4Click(Sender: TObject);
procedure N1_CodeChange(Sender: TObject);
procedure N2_CodeChange(Sender: TObject);
procedure N3_CodeChange(Sender: TObject);
procedure LMDButton10Click(Sender: TObject);
private
    { Private declarations }
Public
    { Public declarations }
end;
var
  F_Main: TF_Main;
implementation
uses Unit3,DatosU, Unit2, Unit5, Unit6, Unit7, Unit8, Unit9, Unit10, Unit11;
Const
      NPrecios         = 6;
      DecimalAllow     = 2;
Type  //Registro para almacenar los costos y precios de inventario
      //en un BlobField;
      RegUnPrecio = Record
                    PorcUtil     ,
                    PorcUtilEx   : Boolean;
                    Utilidad     ,
                    UtilidadEx   ,
                    SinImpuesto  ,
                    MtoImpuesto1 ,
                    MtoImpuesto2 ,
                    TotalPrecio  ,
                    TotalPrecioEx: Currency;
                    TipoRound    : Byte;
                    end;
      RegCostos   = Record
                    CodeCompra      : String[50];   //Utilizado en el modulo de compras
                    VImpuesto1      ,
                    VImpuesto2      : Boolean;  //Impuestos Activados
                    CostoAnteriorBs ,
                    CostoAnteriorEx ,
                    CostoActualBs   ,
                    CostoActualEx   ,
                    CostoPromedioBs ,
                    CostoPromedioEx ,
                    MImpuesto1      ,
                    MImpuesto2      : Currency;
                    PorcentImp1     ,
                    Excento1        ,
                    PorcentImp2     ,
                    Excento2        : Boolean;
                    FechaVencimiento: TDateTime;   //Lo uso en el modulo de compras para incluir el vencimiento
                    NumeroDeLote    : String[50];  //y el numero de lote de los productos con costos por lote
                    Precios         : Array[1..NPrecios] of RegUnPrecio;
                    end;
{$R *.DFM}

procedure TF_Main.LMDButton6Click(Sender: TObject);
begin
 F_Maestro.ShowMOdal;
end;
procedure TF_Main.LMDButton2Click(Sender: TObject);
begin
   F_Main.Close;
end;
procedure TF_Main.ProcedenChange(Sender: TObject);
Var  Tipo : String;
begin
end;
procedure TF_Main.BT_1Click(Sender: TObject);
begin
  F_NIvel_1.ShowModal;
end;
procedure TF_Main.LMDButton7Click(Sender: TObject);
begin
  F_Config.ShowModal;
end;
procedure TF_Main.FormActivate(Sender: TObject);
Var  Nivel : Integer;
     Dira2 : String;
     DirLocal :  String;
begin
   DATOS.T_Config.Active := True;
   Dira2 := datos.T_Config.FieldByName('FNC_DIRA2').AsString;
   DirLocal :=  datos.T_Config.FieldByName('FNC_DIRLOCAL').AsString;
   //Activo tablas de a2
   DATOS.T_Nivel1.DatabaseName := Dira2;
   DATOS.T_Nivel_2.DatabaseName := Dira2;
   DATOS.T_Nivel_3.DatabaseName := Dira2;
   DATOS.T_Inventario.DatabaseName := Dira2;
   // Prueba para lo del Sfixed
   DATOS.T_Sfixed.DatabaseName := Dira2;
   Datos.T_Sfixed.Active := True;
   //
   Datos.T_Nivel1.Active := True;
   Datos.T_Nivel_2.Active := True;
   Datos.T_Nivel_3.Active := True;
   Datos.T_Inventario.Active := True;
   // Activo  tablas locales
   Nivel := Datos.T_Config.FieldByName('FNC_NUM_NIVELES').AsInteger;
   If Nivel = 1 then
    begin
      BT_1.Enabled := True;
      BT_1.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL1').AsString;
      E_N1.Visible := True;
      N1_Code.Visible := True;
      ED_N1.Visible := True;
    end;
    If Nivel = 2 then
    begin
      BT_1.Enabled := True;
      BT_1.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL1').AsString;
      BT_2.Enabled := True;
      BT_2.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL2').AsString;
      E_N1.Visible := True;
      N1_Code.Visible := True;
      ED_N1.Visible := True;
      E_N2.Visible := True;
      N2_Code.Visible := True;
      ED_N2.Visible := True;
    end;
    If Nivel = 3 then
    begin
      BT_1.Enabled := True;
      BT_1.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL1').AsString;
      BT_2.Enabled := True;
      BT_2.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL2').AsString;
      BT_3.Enabled := True;
      BT_3.Caption := Datos.T_Config.FieldByName('FNC_NAME_NIVEL3').AsString;
      E_N1.Visible := True;
      N1_Code.Visible := True;
      ED_N1.Visible := True;
      E_N2.Visible := True;
      N2_Code.Visible := True;
      ED_N2.Visible := True;
      E_N3.Visible := True;
      N3_Code.Visible := True;
      ED_N3.Visible := True;
    end;
end;
procedure TF_Main.BT_2Click(Sender: TObject);
begin
  F_Nivel_2.ShowModal;
end;
procedure TF_Main.BT_3Click(Sender: TObject);
begin
   F_Nivel_3.ShowModal;
end;
procedure TF_Main.BT_4Click(Sender: TObject);
begin
  F_Nivel_4.ShowModal;
end;
procedure TF_Main.N1_CodeChange(Sender: TObject);
begin
  E_CODERES.Text := N1_Code.Text;
end;
procedure TF_Main.N2_CodeChange(Sender: TObject);
begin
  E_CODERES.Text := N1_Code.Text+N2_Code.Text;
end;
procedure TF_Main.N3_CodeChange(Sender: TObject);
begin
  E_CODERES.Text := N1_Code.Text+N2_Code.Text+N3_Code.Text;
end;

procedure TF_Main.LMDButton10Click(Sender: TObject);
Var  Tallas : Boolean;
begin
   Datos.T_Inventario.Insert;
   Datos.T_Inventario.FieldByName('FI_CODIGO').AsString := E_CODERES.Text;
   Datos.T_Inventario.FieldByName('FI_DESCRIPCION').AsString := E_DESCRIPCION.Text;
   Datos.T_Inventario.FieldByName('FI_DESCRIPCIONDETALLADA').AsString := E_InformacionAdicional.Text;
   Datos.T_Inventario.FieldByName('FI_SUBCATEGORIA').AsString := E_Grupo.Text;
   Datos.T_Inventario.FieldByName('FI_CATEGORIA').AsString := E_Departamento.Text;
   Datos.T_Inventario.FieldByName('ZZCAMPO_003').AsString := E_Linea.Text;
   Datos.T_Inventario.FieldByName('FI_REFERENCIA').AsString := E_Referencia.Text;
   Datos.T_Inventario.FieldByName('FI_MARCA').AsString  := E_Marca.Text;
   Datos.T_Inventario.FieldByName('FI_MODELO').AsString  := E_Modelo.Text;
   Datos.T_Inventario.FieldByName('ZZCAMPO_002').AsString  := E_TallaTamano.Text;
   Datos.T_Inventario.FieldByName('FI_MONEDA').AsString  := '1';
   Datos.T_Inventario.FieldByName('FI_UNIDAD').AsString  := E_Unidad.Text;
   Datos.T_Inventario.FieldByName('FI_SUJETOACOMISION').AsBoolean  := True;
   Datos.T_Inventario.FieldByName('FI_STATUS').AsBoolean  := True;
   Datos.T_Inventario.FieldByName('FI_PESOPRODUCTO').AsCurrency  := 0;
   Datos.T_Inventario.FieldByName('FI_GARANTIA').AsInteger  := 0;
   Datos.T_Inventario.FieldByName('FI_DEPOSITOS').AsBoolean  := True;
   Datos.T_Inventario.FieldByName('FI_OFERTAS').AsBoolean  := True;
   Datos.T_Inventario.FieldByName('FI_VENCIMIENTOS').AsBoolean  := False;
   Datos.T_Inventario.FieldByName('FI_CLASIFICACION').AsInteger  := 0;
   If  C_Tallas.Checked = True then
   begin
     Datos.T_Inventario.FieldByName('FI_MANEJOINVENTARIO').AsInteger  := 1;
   end ;
   If C_Tallas.Checked = False then
   begin
     Datos.T_Inventario.FieldByName('FI_MANEJOINVENTARIO').AsInteger  := 0;
   end;
   Datos.T_Inventario.FieldByName('FI_MANEJOINVENTARIO').AsInteger  := 0;
   Datos.T_Inventario.FieldByName('FI_SERIALES').AsBoolean  := False;
   Datos.T_Inventario.FieldByName('FI_INVENTARIOINICIALUNIDADES').AsCurrency  := 0;
   Datos.T_Inventario.FieldByName('FI_INVENTARIOINICIALCOSTO').AsCurrency  := 0;
   Datos.T_Inventario.FieldByName('FI_CAPACIDAD').AsCurrency  := 0;
   Datos.T_Inventario.FieldByName('FI_EXISTDECIMAL').AsBoolean  := False;
   Datos.T_Inventario.FieldByName('FI_COMPUESTOSERIALES').AsBoolean  := False;
   Datos.T_Inventario.Post;
 
******* esta es la rituna o procedimiento que necesito agregar, pero me arroja unos errores que no se como solventar
 
// aca comienza la copia del blob de precios
//   Var SourceField    : TField;
//   BlobStreamData : TDBISAMBlobStream;
//   I:Byte;
//   H : Byte;
//   CostoSIVA, Costo, CostoEx  : Double;
//   Impuesto : Integer;
//   begin
//   //FillChar(CostosProducto,SizeOf(CostosProducto),0 );
//   With TableFix do
//   if  Not FindKey(['B',SourceCode]) then
//    begin
//    Insert;
//    FieldByName('FX_TIPO').AsString     := 'B';
//    FieldByName('FX_CODIGO').AsString   := SourceCode;
//    FieldByName('FX_VISIBLE').AsBoolean := True;
//    FieldByName('FX_EXISTENCIA').AsFloat := 0;
//    FieldByName('FX_EXISTENCIAINICIAL').AsFloat := 0;
//
//    //Rellenando el registro de costos para guardarlo en el campo Blob
//     With CostosProducto do
//       begin
//          Costo := TableDBF.FieldByName(CampoCosto.Text).AsFloat;
//          If BoxDolar.Checked = True then
//           begin
//            CostoEx := TableDBF.FieldByName(CampoCostoUs.Text).AsFloat;
//           end;
//          If BoxDolar.Checked = False then
//           begin
//            CostoEx := 0;
//           end;
//          VImpuesto1      := True; //TableDBF.FieldByName('IMPUESTO').AsBoolean;;
//          CostoAnteriorBs :=  Costo;
//          CostoActualBs   := CostoAnteriorBs;
//          CostoPromedioBs := CostoAnteriorBs;
//          CostoAnteriorEx := CostoEx;
//          CostoActualEx   := CostoAnteriorEx;
//          CostoPromedioEx := CostoAnteriorEx;
//          MImpuesto1      := 16.0;
//          PorcentImp1     := True;
//          Excento1        := False; //TableDBF.FieldByName('EXCENTO').AsBoolean;;
//
//          //Asignando precios de Venta
//          For I:=1 to 3 do
//           With Precios[i] do
//            begin
//              PorcUtil    := True;
//               Case I of
//                  1 : SinImpuesto := E_Pvp1.AsFloat;
//                  2 : SinImpuesto := E_Pvp2.AsFloat;
//                  3 : SinImpuesto := E_Pvp3.AsFloat;
//               end { Case I };
//
//            Impuesto := 14.0 ;
//            Utilidad := 100;
//            MtoImpuesto1 := (SinImpuesto*Impuesto/100);
//            TotalPrecio := E_Pvp1+MtoImpuesto1;
//            TipoRound   := 0;
//
//          // Asignando Precios en Dólares
//          CostosProducto.Precios[1].TotalPrecioEx :=  E_CostoAnterior.AsFloat;
//          For H:= 1 to 3 do
//            begin
//              With Precios[H] do
//                PorcUtilEx := True;
//                  Case H of
//                    1 : TotalPrecioEx :=  E_Pvp1.AsFloat;
//                    2 : TotalPrecioEx :=  E_Pvp2.AsFloat;
//                    3 : TotalPrecioEx :=  E_Pvp3.AsFloat;
//                  end { Case H};
//              //UtilidadEx := TruncDecimalAllow(100-DivCero(CostoPromedioEx,TotalPrecioEx*100));
//              TotalPrecioEx := TotalPrecioEx;
//              TipoRound  := 0;
//            end;
//       end;
//   Try
//    SourceField   := FindField('FX_COSTOS');
//    BlobStreamData:= TDBISAMBlobStream.Create(TBlobField(SourceField),bmReadWrite);
//    BlobStreamData.Seek(0,0);
//    BlobStreamData.Truncate;
//    BlobStreamData.Write(CostosProducto,SizeOf(CostosProducto));
//   Finally
//    BlobStreamData.Free;
//   End;
//   Post;
//   end;
//end  ;
//end;
   // aca termina la copia del blob de precios
   MessageDlg('PRODUCTO INCLUIDO GRACIAS',MtInformation,[MbOk],0)
end;
end.

si necesitan el proyecto completo, con gusto lo envio.

Saludos.
Alexander Medina
Maracay/venezuela

Última edición por roman fecha: 08-08-2006 a las 21:47:53. Razón: Agregar etiquetas [delphi] para mayor legibilidad
Responder Con Cita