Var
  depoID: Integer;
  
procedure depoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
Var
  IDS: String;
begin 
  IDS:= SelectRecord(
     'SELECT ID, KARTNO, KOD, ACIKLAMA FROM TBLDEPOLAR WHERE DELETED = 0', 
     'KOD;ACIKLAMA', 
	 'Depo Kodu; Açıklama', 
	 'KARTNO', 
	 'Depo Kodu / Açıklama', 
	 'KOD;ACIKLAMA', 
	 False);
  if IDS <> '' Then
  Begin
    depoID:= strToInt(IDS);
    Self.depo.Text:= GetDBValue('SELECT KOD FROM TBLDEPOLAR WHERE KARTNO = ' + IDS);
  End;  
End;

procedure fFormShow(Sender: TObject);
Begin  
End;

procedure iptalClick(Sender: TObject);
begin
  Self.Close;
end;
  
procedure TamamClick(Sender: TObject);
Var
  D, S: Real;
Begin
  SaveDecimalSeperator;
  if (depoID > 0) and (self.miktar.Text <> '') Then
  Begin    
    S:= StrToFloat(self.Miktar.Text);
	
	D:= GetDBValue('Select DEPO from DEPOSTOKDURUMU WHERE DEPOID = ' + IntToSTr(depoID) + ' AND STOKID = ' + IntToStr(FIslemNo));
	
	if S <> D Then
	Begin
	  ExecSQL('INSERT INTO TBLSAYIM(BIRIMID, DEPOID, MIKTAR, TARIH, RENKID, BEDENID, DESENID) ' +
		' SELECT ANABIRIM, ' + INtToSTr(depoID) + ', ' + FloatToStr(S - D) + ', GETDATE(), 0, 0, 0 FROM TBLSTOKLAR WHERE KARTNO = ' + IntToStr(FIslemNo));
      ExecSQL('UPDATE TBLSTOKLAR SET' +
              '  GIREN = (Select SUM(GIREN) From STOKDURUMU WHERE STOKKARTNO = TBLSTOKLAR.KARTNO),' +
              '  CIKAN = (Select SUM(CIKAN) From STOKDURUMU WHERE STOKKARTNO = TBLSTOKLAR.KARTNO)');
	End;
  End;
  
  UpdateDecimalSeperator;
  self.Close;
End;

Begin
  self.depo.Properties.OnButtonClick:= @depoPropertiesButtonClick;
  self.miktar.Text:= '0'; 
  self.stokKodu.Caption:= GetDBValue('Select STOKKODU from TBLSTOKLAR WHERE KARTNO = ' + IntToStr(FIslemNo));
  self.Cinsi.Caption:= GetDBValue('Select CINSI from TBLSTOKLAR WHERE KARTNO = ' + IntToStr(FIslemNo));
End.
