随机数的补位问题

protected void submit_Click(object sender, EventArgs e)
    {
        int intro = 0; string opra = String.Empty;
       

        Random diaran = new Random();
        DateTime diad = DateTime.Today;
        string diadt = diad.Year.ToString() +  diad.Month.ToString() + diad.Day.ToString();
        string diablo = (diaran.Next() % 999).ToString();
        while (diablo.Length < 3)
        {
            diablo = "0" + diablo;
        }

        //String temp = (diaran.Next() % 999).toString;
        //while (temp.length < 3)
        //{
        //    temp = "0" + temp;
        //}

        diadt += diablo;

        //diadt += diaran.Next() % 999;
        //string diadt = diad.Year.ToString() + diad.Month.ToString() + diad.Day.ToString();
        //diadt += diaran.Next() % 999;

       
       
       
        //string diadt = DateTime.Today.ToString();
        string name = this.tbxzusername.Text.Trim();
        string zuserno = diadt;
        string zuserreal = this.tbxzuserrealname.Text.Trim();
        string diapass = this.tbxzpwd.Text.Trim();
        string sex = this.ddlSex.Value.Trim();
        string tel = this.tbxtelephone.Text.Trim();
        string mobile = this.tbxmobiletelephone.Text.Trim();
        intro = int.Parse(this.dropzuserid.Text.Trim());
          opra = this.dropoperation.Text.Trim();
          if (!zvili(name))
          {
             
              updintrosam(intro);
              insertzuser(name, zuserno, zuserreal,diapass, sex, tel, mobile, intro, opra);
              Response.Write("<script language='javascript'>alert('" + zuserno + "');;window.location='zuerlist.aspx';</script>");
          }
          else
          {
              Response.Write("<script language='javascript'>alert('登录名已存在!');</script>");
          }
    }

 

 

 

 

String temp = (diaran.Next() % 999).toString;
while(temp.length < 3) {
    temp = "0" + temp;
}  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值