.net按钮是否有问题~!
我在执行一个按钮事件的时候,其中包括提交表单、上传文件、然后还回列表。哎。每次执行都很慢,但是当我再点击该按钮的时候等几秒又成功了,不过郁闷的时候是有时生成了两条记录,也就是执行了两次。以下代码是否有问题:
private void submit1_Click(object sender, System.EventArgs e)//立即发布方案
{
submit1.Enabled=false;
if (goldtxt.Value.Trim()!="")
{
string hemaibianhao=function.GetStringNum("zchm","codenum","pkid","QC10001");
double mycash=double.Parse(myclass.getgold(User.Identity.Name));
string snetid=User.Identity.Name;
int hemaifenshu=int.Parse(allfenshutxt.Value.Trim());
int smyfenshu=int.Parse(myfenshutxt.Value.Trim());
string stitle=titletxt.Text.Trim();
int sbaodifenshu=int.Parse(baoditxt.Value);
double scash=double.Parse(goldtxt.Value.Trim())*int.Parse(beishutxt.Value.Trim());
string scontenttxt=contenttxt.Text;
string spid=DropDownList1.SelectedValue;
string sqihao=DropDownList1.SelectedItem.Text;
//=========================================计算进度
int sisfull=0;
if (hemaifenshu==smyfenshu)
{
sisfull=1;
}
//检查金额是否足够
double needcash=(sbaodifenshu+smyfenshu)*scash/hemaifenshu;
if (needcash>mycash)
{
function.AlertInfo("你的金额不足!!!");
}
else
{
//上传文件。两种方式。
string sfileurl="";
if (RadioButtonList1.SelectedValue=="0")
{
string NamePart=function.GetDataRandom();
string sfilename=Server.MapPath("../upload/")+NamePart+".txt";
if(myclass.WriteText(sfilename,touzhunrtxt.Value))
{
sfileurl="upload/"+NamePart+".txt";
}
else
{
sfileurl="";
}
}
else if(RadioButtonList1.SelectedValue=="1")
{
try
{
sfileurl=myclass.GetUpLoadFileName(File1,"../upload","text/plain");
sfileurl=sfileurl.Substring(3,sfileurl.Length-3);
}
catch
{
sfileurl="";
}
}
//上传文件结束--------------
int sishownow=1;
if (Radio2.Checked)
{
sishownow=0;
}
//把合买写入zchm表中
Button1.Enabled=false;
string sql="insert into [zchm](username,netid,pid,codenum,title,content,beishu,nowpiece,howpiece,codeid,type,checktype,isfull,zhushu,baodipiece,cash,FileUrl,isshownow) values('"+usernametxt.Text.Trim()+"','"+snetid+"','"+spid+"','"+hemaibianhao+"','"+stitle+"','"+scontenttxt+"','"+beishutxt.Value.Trim()+"','"+smyfenshu+"','"+hemaifenshu+"','"+sqihao+"','3','0','"+sisfull+"','"+zhushutxt.Text+"','"+sbaodifenshu+"','"+scash+"','"+sfileurl+"','"+sishownow+"')";
data.RunSql(sql);
//-----------------------以下写入[joinhm]表,发起人也是加入合买人。
string sqlpkid="select pkid from [zchm] where codenum='"+hemaibianhao+"'";
string shemaipkid=data.RunSqlDs(sqlpkid).Tables[0].Rows[0]["pkid"].ToString();
string sqljoinhm="insert into [joinhm](pid,codenum,netid,username,baodipiece,type,checktype,joinpiece,joincash) values('"+shemaipkid+"','"+hemaibianhao+"','"+snetid+"','"+usernametxt.Text+"','"+sbaodifenshu+"','3','0','"+smyfenshu+"','"+needcash+"')";
data.RunSql(sqljoinhm);
//注:标记pid=-1表示我是发起人,这里的 PID对应[zchm]表中的PKID.
//合买发起人的G币扣除对应的金额。
string sqlcash="update [user] set gold=gold-'"+needcash+"' where netid='"+snetid+"'";
data.RunSql(sqlcash);
step1.Visible=false;
step2.Visible=true;
//发送成功后转向
function.JavaScript_AlertLocation("合买发起成功!!!","singlelist.aspx?pkid="+DropDownList1.SelectedValue);
}
}
else
{
function.AlertInfo("你投注金额为0,不能发起合买!");
}
}
//我在想别人网站应该都是有个提交后按钮不可用,可是我还能用/热~!