Ejemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TFrm1010::TreeMenuChange(TObject *Sender, TTreeNode *Node)
{
	SfgMenuInfo *MenuInfo;
	if (Node != NULL) {
      if (Node->Data != NULL) {
		   MenuInfo = (SfgMenuInfo*)Node->Data;
		   CadMenu->Locate("cod_rotina",Variant(MenuInfo->cod_rotina),TLocateOptions());
         ico_index->ItemIndex = CadMenu->FieldByName("ico_index")->AsInteger + 1;
      }
	}
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
void __fastcall TPrihodForm::ButtonInsertClick(TObject &Sender)
{
   if(!Document->Partner->ID_Partner)
   {
      ShowMessage("введите поставщика");
      return;
   }

   TTovarListForm * tlf = new TTovarListForm(this);
   tlf->ShowModal();
   if(!tlf->SelectedItem)
      return;
   TTovar * t = tlf->SelectedItem;
   
   TPrihod * p;
   Refresh();
   if(FrameList1->Query->Locate("id_tovar", t->ID_Tovar, TLocateOptions()<<loCaseInsensitive<<loPartialKey ))
      p = new TPrihod(FrameList1->Query->FieldByName("id_prihod")->AsInteger);
   else
      p = new TPrihod(0);
   p->ID_Tovar = t->ID_Tovar;
   p->ID_Partner = Document->Partner->ID_Partner;
   p->Nomer = Document->Nomer;
   p->DataDok = Document->DataDok;
   p->Cina = t->CinaZakup;
   float Kilxkist = 0;
   try
   {
      Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", "1"));
   }
   catch ( ... )
   {
      ShowMessage("введено неправильное количество!");
   }
   if(Kilxkist <= 0)
   {
      ShowMessage("количество не может быть нулевым или минусовым");
      delete p;
      delete t;
      delete tlf;
      return;
   }
   t->ID_Partner = Document->Partner->ID_Partner;
   t->Save();

   p->Kilxkist += Kilxkist;
   p->Save();
   delete p;
   delete t;
   delete tlf;
   Refresh();
   FrameList1->Query->Last();   
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void __fastcall TSfgVaPara::btOKClick(TObject *Sender)
{
   bool bRet;
   if(VaPara->Text.Length()){
      bRet = FDataSet->Locate(FPkField->FieldName, Variant(this->VaPara->Text), TLocateOptions());
   if(!bRet){
      MessageBox(Handle,"Registro não encontrado!","Vá Para",APP_INFORM);
      VaPara->SetFocus();
   }
   else{
      if(AfterGoToFind != NULL) {
         AfterGoToFind();
      }
      Close();
   }
 }
 else{
   MessageBox(Handle,"Entre com um código para efetuar a procura!","Vá Para",APP_ATENTION);
   VaPara->SetFocus();
 } 
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TNakladnaForm::ButtonInsertClick(TObject &Sender)
{
   if(!Document->Partner->ID_Partner)
   {
      ShowMessage("введите покупателя");
      return;
   }
   TTovarListForm * tlf = new TTovarListForm(this);
   tlf->ShowModal();
   if(!tlf->SelectedItem)
      return;
   TTovar * t = new TTovar(tlf->SelectedItem->ID_Tovar, Document->Partner->ID_Partner);
   if(!t->CinaProdazh)
   {
      delete t;
      t = tlf->SelectedItem;
   }

   TRashod * r;
   Refresh();
   if(FrameList1->Query->Locate("id_tovar", t->ID_Tovar, TLocateOptions()<<loCaseInsensitive<<loPartialKey ))
      r = new TRashod(FrameList1->Query->FieldByName("id_rashod")->AsInteger);
   else
      r = new TRashod(0);
   r->ID_Tovar = t->ID_Tovar;
   r->ID_Partner = Document->Partner->ID_Partner;
   r->Nomer = Document->Nomer;
   r->DataDok = Document->DataDok;
   float procent = cxSpinEditProcent->Value;
//   if(procent > 0)
      r->Cina = t->CinaProdazh-(t->CinaProdazh*(procent/(100+procent)));
//   else
//      r->Cina = t->CinaProdazh;
   float Kilxkist = 0;
   try
   {
      Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", "1"));
   }
   catch ( ... )
   {
      ShowMessage("введено неправильное количество!");
   }
   if(Kilxkist <= 0)
   {
      ShowMessage("количество не может быть нулевым или минусовым");
      delete r;
      delete t;
      return;
   }
   
   r->Kilxkist += Kilxkist;
   if(t->Ostatok < Kilxkist)
      ShowMessage("столько количества товара нету на складе");
   else
      r->Save();
   delete r;
   delete t;
   delete tlf;
   Refresh();
   FrameList1->Query->Last();
}
Ejemplo n.º 5
0
void __fastcall TForm1::ServerSocket1Accept(TObject *Sender,
      TCustomWinSocket *Socket)
{
     Timer1->Enabled=true;
     onEdit=true;
     String message = Socket->RemoteAddress;
     Memo1->Lines->Add("IP-адресс источника данных: "+message);
     int *a;
     int Bufer = Socket->ReceiveLength();
     char * Bufs = new char[Bufer+1];
     Socket->ReceiveBuf(Bufs, Bufer);

     int si=0;
     int k=0;
     String str[20];
     while(si<Bufer)
     {
          for (int i=si;i<Bufer;i++)
                        if((Bufs[i]=='/')||(i==Bufer-1))
                                {
                                  si=i+1;
                                  break;
                                } else str[k]+=Bufs[i];
        k++;
     }


     Bufs[Bufer+1]=' ';
     Bufs[Bufer]=' ';
     message=Bufs;

   bool flag=ADOTable1->Locate("Инвентарный номер",str[0],TLocateOptions()<<loCaseInsensitive);

    if((!flag)&&(k>8))
    {
     ADOTable1->Append();
     ADOTable1->FieldValues["Инвентарный номер"]=str[0];
     ADOTable1->FieldValues["Наименование"]=str[1];
     ADOTable1->FieldValues["Кабинет"]=str[2];
     ADOTable1->FieldValues["Подразделение"]=str[3];
     ADOTable1->FieldValues["РФ/РК"]=str[4];
     TDateTime CurrentDate = Date();
     ADOTable1->FieldValues["Дата инвентаризации"]=CurrentDate;
     ADOTable1->FieldValues["Дата списания"]=str[5];
     ADOTable1->FieldValues["Дата принятия"]=str[6];
     ADOTable1->FieldValues["Заводской номер"]=str[7];
     ADOTable1->FieldValues["Документ"]=str[8];
     ADOTable1->FieldValues["Состояние"]=str[9];
     ADOTable1->Post();
     Memo1->Lines->Add("Данные получены");
    }else
    {
      if(flag)Memo1->Lines->Add("Уже есть запись");
      if(k<8)Memo1->Lines->Add("Ошибка передачи, повторите попытку");
    }
    ADOQuery1->Active=false;
    ADOQuery1->SQL->Clear();
    AnsiString strSQL("SELECT Count(Главная.Наименование) AS [Количество], Наименование.Наименование FROM Наименование INNER JOIN Главная ON Наименование.Наименование = Главная.Наименование GROUP BY Наименование.Наименование HAVING (((Наименование.Наименование)=:ID));");
    ADOQuery1->SQL->Text=strSQL;
    ADOQuery1->Parameters->ParamByName("ID")->Value=str[1];
    ADOQuery1->Open();
    ADOQuery1->Active=true;
    ADOTable2->First();
    while(!ADOTable2->Eof) {
        if(ADOTable2->FieldByName("Наименование")->AsString==str[1])
        {
        ADOTable2->Edit();
        ADOTable2->FieldByName("Количество")->AsInteger = ADOQuery1->Fields->Fields[0]->AsInteger ;
        ADOTable2->Post();
        break;
        }
        ADOTable2->Next();
    }
    onEdit=false;
}