📄 tonghua.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Threading;
public partial class tonghua : System.Web.UI.Page
{
Stopwatch nee = new Stopwatch();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
nee.Start();
if (tong.Text == "开始通话")
{
Thread.Sleep(4000);
tong.Text = "通话结束";
nee.Stop();
TimeSpan tt = nee.Elapsed;
string thlx = "";
double x = 0;
if (RadioButton1.Checked) { x = 0.30; thlx = "长途"; }
if (RadioButton2.Checked) { x = 0.20; thlx = "本地"; }
double y = tt.Seconds;
double z = 0;
z = y * x;
Label1.Text = string.Format("通话费用:{0}元", z);
TimeSpan ss = nee.Elapsed;
Label2.Text = string.Format("{0:00}时{1:00}分{2:00}秒", ss.Hours, ss.Minutes, ss.Seconds);
string connString = @"Data Source=.;Initial Catalog=shoujijifei;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
//SqlCommand cmd = new SqlCommand("INSERT INTO fee(shijian,fee,CardNo,leixing) VALUES ('" + Label2.Text + "', '" + z + "', '" + TextBox1.Text + "','" + thlx + "')", conn);
SqlCommand cmd = new SqlCommand("INSERT INTO Call(CardNo,shijian,leixing,fei) VALUES ('" + TextBox1.Text + "','" + Label2.Text + "', '" + thlx + "','" + z + "')", conn);
int i = cmd.ExecuteNonQuery();
if (i != 0)
{
Label3.Text = "记录成功";
}
}
string connString2 = @"Data Source=.;Initial Catalog=shoujijifei;Integrated Security=True";
using (SqlConnection conn2 = new SqlConnection(connString2))
{
conn2.Open();
string sql="UPDATE jifee SET tonghuafee=(SELECT tonghuafee+'"+z+"'from jifee where CardNo='"+TextBox1.Text+"') WHERE CardNo='"+TextBox1.Text+"'";
SqlCommand cmd2 = new SqlCommand(sql, conn2);
int ii = cmd2.ExecuteNonQuery();
if (ii != 0)
{
Label3.Text = "记录成功";
}
}
}
else
{
tong.Text = "通话开始";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -