📄 crjs.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.SqlClient;
namespace cwgl.inc
{
public partial class crjs : cwgl.inc.bpjs
{
public crjs(TextBox tb1,string tx1)
{
InitializeComponent();
this.tb = tb1;
this.tx = tx1;
}
SqlConnection con = new SqlConnection(global::cwgl.Properties.Settings.Default.cwglCon);
private void button1_Click(object sender, EventArgs e)
{
string t1 = this.tx;
string t2 = this.comboBox1.Text;
string t3 = this.textBox1.Text;
string t4 = this.textBox2.Text;
string t5 = this.textBox3.Text;
string t6 = this.textBox4.Text;
string t7 = this.textBox5.Text;
string t8 = this.textBox6.Text;
string t9 = this.textBox7.Text;
string t10 = "1";
try
{
con.Open();
string sql = "insert into jsb (xmm,sfxm,bz,jfs,ytj,yfj,yjf,sjf,db,qb) values('"
+ t1 + "','" + t2 + "','" + t3 + "','" + t4 + "','" + t5 + "','"
+ t6 + "','" + t7 + "','" + t8 + "','" + t9 + "','" + t10 + "')";
SqlCommand com = new SqlCommand(sql, con);
com.ExecuteNonQuery();
string sql1 = "SELECT sfxm AS 收费项目名称, bz AS 标准,jfs AS [报批(出让)通知缴费数],ytj AS 应退金额, yfj AS 应返金额,yjf AS 应缴纳费用,sjf AS 实际缴纳费用, db AS 实缴与应缴对比 FROM dbo.jsb where (xmm='" + tx + "' and qb= '1')";
SqlCommand com1 = new SqlCommand(sql1, con);
SqlDataAdapter sda = new SqlDataAdapter(com1);
DataTable dt = new DataTable();
sda.Fill(dt);
this.dataGridView1.DataSource = dt;
con.Close();
this.textBox8.Text = Convert.ToString(dt.Compute("Sum(实缴与应缴对比)", ""));
MessageBox.Show("添加成功!", "完成");
}
catch (SqlException e3)
{
MessageBox.Show("已经存在收费项目,请重新选择!", "失败");
}
}
private void crjs_Load(object sender, EventArgs e)
{
try
{
con.Open();
string sql = "SELECT sfxm AS 收费项目名称, bz AS 标准,jfs AS [报批(出让)通知缴费数], ytj AS 应退金额, yfj AS 应返金额, yjf AS 应缴纳费用, sjf AS 实际缴纳费用, db AS 实缴与应缴对比 FROM dbo.jsb where (xmm='" + tx + "' and qb='1')";
SqlCommand com = new SqlCommand(sql, con);
SqlDataAdapter sda = new SqlDataAdapter(com);
DataTable dt = new DataTable();
sda.Fill(dt);
this.dataGridView1.DataSource = dt;
con.Close();
this.textBox8.Text = Convert.ToString(dt.Compute("Sum(实缴与应缴对比)", ""));
}
catch (SqlException e1)
{
MessageBox.Show(e1.Message,"数据库连接出错");
}
}
private void button2_Click(object sender, EventArgs e)
{
string t1 = this.tx;
string t2 = this.comboBox1.Text;
string t3 = this.textBox1.Text;
string t4 = this.textBox2.Text;
string t5 = this.textBox3.Text;
string t6 = this.textBox4.Text;
string t7 = this.textBox5.Text;
string t8 = this.textBox6.Text;
string t9 = this.textBox7.Text;
string t10 = "1";
try
{
con.Open();
string sql = "update jsb set xmm='"
+ t1 + "',sfxm='"
+ t2 + "',bz='"
+ t3 + "',jfs='"
+ t4 + "',ytj='"
+ t5 + "',yfj='"
+ t6 + "',yjf='"
+ t7 + "',sjf='"
+ t8 + "',db='"
+ t9 + "',qb='"
+ t10 + "' where xmm='" + t1 + "' and sfxm= '" + t2 + "'";
SqlCommand com = new SqlCommand(sql, con);
com.ExecuteNonQuery();
string sql1 = "SELECT sfxm AS 收费项目名称, bz AS 标准,jfs AS [报批(出让)通知缴费数], ytj AS 应退金额, yfj AS 应返金额, yjf AS 应缴纳费用, sjf AS 实际缴纳费用, db AS 实缴与应缴对比 FROM dbo.jsb where (xmm='" + tx + "' and qb='1')";
SqlCommand com1 = new SqlCommand(sql1, con);
SqlDataAdapter sda = new SqlDataAdapter(com1);
DataTable dt = new DataTable();
sda.Fill(dt);
this.dataGridView1.DataSource = dt;
con.Close();
this.textBox8.Text = Convert.ToString(dt.Compute("Sum(实缴与应缴对比)", ""));
MessageBox.Show("修改成功!", "完成");
}
catch (SqlException e1)
{
MessageBox.Show("修改失败!", "失败");
}
}
private void button4_Click(object sender, EventArgs e)
{
string sfx = Convert.ToString(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value);
try
{
con.Open();
string sql = "delete from jsb where sfxm='" + sfx + "' and xmm ='" + tx + "'";
SqlCommand com = new SqlCommand(sql, con);
com.ExecuteNonQuery();
string sql1 = "SELECT sfxm AS 收费项目名称, bz AS 标准,jfs AS [报批(出让)通知缴费数], ytj AS 应退金额, yfj AS 应返金额, yjf AS 应缴纳费用, sjf AS 实际缴纳费用, db AS 实缴与应缴对比 FROM dbo.jsb where (xmm='" + tx + "' and qb='1')";
SqlCommand com1 = new SqlCommand(sql1, con);
SqlDataAdapter sda = new SqlDataAdapter(com1);
DataTable dt = new DataTable();
sda.Fill(dt);
this.dataGridView1.DataSource = dt;
this.textBox8.Text = Convert.ToString(dt.Compute("Sum(实缴与应缴对比)", ""));
MessageBox.Show("删除收费项目成功!", "完成");
con.Close();
}
catch (SqlException e1)
{
MessageBox.Show("删除收费项目失败!", "失败");
}
}
private void button3_Click(object sender, EventArgs e)
{
tb.Text = this.textBox8.Text.ToString().Trim();
this.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -