Exemplo n.º 1
0
        public void ShowEmployee()
        {
            string          ShowStr = "select * from member";
            DatabaseControl dc      = new DatabaseControl();
            DataTable       d1      = new DataTable();

            d1 = dc.ExecuteQuery(ShowStr);
            if (d1 != null && d1.Rows.Count > 0)
            {
                dataGridView1.DataSource = d1;    //将查询结果放入到dataGridView;
                           
            }
        }
Exemplo n.º 2
0
        private void Delete_Employee_Click(object sender, EventArgs e)
        {
            int    a            = dataGridView1.CurrentRow.Index;
            string strID        = dataGridView1.Rows[a].Cells[0].Value.ToString();
            string AlertMessage = "确定要删除id为" + strID + "的员工吗?";

            if (MessageBox.Show(AlertMessage, "警告", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                //确定删除
                string          sqlStr          = "DELETE FROM member where  id =" + strID;
                DatabaseControl databaseControl = new DatabaseControl();
                int             d2 = databaseControl.ExecuteUpdate(sqlStr);//执行后会有返回值,是int类型,如果执行失败会返回0;
                if (d2 != 0)
                {
                    MessageBox.Show("删除成功!", "添加结果",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("删除失败!此工号不存在!", "添加结果",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string EmployeeId       = textBox1.Text;
            string EmployeeName     = textBox2.Text;
            string EmployeeSex      = textBox3.Text;
            string EmployeeWorkType = textBox4.Text;
            string EmployeeAge      = textBox5.Text;
            string sqlStr           = "INSERT INTO member " +
                                      "VALUES(" + EmployeeId + ", '" + EmployeeWorkType + "', " + EmployeeAge + ", '" + EmployeeSex + "', '" + EmployeeName + "')";
            DatabaseControl databaseControl = new DatabaseControl();
            int             d2 = databaseControl.ExecuteUpdate(sqlStr);//执行后会有返回值,是int类型,如果执行失败会返回0;

            if (d2 != 0)
            {
                MessageBox.Show("添加成功!", "添加结果",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("添加失败!此工号已存在!", "添加结果",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string WorkTypeName    = textBox1.Text;
            string WorkTypeBase    = textBox2.Text;
            string WorkTypeGrade   = textBox3.Text;
            string WorkTypeDept    = textBox4.Text;
            string WorkTypePenalty = textBox5.Text;
            string sqlStr          = "INSERT INTO work_type " +
                                     "VALUES('" + WorkTypeName + "', " + WorkTypeBase + ", " + WorkTypeGrade + ", '" + WorkTypeDept + "', " + WorkTypePenalty + ")";
            DatabaseControl databaseControl = new DatabaseControl();
            int             d2 = databaseControl.ExecuteUpdate(sqlStr);//执行后会有返回值,是int类型,如果执行失败会返回0;

            if (d2 != 0)
            {
                MessageBox.Show("添加成功!", "添加结果",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("添加失败!此工种已存在!", "添加结果",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }