//如果code里 有错 请指出 非喜勿喷 谢谢
/// <summary>
/// 拨号事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button7_Click(object sender, EventArgs e)
{
this.lblmsg.Text = "";
string phone = txtTEL.Text.Trim();//手机号
if (!string.IsNullOrEmpty(txtTEL.Text.Trim()))
{
try
{
//num = Convert.ToInt32(txtTEL.Text.Trim().ToString());
Convert.ToInt64(txtTEL.Text.Trim());
}
catch (Exception ex)
{
this.lblmsg.Text = "输入手机号格式不正确";
txtTEL.SelectAll();
txtTEL.Focus();
return;
}
if (txtTEL.Text.Length!=11)
{
this.lblmsg.Text = "手机号长度必须是11位";
txtTEL.SelectAll();
txtTEL.Focus();
return;
}
if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^((0?1[358]\d{9})|((0(10|2[1-3]|[3-9]\d{2}))?[1-9]\d{6,7}))$"))
{
this.lblmsg.Text = "手机号不存在!";
txtTEL.SelectAll();
txtTEL.Focus();
return;
}
//"15666775256"
//MessageBox.Show(phoneclass.DialUp(txtTEL.Text.Trim().ToString()));输出的返回值
this.lblmsg.Text = "正在呼叫中,请稍等.";
this.timer1.Enabled = true;
if (phoneclass.DialUp(txtTEL.Text.Trim().ToString()) == "OK")// 拨打电话
{
this.lblmsg.Text = "正在通话中...";
}
}
else
{
this.lblmsg.Text = "输入手机号";
txtTEL.Focus();
return;
}
}