Ir para conteúdo
Fórum Script Brasil

CorN_Sk8

Membros
  • Total de itens

    89
  • Registro em

  • Última visita

Posts postados por CorN_Sk8

  1. cara esse código que seis passaram ai tá muito ruim.... sem zuera...

    por exemplo

    if data.Caption='01/10/04' then a.Caption:='011004';
    if data.Caption='02/10/04' then a.Caption:='021004';
    if data.Caption='03/10/04' then a.Caption:='031004';
    if data.Caption='04/10/04' then a.Caption:='041004';
    if data.Caption='05/10/04' then a.Caption:='051004';
    if data.Caption='06/10/04' then a.Caption:='061004';
    if data.Caption='07/10/04' then a.Caption:='071004';
    if data.Caption='08/10/04' then a.Caption:='081004';
    ...

    isso poderia ser substituido por simplesmente isso StringReplace(Data.Caption, '/', '', [rfReplaceAll]) ou até mesmo FomatDateTime('DDMMYY', StrToDate(Data.Caption)); sem falar de outras formas que tambem dariam certo, em apenas 1 linha...

    Sugiro que antes que façam um atualizar do seu prog, estudem um pouco de lógica de prog., desculpe o modo de falar meu, parece um pouco ignorância...

    outro ponto, não utilizar o UrlMon.... use componentes como TIDHTTPClient da palheta indy, ou HttpClient da palheta ICS (www.overbyte.be)....

  2. para agilizar ainda mais o sistema utilize expressão regular,

    usando a função: int preg_match(string pattern, string subject, array [matches]);

    ficaria mais ou menos assim o código:

    <?
      $text = "http://www.google.com.br";
      if (preg_match("(?i)(FTP|HTTP[S])://([_a-z\d\-]+(\.[_a-z\d\-]+)+)((/[ _a-z\d\-\\\.]+)+)*", $text, $matchs)){
        for($x = 0; $x < $count($matchs); $x++){
          echo $match[$x][0] . "<br>";
        }
      }
    ?>

    a expressão pode ser (?i)((FTP|HTTP)://)?([_a-z\d\-]+(\.[_a-z\d\-]+)+)((/[ _a-z\d\-\\\.]+)+)*

    para poder pegar urls sem http:// ou ftp:// ou https:// mas não acho recomendável...

    espero ter ajudado... flws

  3. procedure TF_Cad_Orc.BitBtn9Click(Sender: TObject);
        begin
    with dados.Q_Kit do
    begin
    close;
    sql.clear;
    sql.add ('SELECT SUM (Kit_Total_Fin) AS TOTAL FROM TBL_Kit WHERE ID_ORCA = '+QuotedStr(dbedit60.text));
    ShowMessage(SQL.TEXT);
    open;
    

    vai aparecer uma mensagem com a query veja se está tudo OK

  4. se for o que eu to pensando, vai ficar enorme mesmo, o tamanho é proporcial a resolução, a melhor solução é desenvolver softwares para 800x600 que quando voce mudar para 1024x768 fica normal ...

    um botao de 25x25 em 1024x768 não é nada mais em 800x600 ele vira um botaozaooo justamente porque a tela tem menos pixels

  5. você tem que ligar elas, relacionar, exemplo:

    Tabela Clientes

    ------------------

    Codigo

    Nome

    Tabela Produtos

    ------------------

    Codigo

    Nome

    Preço

    Tabela Vendas

    ------------------

    Codigo

    CodCliente

    CodProduto

    Quantidade

    ai sua query vai ficar assim:

    Select * from Clientes C, Produtos P, Vendas V where V.CodCliente = C.Codigo and V.CodProduto  = P.Codigo

    legal né ?

  6. pronto, terminei.

    Unit1.pas

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Image1: TImage;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        procedure Load;
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      BMP: TBitmap;
      P: TPoint;
      P_Clicked: TPoint;
      Clicked: Boolean = false;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Load;
    var
      MyRect, MyOther: TRect;
      X, Y: Integer;
    begin
      if Image1.Width > BMP.Width then
        X := (Image1.Width - BMP.Width) div 2
      else X := 0;
    
      if Image1.Height > BMP.Height then
        Y := (Image1.Height - BMP.Height) div 2
      else Y := 0;
    
      MyRect := Rect(P.X, P.Y, P.X + Image1.Width, P.Y + Image1.Height);
    
      MyOther := Rect(X,Y,Image1.Width, Image1.Height);
      Image1.Canvas.CopyRect(MyOther,BMP.Canvas,MyRect);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      P.X := 0;
      P.Y := 0;
    
      BMP := TBitmap.Create;
      BMP.LoadFromFile('C:\teste.bmp');
    
      Load;
    end;
    
    procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if BMP = nil then exit;
    
      P_Clicked.X := X;
      P_Clicked.Y := Y;
    
      Clicked := True;
    end;
    
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if Clicked = false then exit;
      
      P.X := P.X + (X - P_Clicked.X);
      P.Y := P.Y + (Y - P_Clicked.Y);
    
      if P.X < 0 then
        P.X := 0
      else if P.X > BMP.Width - Image1.Width then
        P.X := BMP.Width - Image1.Width;
    
      if P.Y < 0 then
        P.Y := 0
      else if P.Y > BMP.Height - Image1.Height then
        P.Y := BMP.Height - Image1.Height;
    
      if Image1.Width > BMP.Width then
        P.X := 0;
    
      if Image1.Height > BMP.Height then
        P.Y := 0;
    
      P_Clicked.X := X;
      P_Clicked.Y := Y;
    
      Load;
    end;
    
    procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      Clicked := False;
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      DoubleBuffered := True;
    end;
    
    end.

  7. com ó codigo é bem mais facil ajuda

    Writes to a text file and adds an end-of-line marker

    Unit

    System

    Category

    text file routines

    procedure Writeln([ var F: Text; ] P1 [, P2, ...,Pn ] );

    Description

    Writeln is an extension to the Write procedure, as it is defined for text files.

    After executing Write, Writeln writes an end-of-line marker (carriage return/line feed) to the file. Writeln(F) with no parameters writes an end-of-line marker to the file. (Writeln with no parameter list corresponds to Writeln(Output).)

    The file must be open for output.

    Note: When an application is compiled as a console application (using the Generate console application checkbox on the Linker page of the Project|Options dialog, or a -cc command line switch with the command-line compiler), Delphi automatically associates the Input and Output files with the application's console window. For non-console applications, any attempt to read from Input or write to Output will generate an I/O error.

  8. Unit1.pas

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Image1: TImage;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        procedure Load;
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      BMP: TBitmap;
      P: TPoint;
      P_Clicked: TPoint;
      Clicked: Boolean = false;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Load;
    var
      MyRect, MyOther: TRect;
    begin
    
      MyRect := Rect(P.X, P.Y, P.X + Image1.Width, P.Y + Image1.Height);
    
      MyOther := Rect(0,0,Image1.Width, Image1.Height);
      Image1.Canvas.CopyRect(MyOther,BMP.Canvas,MyRect);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      P.X := 0;
      P.Y := 0;
    
      BMP := TBitmap.Create;
      BMP.LoadFromFile('C:\teste.bmp');
    
      Load;
    end;
    
    procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      P_Clicked.X := X;
      P_Clicked.Y := Y;
    
      Clicked := True;
    end;
    
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if Clicked = false then exit;
      
      P.X := P.X + (X - P_Clicked.X);
      P.Y := P.Y + (Y - P_Clicked.Y);
    
      if P.X < 0 then
        P.X := 0
      else if P.X > BMP.Width - Image1.Width then
        P.X := BMP.Width - Image1.Width;
    
      if P.Y < 0 then
        P.Y := 0
      else if P.Y > BMP.Height - Image1.Height then
        P.Y := BMP.Height - Image1.Height;
    
      P_Clicked.X := X;
      P_Clicked.Y := Y;
    
      Load;
    end;
    
    procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      Clicked := False;
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      DoubleBuffered := True;
    end;
    
    end.
    Unit1.dfm
    object Form1: TForm1
      Left = 192
      Top = 107
      Width = 696
      Height = 480
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Image1: TImage
        Left = 8
        Top = 8
        Width = 521
        Height = 433
        Cursor = crHandPoint
        OnMouseDown = Image1MouseDown
        OnMouseMove = Image1MouseMove
        OnMouseUp = Image1MouseUp
      end
      object Button1: TButton
        Left = 536
        Top = 40
        Width = 75
        Height = 25
        Caption = 'Abrir'
        TabOrder = 0
        OnClick = Button1Click
      end
    end
    

  9. procedure TfrmInsereCliente.btnInsereClick(Sender: TObject);
    
    begin
    if ncadastro.Text = '' then
    begin
    showmessage('Favor colocar o nome');
    end
    else if fcadastro.Text = '' then
    begin
    showmessage('Favor colocar o telefone');
    end
    else
    datamodule1.AdoQuery.Close;
    datamodule1.AdoQuery.SQL.Clear;
    datamodule1.AdoQuery.SQL.Add('Insert Into Clientes(idCliente,Nome,Fone)');
    datamodule1.AdoQuery.SQL.Add('Values('+inttostr(id)+','+quotedstr(ncadastro)+','+quotedstr(fcadastro)); // Aqui dá o erro
    datamodule1.AdoQuery.Open;
    end;
    end.

  10. ou assim

    <?
    
    echo "<select name=\"categoria\">";
    
    $conexao = mysql_connect("localhost", "root", "");
    mysql_select_db("biblio", $conexao);
    $sql="SELECT nome FROM aux_categoria";
    $result = mysql_query($sql,$conexao) or die(mysql_error());
    
    while ($s = mysql_fetch_array($result)) {
      echo "<option value=\"" . $s['nome'] "\">" . $ver . "</option>";
    }
    
    echo "</select>";
    ?>

  11. bom vou tentar fazer uma coisa mais mastigada para você

    function SubtrairTemp($tmpFinal, $tmpInicial){ //Calcular Final - Inicial, formato HH:NN:SS
      $tmpFinal = explode(":", $tmpFinal);
      $ss_fn = ($tmpFinal[0] * 3600) + ($tmpFinal[1] * 60) + ($tmpFinal[2]);
    
      $tmpInicial = explode(":", $tmpInicial);
      $ss_in = ($tmpInicial[0] * 3600) + ($tmpInicial[1] * 60) + ($tmpInicial[2]);
    
      $ss_rs = $ss_fn - $ss_in;
    
      // Agora formata novamente a data ...
    
      $nn_rs = 0;
      $hr_rs = 0;
    
      while($ss_rs > 59){
        $ss_rs = $ss_rs - 60;
        $nn_rs = $nn_rs + 1;
        if($nn_rs>=60){
          $nn_rs = 0;
          $hr_rs = $hr_rs + 1;
        }
      }
      return $hr_rs . ":" . $nn_rs . ":" . $ss_rs
    }

    na verdade fuii fazendo aqui nem testei, mas axo q ta certo

×
×
  • Criar Novo...