俺也不多说了,按的表达能力很有限啊
要是当面,早把问题给你解决了啊。
好了,给你一段代码,看一下,我想你的问题应给会解决的。
我是直接从程序里COPY的,汉字是乱码。
procedure Tfrm_NewTelBusiness.FormCreate(Sender: TObject);
begin
qryTelNewBusiness.Connection:= DM_Main.conn_Main;
qryTelNewBusiness.CommandTimeout:=600;
qryTelNewBusinessSelect.Connection:=DM_Main.conn_Main;
qryTelNewBusinessSelect.CommandTimeout:=600;
qryTelNewBusinessDetailSelect.Connection:=DM_Main.conn_Main;
qryTelNewBusinessDetailSelect.CommandTimeout:=600;
ADOStoredProc1.Connection:=DM_Main.conn_Main;
ADOStoredProc1.CommandTimeout:=600;
end;
procedure Tfrm_NewTelBusiness.SpeedButton2Click(Sender: TObject);
var
ID : string;
a
leVariant;
i :integer;
begin
if trim(edtAcceptPerson.Text)='' then
begin
Showmessage('??ê?è?êüàíè?D???');
exit;
end;
if trim(edtCustomerName.Text)='' then
begin
showmessage('??ê?è??í?§D???');
exit;
end;
if trim(edtTelNumber.Text)='' then
begin
showmessage('??ê?è?×°?úo???');
exit;
end;
if trim(edtTelAddress.Text)='' then
begin
ShowMessage('??ê?è?°2×°μ??·');
exit;
end;
// if trim(cmbTelType.Text)='' then
// begin
// showmessage('??????°2×°ààDí');
// exit;
// end;
if not DM_MAin.conn_Main.InTransaction then
begin
DM_MAin.conn_Main.BeginTrans;
try
ADOStoredProc1.Close;
ADOStoredProc1.Prepared:=False;
ADOStoredProc1.ProcedureName:='P_GetTelYMD';
ADOStoredProc1.Parameters.Clear;
ADOStoredProc1.Parameters.CreateParameter('@ID',ftString,pdOutput,11,a);
ADOStoredProc1.Prepared:=True;
ADOStoredProc1.ExecProc;
ID:=ADOStoredProc1.Parameters.ParamByName('@ID').Value;
{ D???μ??°òμ??μ?í·±í???? }
qryTelNewBusiness.Close;
qryTelNewBusiness.sql.Clear;
qryTelNewBusiness.SQL.Text:='insert into tbl_TelBusinessHeader(AcceptID,AcceptDate,AcceptPerson,CustomerName,CustomerCard,CustomerAddress,CustomerTel,TelNumber,TelAddress,TelType,TelPrice,TelDeposit,TelFavourable) '+
' values
AcceptID,:AcceptDate,:AcceptPerson,:CustomerName,:CustomerCard,:CustomerAddress,:CustomerTel,:TelNumber,:TelAddress,:TelType,:TelPrice,:TelDeposit,:TelFavourable)';
qryTelNewBusiness.Parameters.ParamByName('AcceptID').Value:=ID;
qryTelNewBusiness.Parameters.ParamByName('AcceptDate').Value:=strToDate(formatdatetime('yyyy-mm-dd',dt_AcceptDate.DateTime));
qryTelNewBusiness.Parameters.ParamByName('AcceptPerson').Value:=trim(edtAcceptPerson.Text);
qryTelNewBusiness.Parameters.ParamByName('CustomerName').Value:=trim(edtCustomerName.Text);
//éí·Y?¤o???
if trim(edtCustomerCard.Text)='' then
qryTelNewBusiness.Parameters.ParamByName('CustomerCard').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('CustomerCard').Value:=trim(edtCustomerCard.Text);
//?í?§áa?μμ??·
if trim(edtCustomerAddress.Text)='' then
qryTelNewBusiness.Parameters.ParamByName('CustomerAddress').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('CustomerAddress').Value:=trim(edtCustomerAddress.Text);
//?í?§áa?μμ??°
if trim(edtCustomerTel.Text)='' then
qryTelNewBusiness.Parameters.ParamByName('CustomerTel').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('CustomerTel').Value:=trim(edtCustomerTel.Text);
//?í?§×°?úo???
qryTelNewBusiness.Parameters.ParamByName('TelNumber').Value:=trim(edtTelNumber.Text);
//×°?úμ??·
qryTelNewBusiness.Parameters.ParamByName('TelAddress').Value:=trim(edtTelAddress.Text);
// ×°?úààDí
qryTelNewBusiness.Parameters.ParamByName('TelType').Value:=trim(cmbTelType.Text);
//3é??????
if trim(edtTelPrice.Text)='' then
qryTelNewBusiness.Parameters.ParamByName('TelPrice').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('TelPrice').Value:=strtofloat(trim(edtTelPrice.Text));
//?o?e
if trim(edtTelDeposit.text)='' then
qryTelNewBusiness.Parameters.ParamByName('TelDeposit').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('TelDeposit').Value:=StrToFloat(trim(edtTelDeposit.text));
//ó??Y????
if trim(edtTelFavourable.Text)='' then
qryTelNewBusiness.Parameters.ParamByName('TelFavourable').Value:=null
else
qryTelNewBusiness.Parameters.ParamByName('TelFavourable').Value:=trim(edtTelFavourable.Text);
qryTelNewBusiness.Prepared:=true;
qryTelNewBusiness.ExecSQL;
{D???μ??°òμ??μ??÷??????}
if ListView_TelGongNeng.Items.Count>0 then
begin
for i:=0 to ListView_TelGongNeng.Items.Count-1 do
begin
qryTelNewBusiness.Close;
qryTelNewBusiness.SQL.Clear;
qryTelNewBusiness.SQL.Text:='insert into tbl_TelBusinessDetail(AcceptID,TelNumber,TelGongNeng) values
AcceptID,:TelNumber,:TelGongNeng)';
qryTelNewBusiness.Parameters.ParamByName('AcceptID').Value:=ID;
qryTelNewBusiness.Parameters.ParamByName('TelNumber').Value:=trim(edtTelNumber.Text);
qryTelNewBusiness.Parameters.ParamByName('TelGongNeng').Value:=trim(ListView_TelGongNeng.Items.Item
.Caption);
qryTelNewBusiness.ExecSQL;
end;
end;
//ìá??ê???
DM_MAin.conn_Main.CommitTrans;
ShowMessage('D???μ??°òμ??3é1|');
except
on e:exception do
begin
DM_MAin.conn_Main.RollbackTrans; //??1?ê???
ShowMessage('D???μ??°òμ??꧰ü£?꧰ü?-òòê?£o'+e.Message);
exit;
end;
end;
end;
{??ê?D???μ?μ??°òμ??D??¢}
//--??ê?í·D??¢
qryTelNewBusinessSelect.Close;
qryTelNewBusinessSelect.SQL.Clear;
qryTelNewBusinessSelect.SQL.Text:='select * from tbl_TelBusinessHeader where AcceptID='''+ID+'''';
qryTelNewBusinessSelect.Open;
//---??ê??÷??D??¢
qryTelNewBusinessDetailSelect.Close;
qryTelNewBusinessDetailSelect.SQL.Clear;
qryTelNewBusinessDetailSelect.SQL.Text:='select * from tbl_TelBusinessDetail where AcceptID=:AcceptID and TelNumber=:TelNumber';
qryTelNewBusinessDetailSelect.DataSource:=DataSourceTelHeader;
qryTelNewBusinessDetailSelect.Open;