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

📄 form1.cs

📁 基于C#和SQL开发的合同管理系统。 可以实现一些简单的添加、删除功能。
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.textBox3.TabIndex = 12;
			this.textBox3.Text = "";
			// 
			// label5
			// 
			this.label5.Font = new System.Drawing.Font("楷体_GB2312", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label5.Location = new System.Drawing.Point(40, 384);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(136, 32);
			this.label5.TabIndex = 11;
			this.label5.Text = "合同额";
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(184, 432);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(264, 31);
			this.textBox4.TabIndex = 14;
			this.textBox4.Text = "";
			// 
			// label6
			// 
			this.label6.Font = new System.Drawing.Font("楷体_GB2312", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label6.Location = new System.Drawing.Point(40, 432);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(136, 32);
			this.label6.TabIndex = 13;
			this.label6.Text = "签定日期";
			// 
			// textBox5
			// 
			this.textBox5.Location = new System.Drawing.Point(184, 480);
			this.textBox5.Name = "textBox5";
			this.textBox5.Size = new System.Drawing.Size(264, 31);
			this.textBox5.TabIndex = 16;
			this.textBox5.Text = "";
			// 
			// label7
			// 
			this.label7.Font = new System.Drawing.Font("楷体_GB2312", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label7.Location = new System.Drawing.Point(40, 480);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(136, 32);
			this.label7.TabIndex = 15;
			this.label7.Text = "销售人";
			// 
			// button1
			// 
			this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.button1.Location = new System.Drawing.Point(488, 384);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(112, 40);
			this.button1.TabIndex = 17;
			this.button1.Text = "删  除";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.button2.Location = new System.Drawing.Point(488, 336);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(112, 40);
			this.button2.TabIndex = 18;
			this.button2.Text = "修  改";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.button3.Location = new System.Drawing.Point(488, 288);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(112, 40);
			this.button3.TabIndex = 19;
			this.button3.Text = "插  入";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// oleDbDataAdapter2
			// 
			this.oleDbDataAdapter2.SelectCommand = this.oleDbSelectCommand2;
			this.oleDbDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																										new System.Data.Common.DataTableMapping("Table", "EMPLOYEE", new System.Data.Common.DataColumnMapping[] {
																																																					new System.Data.Common.DataColumnMapping("EMPLOYEE_ID", "EMPLOYEE_ID")})});
			// 
			// oleDbSelectCommand2
			// 
			this.oleDbSelectCommand2.CommandText = "SELECT EMPLOYEE_ID FROM EMPLOYEE";
			this.oleDbSelectCommand2.Connection = this.oleDbConnection1;
			// 
			// dataSet21
			// 
			this.dataSet21.DataSetName = "DataSet2";
			this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(12, 24);
			this.ClientSize = new System.Drawing.Size(640, 582);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.exit);
			this.Controls.Add(this.search);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.CON_NAME);
			this.Controls.Add(this.CON_ID);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Font = new System.Drawing.Font("楷体_GB2312", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.Name = "Form1";
			this.Text = "项目管理";
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
			
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.oleDbDataAdapter1.Fill(this.dataSet11);
			this.command = this.oleDbDataAdapter1.SelectCommand.CommandText;
			this.tmpcom = this.oleDbDataAdapter2.SelectCommand.CommandText;
		}

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

		private void search_Click(object sender, System.EventArgs e)
		{
			string strfilter;

			if (CON_ID.Text.Trim().Length != 0)
			{
				strfilter = " and CONTRACT.CONTRACT_ID = '";
				strfilter += CON_ID.Text.Trim() + "'";
			}
			else
			{
				strfilter = " and CONTRACT.NAME like '";
				strfilter += CON_NAME.Text.Trim() + "%'";
			}

			this.oleDbDataAdapter1.SelectCommand.CommandText = this.command + strfilter;
			this.dataSet11.Clear();
			this.oleDbDataAdapter1.Fill(this.dataSet11);
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			string strInsert = "insert into CONTRACT(CONTRACT_ID,NAME,AMOUNT,BUSINESS_DATE,SALE_ID) values(?,?,?,?,?)";
			OleDbCommand comInsert = new OleDbCommand(strInsert);
			comInsert.Connection = this.oleDbConnection1;

			comInsert.Parameters.Add("@p1",OleDbType.Char,18).Value = this.textBox1.Text;
			comInsert.Parameters.Add("@p2",OleDbType.VarChar,64).Value = this.textBox2.Text;
			comInsert.Parameters.Add("@p3",OleDbType.Numeric,10).Value = double.Parse(this.textBox3.Text);
			comInsert.Parameters.Add("@p4",OleDbType.Date,28).Value = this.textBox4.Text;

			this.oleDbDataAdapter2.SelectCommand.CommandText =
				tmpcom + " where EMPLOYEE.NAME = '" + this.textBox5.Text.Trim() + "'";
			this.dataSet21.Clear();
			this.oleDbDataAdapter2.Fill(this.dataSet21);
			string tmp = this.dataSet21.Tables["EMPLOYEE"].Rows[0]["EMPLOYEE_ID"].ToString();
			comInsert.Parameters.Add("@p5",OleDbType.Numeric,10).Value = double.Parse(tmp);

			this.oleDbConnection1.Open();
			comInsert.ExecuteNonQuery();
			this.oleDbConnection1.Close();

			this.dataSet11.Clear();
			this.oleDbDataAdapter1.Fill(this.dataSet11);
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			string strUpdate = "update CONTRACT set NAME = ?,AMOUNT = ?,BUSINESS_DATE = ?,SALE_ID = ? where CONTRACT_ID = ?";
			OleDbCommand comUpdate = new OleDbCommand(strUpdate);
			comUpdate.Connection = this.oleDbConnection1;

			comUpdate.Parameters.Add("@p1",OleDbType.VarChar,64).Value = this.textBox2.Text;
			comUpdate.Parameters.Add("@p2",OleDbType.Numeric,10).Value = double.Parse(this.textBox3.Text);
			comUpdate.Parameters.Add("@p3",OleDbType.Date,28).Value = this.textBox4.Text;

			this.oleDbDataAdapter2.SelectCommand.CommandText =
				tmpcom + " where EMPLOYEE.NAME = '" + this.textBox5.Text.Trim() + "'";
			this.dataSet21.Clear();
			this.oleDbDataAdapter2.Fill(this.dataSet21);
			string tmp = this.dataSet21.Tables["EMPLOYEE"].Rows[0]["EMPLOYEE_ID"].ToString();
			comUpdate.Parameters.Add("@p4",OleDbType.Numeric,10).Value = double.Parse(tmp);

			comUpdate.Parameters.Add("@p5",OleDbType.Char,18).Value = this.textBox1.Text;

			this.oleDbConnection1.Open();
			comUpdate.ExecuteNonQuery();
			this.oleDbConnection1.Close();

			this.dataSet11.Clear();
			this.oleDbDataAdapter1.Fill(this.dataSet11);
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string contractID = this.dataGrid1[this.dataGrid1.CurrentRowIndex,0].ToString();
			string strDelete = "delete CONTRACT where CONTRACT_ID = '" + contractID + "'";
			OleDbCommand comDelete = new OleDbCommand(strDelete);
			comDelete.Connection = this.oleDbConnection1;

			this.oleDbConnection1.Open();
			comDelete.ExecuteNonQuery();
			this.oleDbConnection1.Close();

			this.dataSet11.Clear();
			this.oleDbDataAdapter1.Fill(this.dataSet11);
		}
	}
}

⌨️ 快捷键说明

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