使用VS2010写出程序实现增删改查

代码已经求人写好了,但是不会建项目 各位大神帮我调试好了发到我邮箱吧~
861236126@qq.com代码在下面图片说明

建立数据库的代码
CREATE TABLE [dbo].Table NOT NULL,
[姓名] NVARCHAR (20) NOT NULL,
[性别] BIT NOT NULL,
[出生日期] DATETIME NOT NULL,
[工作年限] INT NOT NULL,
[电话号码] NVARCHAR (20) NOT NULL,
[家庭地址] NVARCHAR (100) NOT NULL,
PRIMARY KEY CLUSTERED ([工号] ASC)
);

VS的代码

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

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void Form1_Load(object sender, EventArgs e)
    {
        foreach (string s in "工号,姓名,性别,出生日期,工作年限,电话号码,家庭地址".Split(','))
            dataGridView1.Columns.Add(s, s);
        LoadList();
    }

    private void LoadList()
    {
        db1Entities db = new db1Entities();
        dataGridView1.Rows.Clear();
        foreach (var item in db.Tables)
            dataGridView1.Rows.Add(item.工号, item.姓名, item.性别 ? "男" : "女", item.出生日期, item.工作年限, item.电话号码, item.家庭地址);
    }

    private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
    {

        db1Entities db = new db1Entities();
        if (dataGridView1.Rows[e.RowIndex].Cells[0].Value != null && db.Tables.ToList().Any(x => x.工号 == int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString())))
        {
            var t = db.Tables.ToList().Single(x => x.工号 == int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()));
            t.姓名 = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            t.性别 = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() == "男";
            t.出生日期 = DateTime.Parse(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
            t.工作年限 = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
            t.电话号码 = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
            t.家庭地址 = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
        }
        else
        {
            if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == null) return;
            var t = new Table();
            t.姓名 = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            t.性别 = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() == "男";
            t.出生日期 = DateTime.Parse(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
            t.工作年限 = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
            t.电话号码 = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
            t.家庭地址 = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
            db.Tables.Add(t);
            dataGridView1.Rows[e.RowIndex].Cells[0].Value = t.工号.ToString();
        }
        db.SaveChanges();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        dataGridView1.Rows.Add();
    }

    private void button3_Click(object sender, EventArgs e)
    {
        db1Entities db = new db1Entities();
        var t = db.Tables.ToList().Single(x => x.工号 == int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()));
        db.Tables.Remove(t);
        db.SaveChanges();
        dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
    }

    private void button2_Click(object sender, EventArgs e)
    {
        db1Entities db = new db1Entities();
        var t = db.Tables.ToList().Single(x => x.工号 == int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()));
        t.姓名 = dataGridView1.CurrentRow.Cells[1].Value.ToString();
        t.性别 = dataGridView1.CurrentRow.Cells[2].Value.ToString() == "男";
        t.出生日期 = DateTime.Parse(dataGridView1.CurrentRow.Cells[3].Value.ToString());
        t.工作年限 = int.Parse(dataGridView1.CurrentRow.Cells[4].Value.ToString());
        t.电话号码 = dataGridView1.CurrentRow.Cells[5].Value.ToString();
        t.家庭地址 = dataGridView1.CurrentRow.Cells[5].Value.ToString();
        db.SaveChanges();
    }
}

}

sql语句基础啊,select update insert

个人建议你让帮你写好的人帮你搭建吧,有的人搭建的项目环境不一样,而且数据库也不一样,会出差错。

这个有数据库的连接过程,就算是工程建好。别人的可以连接数据库,工程发到你那里也是一样的不能用:还是要修改与数据库相关的代码。

我觉得你花点钱,大把的人会帮你做。让人帮忙的习惯不太好吧,毕竟别人要花费时间和精力!

来找我吧。这个也是最基本的啊。