Ver Mensaje Individual
  #6  
Antiguo 11-06-2018
benegas benegas is offline
Registrado
NULL
 
Registrado: jun 2018
Posts: 5
Reputación: 0
benegas Va por buen camino
aqui tienes el codigo completo. tambien pense en os separador decimal, pero no lo estoy usando. ybual da em mismo error

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Mask;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    MaskEdit1: TMaskEdit;
    Label4: TLabel;
    Combo1: TComboBox;
    Label5: TLabel;
    cotiza: TEdit;
    Label6: TLabel;
    lista: TListBox;
    lista2: TListBox;
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    encomienda: TEdit;
    viatico: TEdit;
    gastoadm: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label7: TLabel;
    total: TEdit;
    GroupBox2: TGroupBox;
    radio1: TRadioButton;
    Radio2: TRadioButton;
    GroupBox3: TGroupBox;
    Label8: TLabel;
    Label9: TLabel;
    descuento: TEdit;
    incremento: TEdit;
    Label10: TLabel;
    Label11: TLabel;
    tp: TEdit;
    tpotra: TEdit;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure Combo1Change(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure radio1Click(Sender: TObject);
    procedure Radio2Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
valor: string;
i: integer;
begin
i:=1;
  while (i<=4) do
    begin
      valor:=inputbox('Productos','Ingrese Productos','Ingresar');
      lista.items.add(valor);
      i:= i+1;
      end;

end;

procedure TForm1.Button6Click(Sender: TObject);
begin
if application.MessageBox('DESEA SALIR ?',
  'ATENCION !!!', MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) = IDYES THEN
  close;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
num: string;
var
  s, pre: real;
i:integer;
begin
i:= 1;
  while (i<=4) do
    begin
      num:=inputbox('Precio','Ingrese Precio','Ingresar');
      lista2.Items.Add(num);
      pre:= strtofloat(num);
      s:= s+pre;
      i:= i+1;
      end;
      total.text:= floattostr(s);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if lista.ItemIndex= -1 then
  begin
  showmessage('Seleccionar un Item');
  exit;
  end;
  lista.Items.Delete(lista.ItemIndex);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if lista2.ItemIndex= -1 then
  begin
  showmessage('Seleccionar un Item');
  exit;
  end;
  lista2.Items.Delete(lista2.ItemIndex);
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
var
  e:real;
begin
  if CheckBox1.checked = true then
    begin
      e:=30000;
      encomienda.Color:=clWhite;
      encomienda.text:=floattostr(e);

    end
  else if CheckBox1.checked = false then
    begin
      encomienda.Color:=clYellow;
      encomienda.text:=' ';
    end;

end;

procedure TForm1.CheckBox2Click(Sender: TObject);
var
  v:real;
begin
  if CheckBox2.checked = true then
    begin
      v:=50000;
      viatico.Color:=clWhite;
      viatico.text:=floattostr(v);

    end
  else if CheckBox2.checked = false then
    begin
      viatico.Color:=clYellow;
      viatico.text:='';
    end;

end;

procedure TForm1.CheckBox3Click(Sender: TObject);
var
  g:real;
begin
  if CheckBox3.checked = true then
    begin
      g:=10000;
      gastoadm.Color:=clWhite;
      gastoadm.text:=floattostr(g);
    end
  else if CheckBox3.checked = false then
    begin
      gastoadm.Color:=clYellow;
      gastoadm.text:='';
    end;
end;

procedure TForm1.Combo1Change(Sender: TObject);
var
  n:integer;
begin
  n:= combo1.ItemIndex;
  if (n = 0) then
    cotiza.Text:= '5500';
  if (n = 1) then
    cotiza.Text:= '1500';

end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  combobox1.Text:= ' ';
  combobox2.Text:= ' ';
  maskedit1.Text:= ' ';
  combo1.Text:= ' ';
  cotiza.Text:= ' ';
  lista.clear;
  lista2.clear;
  CheckBox1.Checked := false;
  CheckBox2.Checked := false;
  CheckBox3.Checked := false;
  radio1.checked := true;
  radio2.checked := false;
  total.text:= ' ';
  descuento.Text:= ' ';
  incremento.text:= ' ';
  tp.Text:= ' ';
  tpotra.Text:= ' ';
  combobox1.SetFocus;
end;

procedure TForm1.radio1Click(Sender: TObject);
begin
  if (radio1.Checked=true) then
    begin
      descuento.Enabled:= true;
      descuento.Color:=clWhite;
      incremento.enabled:= false;
      incremento.Color:=clYellow;
      end;
end;

procedure TForm1.Radio2Click(Sender: TObject);
begin
  if (radio2.Checked=true) then
    begin
      descuento.Enabled:= false;
      descuento.Color:=clYellow;
      incremento.Enabled:= true;
      incremento.Color:=clWhite;
      end;
end;

procedure TForm1.Button7Click(Sender: TObject);
var
  a,b,c,tpro,des,cot,inc,tpom,t,tpgs:real;
begin
  des:=strtofloat (descuento.text);
  inc:=strtofloat(incremento.Text);
  a:=strtofloat(encomienda.text);
  b:=strtofloat(viatico.text);
  c:=strtofloat(gastoadm.text);
  tpro:=strtofloat(total.text);
  t:= a+b+c+tpro;

  if (descuento.Enabled=true) then
  
    tpgs:= t-des;

  if(incremento.enabled=true) then
   begin
    tpgs:= t+inc;
   end;
  
  tp.text:= floattostr(tpgs);
  cot:= strtofloat(cotiza.text);
  tpom:= tpgs/cot;
  tpotra.text:=floattostr(tpom);
  
end;

end.
Responder Con Cita