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

#include <vcl.h>
#pragma hdrstop

#include "modify.h"
#include "Calc.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TModifyForm *ModifyForm;
//---------------------------------------------------------------------------
__fastcall TModifyForm::TModifyForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TModifyForm::Edit1KeyPress(TObject *Sender, char &Key)
{
        if( Key == 0x0D)
        {
                TCalForm* parent = dynamic_cast<TCalForm*>(Owner);
                
                parent->TotalED->Text = IntToStr(StrToInt(parent->TotalED->Text)-StrToInt(parent->SellGR->Cells[5][parent->SellGR->Row]));

                if(Label1->Caption == "단가변경")
                {
                        if(StrToInt(Edit1->Text) > 0)
                                parent->SellGR->Cells[3][parent->SellGR->Row] = Edit1->Text;
                        else
                                ShowMessage("금액이 너무 적습니다.");
                }
                else
                {
                        parent->SellGR->Cells[4][parent->SellGR->Row] = Edit1->Text;
                }

                parent->SellGR->Cells[5][parent->SellGR->Row] = IntToStr(StrToInt(parent->SellGR->Cells[3][parent->SellGR->Row])*StrToInt(parent->SellGR->Cells[4][parent->SellGR->Row]));
                parent->TotalED->Text = IntToStr(StrToInt(parent->TotalED->Text) + StrToInt(parent->SellGR->Cells[5][parent->SellGR->Row]));

                //parent->IbEdit->OnKeyPress(this,0x0D);

                Close();
        }
        if(Key == 0x1b)//esc키
        {
                Close();
        }
        
}
//---------------------------------------------------------------------------
