?? dadd.cpp
字號:
}
void CDAdd::Clear()
{
m_EdtUseTime.SetWindowText("");
m_EdtUnit.SetWindowText("");
m_EdtSpec.SetWindowText("");
m_EdtReMainsRate.SetWindowText("");
m_EdtReMains.SetWindowText("");
m_EdtOvalue.SetWindowText("");
m_EdtNumber.SetWindowText("");
m_EdtNetValue.SetWindowText("");
m_EdtName.SetWindowText("");
m_EdtEstimateUseTime.SetWindowText("");
m_EdtDepreciationRate.SetWindowText("");
m_EdtDepreciationMoney.SetWindowText("");
m_EdtDepreciation.SetWindowText("");
m_ComUseStatus.SetWindowText("");
m_ComStyle.SetWindowText("");
m_ComMeans.SetWindowText("");
m_ComAddStyle.SetWindowText("");
m_StaID.SetWindowText("ZC00000001");
CTime time;
time=time.GetCurrentTime();
m_DtDate.SetTime(&time);
}
void CDAdd::OnButadd()
{
this->Clear();
this->AddOrChange=1;
CString sID;
sID=ado.AutoNumber("固定資產信息表","編號","ZC",2);
m_StaID.SetWindowText(sID);
this->Enabled(true);
m_DtDate.SetFocus();
}
void CDAdd::OnButchange()
{
this->AddOrChange=2;
this->Enabled(true);
m_DtDate.SetFocus();
}
void CDAdd::OnButdelete()
{
if(MessageBox("刪除后不可恢復!確定要刪除此條固定資產記錄嗎?","系統提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL,sID;
this->m_StaID.GetWindowText(sID);
sSQL.Format("DELETE FROM 固定資產信息表 WHERE 編號='%s'",sID);
RxRecordset Delerst;
Delerst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CDAdd::OnButsave()
{
if(MessageBox("確定要保存記錄嗎?","系統提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL,sID,sName,sSpec,sUnit,sNumber,sStyle,sStyleID,sAddStyle,sAddStyleID,sUseStatus,sUseStatusID,sOvalue,sDepreciation,sNetValue,sReMainsRate,sReMains,sMeans,sMeansID,sEstimateUseTime,sUseTime,sDepreciationRate,sDepreciationMoney,sDate;
CString slb,szt;
int njt;
m_StaID.GetWindowText(sID);
m_EdtUseTime.GetWindowText(sUseTime);
m_EdtUnit.GetWindowText(sUnit);
m_EdtSpec.GetWindowText(sSpec);
m_EdtReMainsRate.GetWindowText(sReMainsRate);
m_EdtReMains.GetWindowText(sReMains);
m_EdtOvalue.GetWindowText(sOvalue);
m_EdtNumber.GetWindowText(sNumber);
m_EdtNetValue.GetWindowText(sNetValue);
m_EdtName.GetWindowText(sName);
m_EdtEstimateUseTime.GetWindowText(sEstimateUseTime);
m_EdtDepreciationRate.GetWindowText(sDepreciationRate);
m_EdtDepreciationMoney.GetWindowText(sDepreciationMoney);
m_EdtDepreciation.GetWindowText(sDepreciation);
m_ComUseStatus.GetWindowText(sUseStatus);
sUseStatusID=ado.FieldToOtherField("使用狀況表","名稱",sUseStatus,"編號",1);
szt=ado.FieldToOtherField("使用狀況表","名稱",sUseStatus,"是否計提",1);
m_ComStyle.GetWindowText(sStyle);
sStyleID=ado.FieldToOtherField("類別表","名稱",sStyle,"編號",1);
slb=ado.FieldToOtherField("類別表","名稱",sStyle,"是否計提",1);
m_ComMeans.GetWindowText(sMeans);
sMeansID=ado.FieldToOtherField("折舊算法表","名稱",sMeans,"編號",1);
m_ComAddStyle.GetWindowText(sAddStyle);
sAddStyleID=ado.FieldToOtherField("增加方式表","名稱",sAddStyle,"編號",1);
CString sMsg,stip;
if(szt=="1"&&slb=="1")
{
njt=1;
stip="屬于計提折舊的固定資產,\n在計提時將被操作,繼續嗎?";
}
else
{
njt=0;
stip="不在計提折舊的固定資產范圍內,\n在計提時不被操作,繼續嗎?";
}
CTime time;
sMsg.Format("由于[ %s %s ]%s",sUseStatus,sStyle,stip);
if(MessageBox(sMsg,"系統提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
m_DtDate.GetTime(time);
sDate=CTimeToCString(time);
if(this->AddOrChange==1)//添加
{
sSQL.Format("INSERT INTO 固定資產信息表 VALUES('%s','%s','%s','%s',%s,%s,%s,%s,%s,%s,%s,%f,%s,%s,%s,%s,%f,%s,'%s',0,%d)",sID,sName,sSpec,sUnit,sNumber,sStyleID,sAddStyleID,sUseStatusID,sOvalue,sDepreciation,sNetValue,(float)atoi(sReMainsRate)/1000,sReMains,sMeansID,sEstimateUseTime,sUseTime,(float)atoi(sDepreciationRate)/1000,sDepreciationMoney,sDate,njt);
rst.Open(sSQL,adCmdText);
}
if( this->AddOrChange==2)//修改
{
sSQL.Format("UPDATE 固定資產信息表 SET 名稱='%s',規格型號='%s',單位='%s',數量='%s',類別=%s,增加方式=%s,使用狀況=%s,入賬原值=%s,累計折舊=%s,凈值=%s WHERE 編號='%s'",sName,sSpec,sUnit,sNumber,sStyleID,sAddStyleID,sUseStatusID,sOvalue,sDepreciation,sNetValue,sID);
rst.Open(sSQL,adCmdText);
sSQL.Format("UPDATE 固定資產信息表 SET 預計凈殘值率=%f,預計凈殘值=%s,折舊方法=%s,預計使用月份=%s,已計提月份=%s,月折舊率=%f,月折舊額=%s,入賬日期='%s',計提否=%d WHERE 編號='%s'",(float)atoi(sReMainsRate)/1000,sReMains,sMeansID,sEstimateUseTime,sUseTime,(float)atoi(sDepreciationRate)/1000,sDepreciationMoney,sDate,njt,sID);
rst.Open(sSQL,adCmdText);
}
this->AddOrChange=0;
this->Enabled(false);
this->m_ButAdd.SetFocus();
}
void CDAdd::OnButundo()
{
if(MessageBox("確定要撤消操作嗎?","系統提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
this->Enabled(false);
this->Clear();
this->Display(m_sID);
this->m_ButAdd.SetFocus();
}
void CDAdd::OnButexit()
{
this->OnCancel();
}
void CDAdd::OnChangeEdtdepreciation()
{
CString sOvalue,sDepreciation,sNetValue;
float fOvalue,fDepreciation,fNetValue;
m_EdtOvalue.GetWindowText(sOvalue);
this->m_EdtDepreciation.GetWindowText(sDepreciation);
fOvalue=atof(sOvalue);
fDepreciation=atof(sDepreciation);
fNetValue=fOvalue-fDepreciation;
sNetValue=Format(fNetValue,2);
m_EdtNetValue.SetWindowText(sNetValue);
}
void CDAdd::OnChangeEdtovalue()
{
OnChangeEdtdepreciation();
}
void CDAdd::OnChangeEdtremainsrate()
{
CString sReMainsRate,sReMains,sNetValue;
float nReMainsRate,nNetValue;
m_EdtReMainsRate.GetWindowText(sReMainsRate);
m_EdtNetValue.GetWindowText(sNetValue);
nNetValue=atof(sNetValue);
nReMainsRate=atof(sReMainsRate)/1000;
nNetValue=nNetValue*nReMainsRate;
sReMains=Format(nNetValue,2);
this->m_EdtReMains.SetWindowText(sReMains);
}
void CDAdd::OnKillfocusCommeans()
{
CString sSQL,sID,sMeans,sMonthRate,sMonthMoney;
m_ComMeans.GetWindowText(sMeans);
m_StaID.GetWindowText(sID);
sMonthRate=ado.FieldToOtherField("折舊算法表","名稱",sMeans,"月折舊率",1);
sMonthMoney=ado.FieldToOtherField("折舊算法表","名稱",sMeans,"月折舊額",1);
if(sMonthRate.IsEmpty()||sMonthMoney.IsEmpty())
return;
sSQL.Format("SELECT %s AS 折舊率,%s AS 折舊金額 FROM 臨時表",sMonthRate,sMonthMoney);
if(rst.Open(sSQL,adCmdText)==false)
return;
sMonthRate=rst.GetFieldValue("折舊率");
sMonthMoney=rst.GetFieldValue("折舊金額");
float fMonthRate=atof(sMonthRate)*1000;
if(fMonthRate<1)
fMonthRate=1;
sMonthRate.Format("%d",(int)fMonthRate);
sMonthMoney=Format(atof(sMonthMoney),2);
m_EdtDepreciationRate.SetWindowText(sMonthRate);
m_EdtDepreciationMoney.SetWindowText(sMonthMoney);
}
void CDAdd::OnSetfocusCommeans()
{
CString sSQL,sOvalue="0",sDepreciation="0",sNetValue="0",sReMainsRate="0",sReMains="0",sEstimateUseTime="0",sDepreciationMonth="0",sUseTime="0";
m_EdtReMains.GetWindowText(sReMains);
m_EdtOvalue.GetWindowText(sOvalue);
m_EdtNetValue.GetWindowText(sNetValue);
m_EdtReMainsRate.GetWindowText(sReMainsRate);
m_EdtEstimateUseTime.GetWindowText(sEstimateUseTime);
m_EdtDepreciation.GetWindowText(sDepreciation);
sSQL.Format("DELETE FROM 臨時表");
rst.Open(sSQL,adCmdText);
sSQL.Format("Insert into 臨時表 values(%s,%s,%s,%f,%s,%s,%s,%s)",sOvalue,sDepreciation,sNetValue,atof(sReMainsRate)/1000,sReMains,sEstimateUseTime,sDepreciationMonth,sUseTime);
rst.Open(sSQL,adCmdText);
}
void CDAdd::SetID(CString sID)
{
this->m_sID=sID;
}
void CDAdd::OnEditchangeComusestatus()
{
//CString UseStatus;
// this->m_ComUseStatus(UseStatus);
//if(UseStatus=="未使用"||UseStatus=="不需用"||UseStatus==""
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -