?? frmyfxx.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 SMS
{
public partial class frmYfxx : Form
{
public frmYfxx()
{
InitializeComponent();
}
private void frmYfxx_Load(object sender, EventArgs e)
{
BindSms();
comboBox1.SelectedIndex = 0;
comboBox1.SelectedText = "電話號碼";
}
private void BindSms()
{
OleDbConnection conn = BaseClass.ConnClass.DataConn();
OleDbDataAdapter da = new OleDbDataAdapter("select * from tb_TelSend order by ID desc",conn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("確定刪除嗎?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
if (dataGridView1.SelectedCells.Count > 0)
{
string id = dataGridView1.SelectedCells[0].Value.ToString();
string str = "delete from tb_TelSend where ID=" + id;
DelData(str);
MessageBox.Show("刪除成功");
BindSms();
}
else
{
MessageBox.Show("請選擇要刪除的信息");
}
}
}
private void DelData(string strsql)
{
OleDbConnection conn = BaseClass.ConnClass.DataConn();
conn.Open();
OleDbCommand cmd = new OleDbCommand(strsql,conn);
cmd.ExecuteNonQuery();
conn.Close();
}
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("確定刪除嗎?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
string str = "delete from tb_TelSend";
DelData(str);
MessageBox.Show("信息已經全部清空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
BindSms();
}
}
private void button4_Click(object sender, EventArgs e)
{
BindSms();
}
private void button3_Click(object sender, EventArgs e)
{
string strsql = "";
if (textBox1.Text == "")
{
MessageBox.Show("請輸入關鍵字");
}
else
{
string comstr=comboBox1.SelectedItem.ToString();
switch(comstr)
{
case "手機號碼": strsql = "select * from tb_TelSend where TelNum like '%" + textBox1.Text + "%'"; break;
case "短信內容": strsql = "select * from tb_TelSend where TelContent like '%" + textBox1.Text + "%'"; break;
case "發送時間": strsql = "select * from tb_TelSend where TelTime like '%" + textBox1.Text + "%'"; break;
}
OleDbConnection conn = BaseClass.ConnClass.DataConn();
OleDbDataAdapter da = new OleDbDataAdapter(strsql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -