Beispiel #1
0
        /// <summary>
        /// 修改信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("请选择要修改的数据!");
                return;
            }
            linq = new linqtisqlClassesDataContext(conn);//实例化Linq连接对象
            //根据员工编号获取要修改的员工信息
            var result = from employee in linq.员工信息
                         where employee.员工编号 == textBox1.Text
                         select employee;

            //对指定的员工信息进行修改
            foreach (员工信息 tbemployee in result)
            {
                tbemployee.员工编号 = textBox1.Text;
                tbemployee.员工姓名 = textBox2.Text;
                tbemployee.性别   = comboBox1.Text;
                tbemployee.年龄   = textBox3.Text;
                tbemployee.电话   = textBox4.Text;
                tbemployee.地址   = textBox5.Text;
                tbemployee.邮箱   = textBox6.Text;
                linq.SubmitChanges();
            }
            MessageBox.Show("信息修改成功!");
            BindInfo();
        }
Beispiel #2
0
        /// <summary>
        /// 添加数据库信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            linq = new linqtisqlClassesDataContext(conn); //实例化Linq连接对象
            员工信息 employee = new 员工信息();                   //实例化"员工信息"类对象

            //为"员工信息"类中的员工实体进行赋值
            employee.员工编号 = textBox1.Text;
            employee.员工姓名 = textBox2.Text;
            employee.性别   = comboBox1.Text;
            employee.年龄   = textBox3.Text;
            employee.电话   = textBox4.Text;
            employee.地址   = textBox5.Text;
            employee.邮箱   = textBox6.Text;
            linq.员工信息.InsertOnSubmit(employee); //添加员工信息
            linq.SubmitChanges();               //提交操作
            MessageBox.Show("信息添加成功");
            BindInfo();
        }
Beispiel #3
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("请选择要删除的信息!");
                return;
            }
            linq = new linqtisqlClassesDataContext(conn);//实例化linq连接对象
            //根据员工编号查询出要删除的员工信息
            var result = from employee in linq.员工信息
                         where employee.员工编号 == textBox1.Text
                         select employee;

            //删除选择的员工信息
            linq.员工信息.DeleteAllOnSubmit(result);
            //提交操作
            linq.SubmitChanges();
            MessageBox.Show("信息删除成功!");
            BindInfo();
        }