private void btn_pay_Click(object sender, EventArgs e)
        {
            float limitmoney;//用于保存可支付款余额的变量
            if (txt_balance.Text != "")//如果有余额
                limitmoney = (Convert.ToSingle(txt_balance.Text)
                    + Convert.ToSingle(nup_nowpaymoney.Value))
                    - Convert.ToSingle(txt_total.Text);//计算本次支付后的余额
            else
                limitmoney = Convert.ToSingle(nup_nowpaymoney.Value) - Convert.ToSingle(txt_total.Text);            if (limitmoney >= 0)//如果本次支付的款项够支付
            {
                //在PayRecored中插入一条付款记录
                myoperate.getcom("insert into PayRecord(PiaoHao,BinLiHao," +
                    "Name,Doctor,Dept,CardID," +
                    "medicalPay,CheckPay,patientPay,registerPay,CurrentPay," +
                    "AmountPay,paymentMethod," +
                    "CurrentDate,paytreatfee) values('"
                    + txt_payno.Text.Trim() + "','" + txt_patientno.Text.Trim() + "'"
                + ",'" + txt_patientname.Text.Trim() + "','" + txt_paydoctor.Text.Trim()
                + "','" + txt_discipline.Text.Trim() + "','" + txt_cardname.Text.Trim()
                + "','" + txt_medcipayfee.Text.Trim() + "','" + txt_paycheckfee.Text.Trim() + "'"
                + ",'" + txt_paytreatfee.Text.Trim() + "','" + txt_regfee.Text.Trim()
                + "','" + nup_nowpaymoney.Value.ToString() + "','" + txt_total.Text.Trim()
                + "','" + cmb_paytype.SelectedItem.ToString() + "','"
                + dtp_paydate.Value.ToShortDateString()
                + "','" + txt_paytreatfee.Text.Trim() + "')");
                MessageBox.Show("付款成功!");//弹出付款成功的消息
            }
            else
                MessageBox.Show("本次付费金额不足!");//提示本次付款不足信息
        }加粗红色部分调试出现“输入字符串的格式不正确”
请问该如何修改???哪位高手帮忙下,THANKS!!

解决方案 »

  1.   

    (nup_nowpaymoney.Value、txt_total.Text有一个为空或填写了非发字符。
      

  2.   

    txt_total.Text含有非数字字符或者内容为空
    仔细检查txt_total.Text的内容
      

  3.   

    txt_total.Text含有非数字字符或者内容为空
    仔细检查txt_total.Text的内容
    打印出来看一下 就明白了
      

  4.   

    加个断点调试一下,看看nup_nowpaymoney.Value和txt_total.Text分别是什么值
      

  5.   

     因为和下面这段代码有关,下面定义的是float类型 private void btn_pay_Click(object sender, EventArgs e)
            {
                float limitmoney;//用于保存可支付款余额的变量
                if (txt_balance.Text != "")//如果有余额
                    limitmoney = (Convert.ToSingle(txt_balance.Text)
                        + Convert.ToSingle(nup_nowpaymoney.Value))
                        - Convert.ToSingle(txt_total.Text);//计算本次支付后的余额
                else
                    limitmoney = Convert.ToSingle(nup_nowpaymoney.Value) - Convert.ToSingle(txt_total.Text);
                if (limitmoney >= 0)//如果本次支付的款项够支付
                {
                    //在PayRecored中插入一条付款记录
                    myoperate.getcom("insert into PayRecord(PiaoHao,BinLiHao," +
                        "Name,Doctor,Dept,CardID," +
                        "medicalPay,CheckPay,patientPay,registerPay,CurrentPay," +
                        "AmountPay,paymentMethod," +
                        "CurrentDate,paytreatfee) values('"
                        + txt_payno.Text.Trim() + "','" + txt_patientno.Text.Trim() + "'"
                    + ",'" + txt_patientname.Text.Trim() + "','" + txt_paydoctor.Text.Trim()
                    + "','" + txt_discipline.Text.Trim() + "','" + txt_cardname.Text.Trim()
                    + "','" + txt_medcipayfee.Text.Trim() + "','" + txt_paycheckfee.Text.Trim() + "'"
                    + ",'" + txt_paytreatfee.Text.Trim() + "','" + txt_regfee.Text.Trim()
                    + "','" + nup_nowpaymoney.Value.ToString() + "','" + txt_total.Text.Trim()
                    + "','" + cmb_paytype.SelectedItem.ToString() + "','"
                    + dtp_paydate.Value.ToShortDateString()
                    + "','" + txt_paytreatfee.Text.Trim() + "')");
                    MessageBox.Show("付款成功!");//弹出付款成功的消息
                }
                else
                    MessageBox.Show("本次付费金额不足!");//提示本次付款不足信息
            }
      

  6.   

    但是上面这段 
    else
      limitmoney = Convert.ToSingle(nup_nowpaymoney.Value) - Convert.ToSingle(txt_total.Text);
    调试也出现问题。
      

  7.   

    谁维护楼主的代码谁就要哭。拼音+英文 命名
    没用字符串格式化函数
    没用数据参数
    无SQL防注入功能