📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Ex13_12
{
public partial class Form1 : Form
{
short result = 1;
bool open_close = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//初始化驱动程序
long load = DJ160API.LoadDRV();
//检测通道总数,并为每个通道分配语音缓冲区
short wuseCh = DJ160API.CheckValidCh();
short wFileBufLen = 16 * 1024;
long card = DJ160API.EnableCard(wuseCh, wFileBufLen);
//设置表格-通道的行数
dataGridView1.RowCount = wuseCh;
//检测每个通道类型
short chanelTpye = 0; //定义通道类型变量
string strType = "";
for (short i = 0; i < wuseCh; i++)
{
chanelTpye = DJ160API.CheckChType(i);
dataGridView1[0, i].Value = i;
switch (chanelTpye)
{
case 0:
strType = "内线";
break;
case 1:
strType = "外线";
break;
case 2:
strType = "悬空";
break;
}
dataGridView1[1, i].Value = strType;
}
DJ160API.Sig_Init(0);
}
private void timer1_Tick(object sender, EventArgs e)
{
byte[] ss = new byte[100];
for (short i = 0; i < 8; i++)
{
DJ160API.StartSigCheck(i);
if(open_close==false)
DJ160API.ResetCallerIDBuffer(i);
if (DJ160API.RingDetect(i))
{
open_close = true;
//获取来电号码
result = DJ160API.GetCallerIDStr(i, ss);
if (result == 3 || result == 4)
{
string str = Encoding.UTF8.GetString(ss);
txtTel.Text = str;
txtTel.Text = txtTel.Text.Substring(txtTel.Text.Length - 8, 8);
dataGridView1[2, i].Value = txtTel.Text;
//查询客户资料
this.getMessage(txtTel.Text);
}
}
}
}
private void getMessage(string str)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "db_csell.mdb" + ";Persist Security Info=False");
OleDbDataAdapter dap = new OleDbDataAdapter("SELECT * FROM 个人名录表 WHERE 电话='" + str + "'", con);
DataSet ds = new DataSet();
dap.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
txtName.Text = ds.Tables[0].Rows[0]["姓名"].ToString();
txtDuty.Text = ds.Tables[0].Rows[0]["职务"].ToString();
txtAddress.Text = ds.Tables[0].Rows[0]["地址"].ToString();
txtMobile.Text = ds.Tables[0].Rows[0]["手机"].ToString();
txtCompany.Text = ds.Tables[0].Rows[0]["公司名称"].ToString();
txtPostId.Text = ds.Tables[0].Rows[0]["邮编"].ToString();
}
else
{
labStatus.Text = "非本单位会员客户。。。。";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -