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

📄 soh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            }
          break;
     case euSdSsite:
          if(ShowUpdateMessage(MsgSrc,MsgType))
           {
            KeyCode=seSohSsite->ItemData[cbItem2];
            FillEdit(seSohSsite,"select SsiteName,SsiteCode from sdSsite","SsiteName","SsiteCode");
            seSohSsite->LocateKey(KeyCode);
            }
          break;

    //Sod
     case euSdUnit:
          if(ShowUpdateMessage(MsgSrc,MsgType))
           {
            KeyCode=seSodUnit->ItemData[cbItem2];
            FillEdit(seSodUnit,"SELECT UnitCode,UnitName FROM sdUnit","UnitName","UnitCode");
            seSodUnit->LocateKey(KeyCode);
            }
          break;
     case euSdSpt:
          if(ShowUpdateMessage(MsgSrc,MsgType))
            {
            KeyCode=seSodSptCode->ItemData[cbItem2];
            FillEdit(seSodSptCode,"SELECT SptCode,SptName FROM sdSpt","SptName","SptCode");
            seSodSptCode->LocateKey(KeyCode);
            }
          break;
     case euSdCurrency:
          if(ShowUpdateMessage(MsgSrc,MsgType))
            {
            KeyCode=seSohCurrency->ItemData[cbItem2];
            AnsiString sSql;
            sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
            sSql+=" where currencycode*=ratecurrency and ";
            sSql+=" ratefmonth='"+g_sdSMonth+"'";
            FillEdit(seSohCurrency,sSql,"CurrencyName","CurrencyCode","CurrencyRate","CurrencyLocal");
            seSohCurrency->LocateKey(KeyCode);
            }
          break;
    }
}
void __fastcall TfrmSoh::seSohCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(WideString(seSohCode->Text));
      DisplayBill();
    }

}
//---------------------------------------------------------------------------


void __fastcall TfrmSoh::seSohClientButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[客户编码][客户名称][客户地址]select Clientcode,Clientname,Clientaddr from sdClient where clientcancel=0 order by Clientcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"客户资料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSohClient->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSohCurrencyButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[货币代码][货币名称]select Currencycode,CurrencyName from sdCurrency,sdssd where ssdCurrency=CurrencyCode and ";
  SqlStr+="ssdClient='"+seSohClient->ItemData[cbItem2]+"' order by CurrencyCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"客户货币查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    if(seSohCurrency->LocateKey(p->ColData[1]))
    {
      if(seSohCurrency->ItemData[cbItem4]=="1")
      {
        seSohEnrate->Enabled=false;
        seSohEnrate->Text="1";
      }
      else
      {
        seSohEnrate->Enabled=true;
        seSohEnrate->Text=seSohCurrency->ItemData[cbItem3];
      }
    }
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodDiscExit(TObject *Sender)
{
  CalculateAmt();
}
//---------------------------------------------------------------------------


void __fastcall TfrmSoh::SetRelativeState(AnsiString GoodsCode)
{
  int IsFound=g_sdRsGoods->LocateByKey(WideString(Trim(GoodsCode)));
  if(IsFound != 0)
    return;
  seSodGoods->Text=GetGoodsValue("GoodsCode");
  seSodGoodsName->Text=GetGoodsValue("GoodsName");
 if(CurrentState!=caNormal)
 {
  seSodUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
  seSodConv->Text="1";
  if(GetGoodsValue("GoodsMUnit")=="0")
  {
    seSodUnit->Enabled=false;
    seSodConv->Enabled=false;
  }
  else
  {
    seSodUnit->Enabled=true;
    seSodConv->Enabled=true;
  }
 }
}

void __fastcall TfrmSoh::seSohSsiteButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[货运地址代码][货运地址名称][联系人]select SsiteCode,SsiteName,Ssitelinkman from sdSsite where ";
  SqlStr+="SsiteClient='"+seSohClient->ItemData[cbItem2]+"' order by SsiteCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货运地址查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSohSsite->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodSptCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[价格类型代码][价格类型名称]select SptCode,SptName from sdSpt order by SptCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"销售价格查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSodSptCode->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodQtyButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  TfrmWnQuery *p;
  SqlStr="004[当前月份][计量单位][库位][库存数量]";
  SqlStr+="select MaccFmonth,GoodsUnitCode,MaccLoc,MaccAoyQty from sdMacc,sdGoods where MaccGoods=GoodsCode and ";
  SqlStr+=" MaccFmonth='"+g_sdSMonth+"' and MaccGoods='"+seSodGoods->Text+"'";
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"当前库存查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  p->ShowModal();
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodPriceButtonClick(TObject *Sender)
{
  if(seSodQty->Text.ToDouble()<=0)
     throw Exception("先输入有效订单数量");
  AnsiString SqlStr;
  TfrmWnQuery *p;
  SqlStr="004[启始数量段][终止数量段][价格][折扣]";
  SqlStr+="select f0=0,f1=squoteqty1,f2=squoteprice1,f3=squoterebate1 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty1,f1=squoteqty2,f2=squoteprice2,f3=squoterebate2 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty2,f1=squoteqty3,f2=squoteprice3,f3=squoterebate3 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty3,f1=squoteqty4,f2=squoteprice4,f3=squoterebate4 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty4,f1=squoteqty5,f2=squoteprice5,f3=squoterebate5 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty5,f1=squoteqty6,f2=squoteprice6,f3=squoterebate6 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty6,f1=squoteqty7,f2=squoteprice7,f3=squoterebate7 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty7,f1=squoteqty8,f2=squoteprice8,f3=squoterebate8 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty8,f1=squoteqty9,f2=squoteprice9,f3=squoterebate9 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"' union all ";
  SqlStr+="select f0=squoteqty9,f1=squoteqty10,f2=squoteprice10,f3=squoterebate10 from sdsquote where squoteclient='"+seSohClient->ItemData[cbItem2]+"' and squotecurrency='"+seSohCurrency->ItemData[cbItem2]+"' and squotegoods='"+seSodGoods->Text+"'";
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"产品报价单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
   seSodPrice->Text=p->ColData[3];
   seSodDisc->Text=p->ColData[4];
   CalculateAmt();
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::CalculateAmt()
{
  double FAmt,FTaxAmt,FVal,FTaxRate,FDiscAmt;
  if(scSohTaxCode->ItemIndex!=-1)
    FTaxRate=scSohTaxCode->ItemData[cbItem3].ToDouble();
  FVal=DataCarry(seSodQty->Text.ToDouble()*seSodPrice->Text.ToDouble(),2,0);
  FAmt=DataCarry(FVal/(1+FTaxRate),2,0);
  FTaxAmt=FVal-FAmt;//DataCarry(FAmt*FTaxRate,2,0);
  FDiscAmt=DataCarry((FAmt+FTaxAmt)*(seSodDisc->Text.ToDouble()),2,0);
  seSodAmt->Text=FAmt;
  seSodTaxAmt->Text=FTaxAmt;
  seSodDAmt->Text=FDiscAmt;
}
void __fastcall TfrmSoh::seSodUnitButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr ="003[计量单位][单位名称][换算系数]";
    SqlStr+="SELECT GmuUnit,UnitName,GmuConv from sdGmu,sdUnit where GmuUnit=UnitCode and ";
    SqlStr+="GmuGoods='"+seSodGoods->Text+"' order by GmuUnit ";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"计量单位查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      seSodUnit->LocateKey(p->ColData[1]);
      seSodConv->Text=p->ColData[3];
    }
    delete p;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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