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

📄 upform.cs

📁 实习时候做的一个c#的财务管理系统
💻 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
{
    public partial class upform : cwgl.MainForm
    {
        public string xmmc;
        public string xg;
        
        public upform(string xm,string xg)
        {
            InitializeComponent();
            
            this.xmmc = xm;
            this.xg = xg;
        }

        SqlConnection con = new SqlConnection(global::cwgl.Properties.Settings.Default.cwglCon);
 
        private void button8_Click(object sender, EventArgs e)
        {
            string t1 = this.comboBox2.Text;
            string t2 = this.textBox22.Text;
            string t3 = this.textBox1.Text;
            string t4 = this.textBox2.Text;
            string t5 = this.textBox3.Text;
            string t6 = this.textBox4.Text;
            string t7 = this.textBox21.Text;
            string t8 = this.textBox5.Text;
            string t9 = this.textBox6.Text;
            string t10 = this.textBox7.Text;
            string t11 = this.textBox8.Text;
            string t12 = this.textBox9.Text;
            string t13 = this.textBox10.Text;
            string t14 = this.textBox11.Text;
            string t15 = this.textBox12.Text;
            string t16 = this.textBox13.Text;
            string t17 = this.textBox14.Text;
            string t18 = this.textBox15.Text;
            string t19 = this.textBox16.Text;
            string t20 = this.textBox17.Text;
            string t21 = this.textBox18.Text;
            string t22 = this.textBox19.Text;
            string t23 = this.textBox20.Text;
            string t24 = this.label25.Text;
            string t25 = this.comboBox1.Text;
            if (xg == "修改项目")
            {
                try
                {
                    con.Open();
                    string sql = "update xmsz set zykf='"
                        + t1 + "',kfs='"
                        + t2 + "',fl='"
                        + t25 + "',xm='"
                        + t3 + "',mj='"
                        + t4 + "',dj='"
                        + t5 + "',jsjs='"
                        + t6 + "',yjsjs='"
                        + t7 + "',wjsjs='"
                        + t8 + "',sjtc='"
                        + t9 + "',kfxys='"
                        + t10 + "',kfqss='"
                        + t11 + "',kfqws='"
                        + t12 + "',xmjk='"
                        + t13 + "',jkzsr='"
                        + t14 + "',hj='"
                        + t15 + "',zdzc='"
                        + t16 + "',cqzc='"
                        + t17 + "',tdbp='"
                        + t18 + "',tdcr='"
                        + t19 + "',cbzc='"
                        + t20 + "',qtzc='"
                        + t21 + "',zhj='"
                        + t22 + "',jy='"
                        + t23 + "',dt='"
                        + t24 + "' where xm='" + xmmc + "'";
                    SqlCommand com = new SqlCommand(sql, con);
                    com.ExecuteNonQuery();
                    MessageBox.Show("修改成功!", "完成");
                    con.Close();
                    sykf sy = new sykf();
                    sy.ShowDialog();
                }
                catch (SqlException e1)
                {
                    MessageBox.Show(e1.Message, "失败");
                }

            }
        }

        private void upform_Load(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string sql = "select * from xmsz where xm ='" + xmmc + "'";
                SqlCommand com = new SqlCommand(sql, con);
                SqlDataReader sdr = com.ExecuteReader();
                if (sdr.Read() == true)
                {
                    this.comboBox2.Text = Convert.ToString(sdr["zykf"]);
                    this.comboBox1.Text = Convert.ToString(sdr["fl"]);
                    this.textBox1.Text = Convert.ToString(sdr["xm"]);
                    this.textBox22.Text = Convert.ToString(sdr["kfs"]);
                    this.textBox2.Text = Convert.ToString(sdr["mj"]);
                    this.textBox3.Text = Convert.ToString(sdr["dj"]);
                    this.textBox4.Text = Convert.ToString(sdr["jsjs"]);
                    this.textBox21.Text = Convert.ToString(sdr["yjsjs"]);
                    this.textBox5.Text = Convert.ToString(sdr["wjsjs"]);
                    this.textBox6.Text = Convert.ToString(sdr["sjtc"]);
                    this.textBox7.Text = Convert.ToString(sdr["kfxys"]);
                    this.textBox8.Text = Convert.ToString(sdr["kfqss"]);
                    this.textBox9.Text = Convert.ToString(sdr["kfqws"]);
                    this.textBox10.Text = Convert.ToString(sdr["xmjk"]);
                    this.textBox11.Text = Convert.ToString(sdr["jkzsr"]);
                    this.textBox12.Text = Convert.ToString(sdr["hj"]);
                    this.textBox13.Text = Convert.ToString(sdr["zdzc"]);
                    this.textBox14.Text = Convert.ToString(sdr["cqzc"]);
                    this.textBox15.Text = Convert.ToString(sdr["tdbp"]);
                    this.textBox16.Text = Convert.ToString(sdr["tdcr"]);
                    this.textBox17.Text = Convert.ToString(sdr["cbzc"]);
                    this.textBox18.Text = Convert.ToString(sdr["qtzc"]);
                    this.textBox19.Text = Convert.ToString(sdr["zhj"]);
                    this.textBox20.Text = Convert.ToString(sdr["jy"]);
                    sdr.Close();
                   
                }
                else
                {
                    MessageBox.Show("请选择具体项目", "错误");
                    this.Close();
                    return;
                }


            }
            catch (SqlException e1)
            {
                MessageBox.Show(e1.Message, "数据库连接错误");
            }
            finally
            {
                con.Close();

            }
        }

        private bool Boolean()
        {
            throw new Exception("The method or operation is not implemented.");
        }

       
    }
}

⌨️ 快捷键说明

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