⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sykf.cs

📁 实习时候做的一个c#的财务管理系统
💻 CS
字号:
/*
 * Created by SharpDevelop.
 * User: ??
 * Date: 2008-3-13
 * Time: 21:33
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;

namespace cwgl
{
	/// <summary>
	/// Description of sykf.
	/// </summary>
	public partial class sykf : Form
    {

		public sykf()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}



        SqlConnection con = new SqlConnection(global::cwgl.Properties.Settings.Default.cwglCon);
        public string xmm = "";

        private void sykf_Load(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string sql = "SELECT  项目名称 , 项目类型 , 分类, 结余 ,日期  FROM v_xmsz";
                SqlCommand com = new SqlCommand(sql, con);
                SqlDataAdapter sda = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                this.dataGridView1.DataSource = dt;
                
                con.Close();
            }
            catch (SqlException e1)
            {
                MessageBox.Show(e1.Message, "数据库连接出错");
            }
        }


        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
           
                //dataGridView1.Rows[0].Selected = true; 
                upform uf = new upform(this.xmm, this.button4.Text);
                uf.ShowDialog();
            
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                   if(xmm != "")
                   {
                    con.Open();
                    string sql = "delete from xmsz where xm='" + xmm + "'";
                    SqlCommand com = new SqlCommand(sql, con);
                    com.ExecuteNonQuery();

                    string sql1 = "SELECT  项目名称,项目类型,分类, 结余, 日期 FROM v_xmsz";
                    SqlCommand com1 = new SqlCommand(sql1, con);
                    SqlDataAdapter sda = new SqlDataAdapter(com1);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    this.dataGridView1.DataSource = dt;
                    com1.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("项目删除成功!", "完成");
                }
                else
                {
                    MessageBox.Show("请线选择需要删除的项目","提示");
                }
                
            }
            catch (SqlException e1) 
            { 
                MessageBox.Show(e1.Message,"数据库连接出错");
            }
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            xmm = (string)dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString().Trim();
        }

       



	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -