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

📄 pish.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    AnsiString S;
    S = ReadFieldValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPish::GetDetailValue(int Index)
{
    AnsiString S;
    S = ReadItemValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::FormCreate(TObject *Sender)
{
//    FormIniFile="D:\Test.Ini";
//    SetGridWidth(Name,sgPish,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgPish,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::FormShow(TObject *Sender)
{
//    InitEditControl();
    ClearControl(1,false);
    ClearControl(2,false);
    TGenBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::sgPishSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow > 0)
    {
       comServer->LocateItemByKey(WideString(sgPish->TextMatrix[ARow][1]));
    }
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::ChangeToBrowseState(bool agree)
{
       sgPish->Visible=true;
       FloatPanel2->Visible=false;
       if(agree==false)
        sgPish->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::btnOKClick(TObject *Sender)
{
  try
  {
    if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
    {
      if(DetailState==caAddDetail)
       comServer->AddItem();
      SendDataToComObject(2);
      comServer->AddToObject();
      ClearControl(2,false);
      sePisdGoods->SetFocus();
    }
    else
      ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------


void __fastcall TfrmPish::GenrateBill()
{
    int TempCount;
    if(scPishType->ItemIndex==4)
      throw Exception("入库类型为<其它入库>时没有生成功能!");
    TempCount = comServer->ItemCount;
    StartWaitForm("正在启动生成界面");
    TfrmPisd *p=new TfrmPisd(this);
    try
    {
      p->GetComObject(comServer);
      EndWaitForm();
      p->ShowModal();
      if (TempCount < comServer->ItemCount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    }
    __finally
    {
      delete p;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::sgPishDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgPish->Row;
    if (iRow == 0)
    {
       return;
    }
    sgPish->Visible=false;
    FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::sePisdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]";
  SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods where goodscancel=0 and ";
  if(scPishType->ItemIndex==0)
    SqlStr+=" goodsfrom=1 and goodsstate=2 order by goodscode";
  else if(scPishType->ItemIndex==1)
    SqlStr+=" goodsfrom=2 and goodsstate=2 order by goodscode";
  else if(scPishType->ItemIndex==2)
    SqlStr+=" goodssale=1 and goodsstate=2 order by goodscode";
  else if(scPishType->ItemIndex==3)
    SqlStr+=" goodstype<>1 and goodsstate=2 order by goodscode";
  else if(scPishType->ItemIndex==4)
    SqlStr+=" goodsstate=2 order by goodscode";

  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    sePisdGoods->Text=p->ColData[1];
    SetDetail(sePisdGoods->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------


void __fastcall TfrmPish::sePisdGoodsExit(TObject *Sender)
{
 SetDetail(Trim(sePisdGoods->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
    case euSdFc:
      if(ShowUpdateMessage(MsgSrc,MsgType))
      {
        FillComboBox(scPishFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
      }
      break;
   case euSdPosType:
      if(ShowUpdateMessage(MsgSrc,MsgType))
      {
        FillComboBox(scPishPosType,"select postypename memo,postypecode from sdPosType  order by PosTypeCode","memo","PosTypeCode");
      }
    break;
   case euSdKeeper:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scPishKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPisdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(sePisdLoc,"select locname memo,loccode from sdloc where LocType=1 order by LocCode","memo","LocCode");
    }
    break;
   case euSdBatch:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPisdBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::scPishTypeChange(TObject *Sender)
{
  if(scPishType->ItemIndex==4 )
    tbGenDetail->Enabled=false;
  else
    tbGenDetail->Enabled=true;
}
//---------------------------------------------------------------------------


void __fastcall TfrmPish::BackDisp()
{
  double dQty,dPrice,dAmt;
  if(sePisdQty->Text != "" && sePisdPrice->Text != "")
  {
   dQty=StrToFloat(sePisdQty->Text);
   dPrice=StrToFloat(sePisdPrice->Text);
   dAmt=dQty*dPrice;
   sePisdAmt->Text=DataCarry(dAmt,2,0);
  }
}

void __fastcall TfrmPish::sePisdQtyExit(TObject *Sender)
{
  BackDisp();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPish::SetDetail(AnsiString gc)
{
  int IsFound=g_sdRsGoods->LocateByKey(WideString(gc));
  if(IsFound != 0) //输入无效编码
  {
   sePisdGoods->Text=pv_GoodsCode;
   return;
  }
  sePisdGoods->Text=GetGoodsValue("GoodsCode");
  pv_GoodsCode=GetGoodsValue("GoodsCode");
  labPisdGoodsName->Caption=GetGoodsValue("GoodsName");
  scPisdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
  SetDetailValue(fiPisdGoods,sePisdGoods->Text);
  if(GetGoodsValue("GoodsTrackSo")=="0")
  {//该物料不跟踪订单,则锁定销售单号和行号
    sePisdSod->Enabled=false;
    sePisdSodLine->Enabled=false;
    sePisdSod->Text="";
    sePisdSodLine->ItemIndex=-1;
  }
  else
  {
    sePisdSod->Enabled=true;
    sePisdSodLine->Enabled=true;
  }
  if(GetGoodsValue("GoodsBatch")=="0")
  {//该物料不采用批次管理,则锁定批号
    scPisdBatch->Enabled=false;
    scPisdBatch->ItemIndex=-1;
  }
  else
  {
    scPisdBatch->Enabled=true;
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::sePisdLocButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc,sdLg where LocCode=lgLocCode and lgState=1 and ";
  SqlStr+=" LocType=1 and lggoodscode='"+sePisdGoods->Text+"' order by LocCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"入库货位查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    sePisdLoc->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::sePisdSodButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="005[订单号][订单行号][客户名称][物料编码][物料名称]select sohcode,sodline,ClientName,sodgoods,goodsname from sdsoh,sdclient,sdsod,sdgoods";
  SqlStr+=" where sohcheck=1 and sohclient=clientcode  and sohcode=sodcode and sodgoods=goodscode and sodgoods='"+sePisdGoods->Text+"' order by sohcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"订单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    sePisdSod->Text=p->ColData[1];
    sePisdSodLine->Text=p->ColData[2];
  }
  delete p;
        
}
//---------------------------------------------------------------------------

void __fastcall TfrmPish::sePishCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && sePishCode->Text != GetHeadValue(fiPishCode))
    {
      comServer->LocateByKey(WideString(sePishCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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