//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "MainCpp.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
const char *HanDigiStr[] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
        : TForm(Owner)
{
  TIniFile *pIniFile = new TIniFile(".\\医院票据坐标.ini");

  for (int i=0;i<56;i++)
   { Edits="Edit"+String(i);
    Edit[i][0]=pIniFile->ReadInteger(Edits, "Left",110);
    Edit[i][1]=pIniFile->ReadInteger(Edits, "Top",110);
   }
   FontSize=pIniFile->ReadInteger("Font", "Size",14);
   Pagelength=pIniFile->ReadInteger("Page", "Pagelength",1200);
   Pagewidth=pIniFile->ReadInteger("Page", "Pagewitch",2600);
   Edit53->Text=pIniFile->ReadString("Name","复核"," ");
   Edit54->Text=pIniFile->ReadString("Name","审核"," ");
   Edit55->Text=pIniFile->ReadString("Name","受理"," ");
   delete pIniFile;
   ADevice =new char[100];
   ADriver =new char[100];
   APort =new char[100];
   Prntr = Printer();
   xdpi=GetDeviceCaps(Prntr->Handle,LOGPIXELSX);
   ydpi=GetDeviceCaps(Prntr->Handle,LOGPIXELSY);
   ldpi=GetDeviceCaps(Prntr->Handle,PHYSICALOFFSETX);
   tdpi=GetDeviceCaps(Prntr->Handle,PHYSICALOFFSETY);
   xDouble=xdpi/254;
   yDouble=ydpi/254;
   //获取打印机
   Prntr->GetPrinterA(ADevice, ADriver, APort,DeviceMode);
   //获取PDevMode结构
  DevMode =(_devicemodeA*) GlobalLock((void *)DeviceMode);
  //设定可以修改的值
  DevMode->dmFields=DevMode->dmFields|DM_PAPERSIZE;
  DevMode->dmFields=DevMode->dmFields|DM_PAPERLENGTH;
  DevMode->dmFields=DevMode->dmFields|DM_PAPERWIDTH;
  //设定要修改的值
  DevMode->dmPaperSize=DMPAPER_USER;//设为自定义纸张
  DevMode->dmPaperLength=Pagelength;
  DevMode->dmPaperWidth=Pagewidth;
  GlobalUnlock((HGLOBAL&)DevMode);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit28Click(TObject *Sender)
{
 Edit28->Text=Edit23->Text.ToDouble()+
              Edit24->Text.ToDouble()+
              Edit25->Text.ToDouble()+
              Edit26->Text.ToDouble()+
              Edit27->Text.ToDouble();
}
//---------------------------------------------------------------------------

char TMainForm::CheckChar(char Key)
{ if((Key<='9'&&Key>='0')||Key=='.'||Key==0x08){}
    else  Key=0;
  return Key;
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::Edit23KeyPress(TObject *Sender, char &Key)
{
  Key=CheckChar(Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit24KeyPress(TObject *Sender, char &Key)
{
  Key=CheckChar(Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit25KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit26KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit27KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit29KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit30KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit31KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit32KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit20KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit22KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit18KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit19KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit9KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit4Click(TObject *Sender)
{
 Edit4->Text=DateToStr(Date());

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



void __fastcall TMainForm::Edit34Click(TObject *Sender)
{
 Edit34->Text=Edit20->Text.ToDouble()-Edit28->Text.ToDouble()
 -Edit30->Text.ToDouble();
 Edit38->Text=FormatFloat("0.00",Edit34->Text.ToDouble()*0.65);
 Edit42->Text=FormatFloat("0.00",Edit34->Text.ToDouble()*0.35);
 Edit45->Text=Edit38->Text;
 length=Edit45->Text.Length()-1;
 sum=Edit45->Text.ToDouble()*100;
 for (int i=0;i<length;i++)
  {zheng=sum;
   sum=zheng/10;yu=zheng%10;
   switch (i)
   { case 0:Edit52->Text=HanDigiStr[yu];break;
     case 1:Edit51->Text=HanDigiStr[yu];break;
     case 2:Edit50->Text=HanDigiStr[yu];break;
     case 3:Edit49->Text=HanDigiStr[yu];break;
     case 4:Edit48->Text=HanDigiStr[yu];break;
     case 5:Edit47->Text=HanDigiStr[yu];break;
     case 6:Edit46->Text=HanDigiStr[yu];break;
   }
  }
 }
//---------------------------------------------------------------------------
void __fastcall TMainForm::Button1Click(TObject *Sender)
{
  Prntr->BeginDoc();
  Prntr->Canvas->Font->Size=FontSize;
  Prntr->Canvas->TextOutA(xDouble*(Edit[1][0]+Edit[0][0])-ldpi,yDouble*(Edit[1][1]+Edit[0][1])-tdpi, Edit1->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[2][0]+Edit[0][0])-ldpi,yDouble*(Edit[2][1]+Edit[0][1])-tdpi, Edit2->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[3][0]+Edit[0][0])-ldpi,yDouble*(Edit[3][1]+Edit[0][1])-tdpi, Edit3->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[4][0]+Edit[0][0])-ldpi,yDouble*(Edit[4][1]+Edit[0][1])-tdpi, Edit4->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[5][0]+Edit[0][0])-ldpi,yDouble*(Edit[5][1]+Edit[0][1])-tdpi, Edit5->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[6][0]+Edit[0][0])-ldpi,yDouble*(Edit[6][1]+Edit[0][1])-tdpi, Edit6->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[7][0]+Edit[0][0])-ldpi,yDouble*(Edit[7][1]+Edit[0][1])-tdpi, Edit7->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[8][0]+Edit[0][0])-ldpi,yDouble*(Edit[8][1]+Edit[0][1])-tdpi, Edit8->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[9][0]+Edit[0][0])-ldpi,yDouble*(Edit[9][1]+Edit[0][1])-tdpi, Edit9->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[10][0]+Edit[0][0])-ldpi,yDouble*(Edit[10][1]+Edit[0][1])-tdpi, Edit10->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[11][0]+Edit[0][0])-ldpi,yDouble*(Edit[11][1]+Edit[0][1])-tdpi, Edit11->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[12][0]+Edit[0][0])-ldpi,yDouble*(Edit[12][1]+Edit[0][1])-tdpi, Edit12->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[13][0]+Edit[0][0])-ldpi,yDouble*(Edit[13][1]+Edit[0][1])-tdpi, Edit13->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[14][0]+Edit[0][0])-ldpi,yDouble*(Edit[14][1]+Edit[0][1])-tdpi, Edit14->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[15][0]+Edit[0][0])-ldpi,yDouble*(Edit[15][1]+Edit[0][1])-tdpi, Edit15->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[16][0]+Edit[0][0])-ldpi,yDouble*(Edit[16][1]+Edit[0][1])-tdpi, Edit16->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[17][0]+Edit[0][0])-ldpi,yDouble*(Edit[17][1]+Edit[0][1])-tdpi, Edit17->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[18][0]+Edit[0][0])-ldpi,yDouble*(Edit[18][1]+Edit[0][1])-tdpi, Edit18->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[19][0]+Edit[0][0])-ldpi,yDouble*(Edit[19][1]+Edit[0][1])-tdpi, Edit19->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[20][0]+Edit[0][0])-ldpi,yDouble*(Edit[20][1]+Edit[0][1])-tdpi, Edit20->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[21][0]+Edit[0][0])-ldpi,yDouble*(Edit[21][1]+Edit[0][1])-tdpi, Edit21->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[22][0]+Edit[0][0])-ldpi,yDouble*(Edit[22][1]+Edit[0][1])-tdpi, Edit22->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[23][0]+Edit[0][0])-ldpi,yDouble*(Edit[23][1]+Edit[0][1])-tdpi, Edit23->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[24][0]+Edit[0][0])-ldpi,yDouble*(Edit[24][1]+Edit[0][1])-tdpi, Edit24->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[25][0]+Edit[0][0])-ldpi,yDouble*(Edit[25][1]+Edit[0][1])-tdpi, Edit25->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[26][0]+Edit[0][0])-ldpi,yDouble*(Edit[26][1]+Edit[0][1])-tdpi, Edit26->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[27][0]+Edit[0][0])-ldpi,yDouble*(Edit[27][1]+Edit[0][1])-tdpi, Edit27->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[28][0]+Edit[0][0])-ldpi,yDouble*(Edit[28][1]+Edit[0][1])-tdpi, Edit28->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[29][0]+Edit[0][0])-ldpi,yDouble*(Edit[29][1]+Edit[0][1])-tdpi, Edit29->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[30][0]+Edit[0][0])-ldpi,yDouble*(Edit[30][1]+Edit[0][1])-tdpi, Edit30->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[31][0]+Edit[0][0])-ldpi,yDouble*(Edit[31][1]+Edit[0][1])-tdpi, Edit31->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[32][0]+Edit[0][0])-ldpi,yDouble*(Edit[32][1]+Edit[0][1])-tdpi, Edit32->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[33][0]+Edit[0][0])-ldpi,yDouble*(Edit[33][1]+Edit[0][1])-tdpi, Edit33->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[34][0]+Edit[0][0])-ldpi,yDouble*(Edit[34][1]+Edit[0][1])-tdpi, Edit34->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[35][0]+Edit[0][0])-ldpi,yDouble*(Edit[35][1]+Edit[0][1])-tdpi, Edit35->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[36][0]+Edit[0][0])-ldpi,yDouble*(Edit[36][1]+Edit[0][1])-tdpi, Edit36->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[37][0]+Edit[0][0])-ldpi,yDouble*(Edit[37][1]+Edit[0][1])-tdpi, Edit37->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[38][0]+Edit[0][0])-ldpi,yDouble*(Edit[38][1]+Edit[0][1])-tdpi, Edit38->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[39][0]+Edit[0][0])-ldpi,yDouble*(Edit[39][1]+Edit[0][1])-tdpi, Edit39->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[40][0]+Edit[0][0])-ldpi,yDouble*(Edit[40][1]+Edit[0][1])-tdpi, Edit40->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[41][0]+Edit[0][0])-ldpi,yDouble*(Edit[41][1]+Edit[0][1])-tdpi, Edit41->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[42][0]+Edit[0][0])-ldpi,yDouble*(Edit[42][1]+Edit[0][1])-tdpi, Edit42->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[43][0]+Edit[0][0])-ldpi,yDouble*(Edit[43][1]+Edit[0][1])-tdpi, Edit43->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[44][0]+Edit[0][0])-ldpi,yDouble*(Edit[44][1]+Edit[0][1])-tdpi, Edit44->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[45][0]+Edit[0][0])-ldpi,yDouble*(Edit[45][1]+Edit[0][1])-tdpi, Edit45->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[46][0]+Edit[0][0])-ldpi,yDouble*(Edit[46][1]+Edit[0][1])-tdpi, Edit46->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[47][0]+Edit[0][0])-ldpi,yDouble*(Edit[47][1]+Edit[0][1])-tdpi, Edit47->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[48][0]+Edit[0][0])-ldpi,yDouble*(Edit[48][1]+Edit[0][1])-tdpi, Edit48->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[49][0]+Edit[0][0])-ldpi,yDouble*(Edit[49][1]+Edit[0][1])-tdpi, Edit49->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[50][0]+Edit[0][0])-ldpi,yDouble*(Edit[50][1]+Edit[0][1])-tdpi, Edit50->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[51][0]+Edit[0][0])-ldpi,yDouble*(Edit[51][1]+Edit[0][1])-tdpi, Edit51->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[52][0]+Edit[0][0])-ldpi,yDouble*(Edit[52][1]+Edit[0][1])-tdpi, Edit52->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[53][0]+Edit[0][0])-ldpi,yDouble*(Edit[53][1]+Edit[0][1])-tdpi, Edit53->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[54][0]+Edit[0][0])-ldpi,yDouble*(Edit[54][1]+Edit[0][1])-tdpi, Edit54->Text);
  Prntr->Canvas->TextOutA(xDouble*(Edit[55][0]+Edit[0][0])-ldpi,yDouble*(Edit[55][1]+Edit[0][1])-tdpi, Edit55->Text);
  Prntr->EndDoc();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button3Click(TObject *Sender)
{
 Edit1->Text="";
 Edit2->Text="";
 Edit3->Text="";
 Edit4->Text="";
 Edit5->Text="";
 Edit6->Text="";
 Edit7->Text="";
 Edit8->Text="";
 Edit9->Text="";
 Edit10->Text="";
 Edit11->Text="";
 Edit12->Text="";
 Edit13->Text="";
 Edit14->Text="";
 Edit15->Text="";
 Edit16->Text="";
 Edit17->Text="";
 Edit18->Text="";
 Edit19->Text="1";
 Edit20->Text="0";
 Edit21->Text="1";
 Edit22->Text="0";
 Edit23->Text="0";
 Edit24->Text="0";
 Edit25->Text="0";
 Edit26->Text="0";
 Edit27->Text="0";
 Edit28->Text="0";
 Edit29->Text="0";
 Edit30->Text="0";
 Edit31->Text="0";
 Edit32->Text="0";
 Edit33->Text="0";
 Edit34->Text="0";
 Edit35->Text="0";
 Edit36->Text="0";
 Edit37->Text="0";
 Edit38->Text="0";
 Edit39->Text="0";
 Edit40->Text="0";
 Edit41->Text="0";
 Edit42->Text="0";
 Edit43->Text="0";
 Edit44->Text="0";
 Edit45->Text="0";
 Edit46->Text="█";
 Edit47->Text="█";
 Edit48->Text="█";
 Edit49->Text="█";
 Edit50->Text="█";
 Edit51->Text="█";
 Edit52->Text="█";
 Edit53->Text="";
 Edit54->Text="";
 Edit55->Text="";
 Edit56->Text="0";
 Edit57->Text="0";
 Edit58->Text="0";
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button2Click(TObject *Sender)
{int iFileHandle;
    iFileHandle = FileOpen(".\\居民支付表.TXT", fmOpenWrite);
    FileSeek(iFileHandle,0,2);
 Variant Ex,Wb,Sh1;
   Ex=Variant::CreateObject("Excel.Application");
   Edits=GetCurrentDir()+"\\2012居民支付表.xls";
   Ex.PG("WorkBooks").PR("Open",Edits.c_str());
   Wb=Ex.PG("ActiveWorkBook");
   Sh1=Wb.PG("ActiveSheet");
   nRow=Sh1.PG("Cells",2,27).PG("Value");
     //---编号---
    FileWrite(iFileHandle,Edit5->Text.c_str(),Edit5->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,1).PS("Value",Edit5->Text.c_str());
    //---年------
    Edits=Edit4->Text;
    length=0;
    while(*(Edits.c_str()+length)>=0x30&&(*(Edits.c_str()+length)<=0x39)){length++;}
    Year=Edits.SubString(1,length);
    FileWrite(iFileHandle,Year.c_str(),Year.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,2).PS("Value",Year.c_str()); //
    //---Month---
    Edits=Edits.SubString(length+2,Edits.Length()-length+1);
    length=0;
    while(*(Edits.c_str()+length)>=0x30&&(*(Edits.c_str()+length)<=0x39)){length++;}
    Month=Edits.SubString(1,length);
    FileWrite(iFileHandle,Month.c_str(),Edits.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,3).PS("Value",Month.c_str());
    //---Day------
    Day=Edits.SubString(length+2,Edits.Length()-length+1);
    FileWrite(iFileHandle,Day.c_str(),Edits.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,4).PS("Value",Day.c_str());
    //---序号（空）-------
    FileWrite(iFileHandle,"\x09",1);
    //----姓名------------
    FileWrite(iFileHandle,Edit6->Text.c_str(),Edit6->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,6).PS("Value",Edit6->Text.c_str());
    //----年龄------------
    FileWrite(iFileHandle,Edit9->Text.c_str(),Edit9->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,7).PS("Value",Edit9->Text.c_str());
    //-----身份证---------
    FileWrite(iFileHandle,Edit10->Text.c_str(),Edit10->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,8).PS("Value",Edit10->Text.c_str());

    //--------------所住医院------
    FileWrite(iFileHandle,Edit12->Text.c_str(),Edit12->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,9).PS("Value",Edit12->Text.c_str());

     //------------级别--------

    FileWrite(iFileHandle,"\x09",1);

     //------------诊断--------
    FileWrite(iFileHandle,Edit13->Text.c_str(),Edit13->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,11).PS("Value",Edit13->Text.c_str());

     //------------住院次数--------
    FileWrite(iFileHandle,Edit21->Text.c_str(),Edit21->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
     Sh1.PG("Cells",&nRow,12).PS("Value",Edit21->Text.c_str());

     //-------------入院时间-------
    FileWrite(iFileHandle,Edit16->Text.c_str(),Edit16->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
     Sh1.PG("Cells",&nRow,13).PS("Value",Edit16->Text.c_str());

     //------------出院时间--------
    FileWrite(iFileHandle,Edit17->Text.c_str(),Edit17->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
     Sh1.PG("Cells",&nRow,14).PS("Value",Edit17->Text.c_str());

     //------------住院天数--------
    FileWrite(iFileHandle,Edit18->Text.c_str(),Edit18->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,15).PS("Value",Edit18->Text.c_str());

     //------------床位费--------
    FileWrite(iFileHandle,Edit56->Text.c_str(),Edit56->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
     Sh1.PG("Cells",&nRow,16).PS("Value",Edit56->Text.c_str());

     //------------医疗费总额--------
  //  FileWrite(iFileHandle,Edit20->Text.c_str(),Edit20->Text.Length());
  //  FileWrite(iFileHandle,"\x09",1);
  //  Sh1.PG("Cells",&nRow,17).PS("Value",Edit20->Text.c_str());

     //-----------医疗费总额校验---------
     FileWrite(iFileHandle,"\x09",1);
     //-----------乙类10%或20%部分---------
    Edits=Edit23->Text.ToDouble()+Edit24->Text.ToDouble();
    FileWrite(iFileHandle,Edits.c_str(),Edits.Length());
    FileWrite(iFileHandle,"\x09",1);
     Sh1.PG("Cells",&nRow,19).PS("Value",Edits.c_str());

     //-----------自费部分---------
    Edits=Edit25->Text.ToDouble()+Edit26->Text.ToDouble()+Edit27->Text.ToDouble();
    FileWrite(iFileHandle,Edits.c_str(),Edits.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,20).PS("Value",Edits.c_str());

     //-----------起付线---------
    FileWrite(iFileHandle,Edit30->Text.c_str(),Edit30->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,21).PS("Value",Edit30->Text.c_str());

     //-----------支付基数---------
    FileWrite(iFileHandle,Edit34->Text.c_str(),Edit34->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,22).PS("Value",Edit34->Text.c_str());

      //----------支付校验----------
    FileWrite(iFileHandle,"\x09",1);
      //----------统筹基金支付----------
    FileWrite(iFileHandle,Edit38->Text.c_str(),Edit38->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,24).PS("Value",Edit38->Text.c_str());
     //-----------个人负担---------
    FileWrite(iFileHandle,Edit42->Text.c_str(),Edit42->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,25).PS("Value",Edit42->Text.c_str());
     //----------封顶线以上----------
    FileWrite(iFileHandle,Edit58->Text.c_str(),Edit58->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,26).PS("Value",Edit58->Text.c_str());
     //----------序号1----------
    FileWrite(iFileHandle,"\x09",1);
     //----------序号2----------
    FileWrite(iFileHandle,"\x09",1);
     //----------药品总额----------
    FileWrite(iFileHandle,Edit57->Text.c_str(),Edit57->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,29).PS("Value",Edit57->Text.c_str());
    //----------特检特治----------
    FileWrite(iFileHandle,Edit23->Text.c_str(),Edit23->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,30).PS("Value",Edit23->Text.c_str());
    //--------乙类药品10%部分------------
    FileWrite(iFileHandle,Edit24->Text.c_str(),Edit24->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,31).PS("Value",Edit24->Text.c_str());
    //--------自费药品------------
    FileWrite(iFileHandle,Edit26->Text.c_str(),Edit26->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,32).PS("Value",Edit26->Text.c_str());
    //-------其它-------------
    Edits=Edit25->Text.ToDouble()+Edit27->Text.ToDouble();
    FileWrite(iFileHandle,Edits.c_str(),Edits.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,33).PS("Value",Edits.c_str());
    //------自费校验--------------
    FileWrite(iFileHandle,"\x09",1);
    //-----跨年度备注---------------
    FileWrite(iFileHandle,"\x09",1);
     //----累计支付----------------
    FileWrite(iFileHandle,Edit22->Text.c_str(),Edit22->Text.Length());
    FileWrite(iFileHandle,"\x09",1);
    Sh1.PG("Cells",&nRow,35).PS("Value",Edit22->Text.c_str());
    FileWrite(iFileHandle,"\x0D\x0A",2);
    nRow++;
    Sh1.PG("Cells",2,27).PS("Value",&nRow);
    FileClose(iFileHandle);
    Wb.PR("Save");
    Wb.PR("Close");
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::Edit56KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit57KeyPress(TObject *Sender, char &Key)
{
  Key=CheckChar(Key);       
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit58KeyPress(TObject *Sender, char &Key)
{
 Key=CheckChar(Key);        
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::Edit6Click(TObject *Sender)
{
 Edit6->Text=Edit2->Text;        
}
//---------------------------------------------------------------------------

