⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsgudang.pas

📁 this is sample for traders
💻 PAS
字号:
unit lsGudang;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, JvExDBGrids, JvDBGrid, JvDBUltimGrid, Buttons,
  JvExControls, JvStaticText, StdCtrls, Mask, SkinBoxCtrls, SkinCtrls, DB,
  DynamicSkinForm, ComCtrls, JvExComCtrls, JvStatusBar, JvGradientCaption,
  Menus, JvMenus, ImgList;

type
  TlsGudangForm = class(TForm)
    spSkinGroupBox1: TspSkinGroupBox;
    RadioGroup1: TspSkinRadioGroup;
    AddBtn: TSpeedButton;
    ItemGrid: TJvDBUltimGrid;
    dsGudang: TDataSource;
    StBAR: TJvStatusBar;
    JvPopupMenu1: TJvPopupMenu;
    EditUbahRecordItem1: TMenuItem;
    N1: TMenuItem;
    ViewSaldoInventoryItemPenjualan: TMenuItem;
    IL1: TImageList;
    spSkinGroupBox2: TspSkinGroupBox;
    edFind: TEdit;
    spDynamicSkinForm1: TspDynamicSkinForm;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure dsGudangDataChange(Sender: TObject; Field: TField);
    procedure edFindChange(Sender: TObject);
    procedure AddBtnClick(Sender: TObject);
    procedure EditUbahRecordItem1Click(Sender: TObject);
    procedure ViewSaldoInventoryItemPenjualanClick(Sender: TObject);
  private
    procedure EditRec;
  public
  end;

var
  lsGudangForm: TlsGudangForm;

implementation

{$R *.dfm}

uses DataMod1, FuncLib, edGudang, itemSaldo ;

procedure TlsGudangForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TlsGudangForm.FormCreate(Sender: TObject);
begin
  Top:=1; Left:=1;
  DateSeparator := '-'; ShortDateFormat := 'dd/mm/yyyy';
  //DM1.qGudang.Open;
end;

procedure TlsGudangForm.FormActivate(Sender: TObject);
begin
  if (DM1.qGudang.State <> dsInActive) then RefreshRec(DM1.qGudang);
  edFind.SetFocus;
end;

procedure TlsGudangForm.RadioGroup1Click(Sender: TObject);
begin
  if RadioGroup1.ItemIndex = 0 then
  begin
    edFind.MaxLength := 6;
    DM1.qGudang.IndexFieldNames:='GDGCODE';
  end else
  begin
    edFind.MaxLength := 30;
    DM1.qGudang.IndexFieldNames:='GDGNAME';
  end;
  edFind.Clear;
  edFind.SetFocus;
end;

procedure TlsGudangForm.dsGudangDataChange(Sender: TObject; Field: TField);
begin
  stBAR.Panels[0].Text := '' + FormatFloat('#,##0',DM1.qGudang.RecordCount)+' Records';
end;

procedure TlsGudangForm.edFindChange(Sender: TObject);
var
  sqltext: String;
begin
  if edFind.Text='' then Exit;
  QueryPerformanceFrequency(Frequency);
  QueryPerformanceCounter(start);
  with DM1.qGudang do
  begin
    Close;
    SQL.Clear;
    if RadioGroup1.ItemIndex = 0 then
    begin
        sqltext:=('SELECT * ')+
                 ('FROM ITEM_GUDANG ')+
                 ('WHERE GDGCODE LIKE :NCari ')+
                 ('ORDER BY GDGCODE, GDGNAME ASC ');
    end else
    begin
        sqltext:=('SELECT * ')+
                 ('FROM ITEM_GUDANG ')+
                 ('WHERE GDGNAME LIKE :NCari ')+
                 ('ORDER BY GDGNAME, GDGCODE ASC ');
    end;
    SQL.Text:=sqltext;
    Params.ParamByName('NCari').Value:=edFind.Text+'%';
    Open;
    if (Recordcount = 0) and (RadioGroup1.ItemIndex = 0) then
    AddBtn.Enabled := True else AddBtn.Enabled := False;
    EnableControls;
  end;
  QueryPerformanceCounter(stop);
  stBAR.Panels[1].Text := ''+format('%.2f',[(stop-start)/frequency])+' detik';
end;

procedure TlsGudangForm.AddBtnClick(Sender: TObject);
begin
  with DM1.qGudangEdit do
  begin
    Close;
    SQL.Text:='SELECT * FROM ITEM_GUDANG WHERE GDGCODE=:GDGCODE ';
    Params.ParamByName('GDGCODE').Value:=edFind.Text;
    Open;
  end;
  if DM1.qGudangEdit.RecordCount<>0 then
  MessageDlg('KODE sudah ada ...',mtWarning,[mbOk],0) else
  edGudangForm.Enter(edFind.Text);
  edFind.Clear;
  RefreshRec(DM1.qGudang);
end;

procedure TLsGudangForm.EditRec;
begin
  with DM1.qGudangEdit do
  begin
    Close;
    Open;
  end;
  edGudangForm.Edit;
  RefreshRec(DM1.qGudang);
end;

procedure TlsGudangForm.EditUbahRecordItem1Click(Sender: TObject);
begin
  EditRec;
end;

procedure TlsGudangForm.ViewSaldoInventoryItemPenjualanClick(
  Sender: TObject);
begin
  {with SQLp do
  begin
    Clear;
    sqltext:= 'DROP TABLE IF EXISTS itemqty_per_gdg; '+
              'CREATE TABLE IF NOT EXISTS itemqty_per_gdg (PRINT tinyint(1) unsigned NOT NULL default 0) '+
              'SELECT item.*, '+
              'IFNULL((SELECT opbal from item_qty where item.itemcode=itemcode and gdgcode=:gdgcode),0) as OPBAL, '+
              'IFNULL((SELECT onhand from item_qty where item.itemcode=itemcode and gdgcode=:gdgcode),0) as ONHAND '+
              'FROM item '+
              'ORDER BY ITEMCODE ASC ; '+
              'ALTER TABLE itemqty_per_gdg ADD PRIMARY KEY (ITEMCODE) ;';
    Script.Add(sqltext);
    Params.ParamByName('gdgcode').Value:=DM1.qGudang.FieldByName('GDGCODE').Value;
    Execute;
  end;
  }
  {with DM1.qItemQTY do
  begin
    Close;
    SQL.Clear;
    sqltext:=
    ('SELECT * ')+
    ('FROM item_qty WHERE gdgcode=:gdgcode ORDER BY ITEMCODE ASC ');
    SQL.Text:=sqltext;
    Params.ParamByName('gdgcode').Value:=DM1.qGudang.FieldByName('GDGCODE').Value;
    Open;
  end;
  }
  ItemSaldoForm.Enter(DM1.qGudang.FieldByName('GDGCODE').Value,DM1.qGudang.FieldByName('GDGNAME').Value);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -