• 大小: 396KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-25
  • 语言: C#
  • 标签: c#  源代码  

资源简介

对于员工的增加、删除、更新、查询和添加功能

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    public partial class Employees : Form
    {
      

        public Employees()
        {
            InitializeComponent();
        }
        private System.Data.DataSet myDS;
        private System.Data.SqlClient.SqlDataAdapter myAD;
        private System.Data.SqlClient.SqlCommand myCom;
        private System.Data.SqlClient.SqlConnection myCon;
        private string myConStr =@“Data Source=localhost;Persist Security Info=False;Initial Catalog=Employee;Integrated Security=SSPI“;


        private void ExecuteSQL(string SQL)
        {
           int flag=0;
            myCon= new SqlConnection(myConStr);
            try
            {
                myCon.Open();
                myCom = new SqlCommand(SQL myCon);
                flag=myCom.ExecuteNonQuery();

                if (flag != 0)
                {
                    MessageBox.Show(“执行正确!“);
                }
                else
                {
                    MessageBox.Show(“未能正确执行!“);
                }
            }
            catch (Exception oe)
            {
                MessageBox.Show(oe.Message “Error“);
            }
            finally
            {
                if (myCon.State == ConnectionState.Open)
                    myCon.Close();
            }
        }

        private void Form2_Load(object sender EventArgs e)
        {
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        }
        
        private void button1_Click(object sender EventArgs e)
        {

            string searchStr = string.Format(“select * from Employee where EmployeeID=“ +Convert.ToInt32(textBox1.Text));

            myCon = new SqlConnection(myConStr);
            try
            {
                myCon.Open();
                //myCom = new SqlCommand(searchStr myCon);
                myAD = new SqlDataAdapter(searchStr myCon);
                myDS = new DataSet();
                myAD.Fill(myDS);

                if (myDS != null && myDS.Tables[0].Rows.Count > 0)
                {
                    MessageBox.Show(“已经存在该值,请重新输入!“);
                }
                else
                {
                    
                    string insStr = String.Format(“INSERT INTO Employee(EmployeeIDNameAgeSexIDtitleSalaryPhoneAddressHireDate) values(‘{0}‘‘{1}‘‘{2}‘‘{3}‘‘{4}‘‘{5}‘‘{6}‘‘{7}‘‘{8}‘‘{9}‘)“ textBox1.Text textBox2.Text textBox3.Text textBox4.Text textBox5.Text textBox6.Text textBox7.Text textBox8.Text textBox9.Text textBox10.Text);
                    ExecuteSQL(insStr);
                }
            }
            catch (Exception oe)
            {
                M

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     108032  2014-05-30 19:48  员工登录\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      48640  2014-05-30 19:48  员工登录\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      22984  2014-05-30 19:50  员工登录\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2010-03-18 06:39  员工登录\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       4303  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Employees.cs

     文件      15796  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Employees.Designer.cs

     文件       6019  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Employees.resx

     文件       1229  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Form1.cs

     文件       6669  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Form1.Designer.cs

     文件       5817  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Form1.resx

     文件       5420  2014-05-27 12:49  员工登录\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7164  2014-05-30 19:49  员工登录\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       5120  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       4380  2014-05-30 19:50  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件       1155  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件       9214  2014-05-27 12:49  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache

     文件        180  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Employees.resources

     文件     108032  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe

     文件        180  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources

     文件      48640  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb

     文件      82557  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        180  2014-05-30 19:48  员工登录\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.searchDialog.resources

     文件        505  2014-05-27 12:49  员工登录\WindowsFormsApplication1\Program.cs

     文件      77090  2014-05-30 18:25  员工登录\WindowsFormsApplication1\Properties\4.jpg

     文件       1380  2014-05-27 12:49  员工登录\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       4789  2014-05-30 17:50  员工登录\WindowsFormsApplication1\Properties\images (1).jpg

     文件       3627  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       6413  2014-05-30 19:48  员工登录\WindowsFormsApplication1\Properties\Resources.resx

     文件       1111  2014-05-27 12:49  员工登录\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2014-05-27 12:49  员工登录\WindowsFormsApplication1\Properties\Settings.settings

............此处省略23个文件信息

评论

共有 条评论