Esempio n. 1
0
        /// <summary>
        /// 判断不同的单元格中不同控件的处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvBlackList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvBlackList.Columns[e.ColumnIndex].Name == "buttonEdit")
            {
                DriverList driver = new DriverList();
                driver.Id = dgvBlackList.CurrentRow.Cells[2].Value.ToString();
                driver.User_ChineseName       = dgvBlackList.CurrentRow.Cells[3].Value.ToString();
                driver.User_EnglishName       = dgvBlackList.CurrentRow.Cells[4].Value.ToString();
                driver.Department_ChineseName = dgvBlackList.CurrentRow.Cells[5].Value.ToString();
                driver.Department_EnglishName = dgvBlackList.CurrentRow.Cells[6].Value.ToString();
                driver.Job                   = dgvBlackList.CurrentRow.Cells[7].Value.ToString();
                driver.Sex                   = dgvBlackList.CurrentRow.Cells[8].Value.ToString();
                driver.Birthdy               = dgvBlackList.CurrentRow.Cells[9].Value.ToString();
                driver.Identification_Type   = dgvBlackList.CurrentRow.Cells[10].Value.ToString();
                driver.Identification_Number = dgvBlackList.CurrentRow.Cells[11].Value.ToString();
                driver.Employer              = dgvBlackList.CurrentRow.Cells[12].Value.ToString();
                driver.Telephone             = dgvBlackList.CurrentRow.Cells[13].Value.ToString();
                Form blackNameListEdit = new BlackNameListEdit(driver, this);
                blackNameListEdit.Show();
            }
            if (dgvBlackList.Columns[e.ColumnIndex].Name == "btnDelete")
            {
                string getblacklistsql = "select ID ,User_ChineseName as 中文,User_EnglishName as 英文,Department_ChineseName as 单位名称中文,Department_EnglishName as 单位名称英文,Job as 职务,Sex as 性别,Birthdy as 出生日期,Identification_Type as 身份证件类型,Identification_Number as 身份证件号码,Employer as 工作单位,TELEPHONE as 联系方式 from TB_BlacakList ";
                if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int    id  = Convert.ToInt32(dgvBlackList.CurrentRow.Cells[2].Value.ToString());
                    string sql = "delete from TB_BlacakList where ID=" + id + "";
                    try
                    {
                        if (driverListBll.ExecuteSql(sql))
                        {
                            MessageBox.Show("删除成功");

                            dgvBlackList.DataSource       = driverListBll.FindAll_infos(getblacklistsql);
                            dgvBlackList.Rows[0].Selected = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }



                DataTable dtDriverList = driverListBll.FindAll_infos(getblacklistsql);

                dgvBlackList.DataSource = dtDriverList;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 判断不同的单元格中不同控件的处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvBlackList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvBlackList.Columns[e.ColumnIndex].Name == "buttonEdit")
            {

                DriverList driver = new DriverList();
                driver.Id = dgvBlackList.CurrentRow.Cells[2].Value.ToString();
                driver.User_ChineseName = dgvBlackList.CurrentRow.Cells[3].Value.ToString();
                driver.User_EnglishName = dgvBlackList.CurrentRow.Cells[4].Value.ToString();
                driver.Department_ChineseName = dgvBlackList.CurrentRow.Cells[5].Value.ToString();
                driver.Department_EnglishName = dgvBlackList.CurrentRow.Cells[6].Value.ToString();
                driver.Job = dgvBlackList.CurrentRow.Cells[7].Value.ToString();
                driver.Sex = dgvBlackList.CurrentRow.Cells[8].Value.ToString();
                driver.Birthdy = dgvBlackList.CurrentRow.Cells[9].Value.ToString();
                driver.Identification_Type = dgvBlackList.CurrentRow.Cells[10].Value.ToString();
                driver.Identification_Number = dgvBlackList.CurrentRow.Cells[11].Value.ToString();
                driver.Employer = dgvBlackList.CurrentRow.Cells[12].Value.ToString();
                driver.Telephone = dgvBlackList.CurrentRow.Cells[13].Value.ToString();
                Form blackNameListEdit = new BlackNameListEdit(driver,this);
                blackNameListEdit.Show();
            }
            if (dgvBlackList.Columns[e.ColumnIndex].Name == "btnDelete")
            {
                string getblacklistsql = "select ID ,User_ChineseName as 中文,User_EnglishName as 英文,Department_ChineseName as 单位名称中文,Department_EnglishName as 单位名称英文,Job as 职务,Sex as 性别,Birthdy as 出生日期,Identification_Type as 身份证件类型,Identification_Number as 身份证件号码,Employer as 工作单位,TELEPHONE as 联系方式 from TB_BlacakList ";
                if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(dgvBlackList.CurrentRow.Cells[2].Value.ToString());
                    string sql = "delete from TB_BlacakList where ID=" + id + "";
                    try
                    {
                        if (driverListBll.ExecuteSql(sql))
                        {
                            MessageBox.Show("删除成功");

                            dgvBlackList.DataSource = driverListBll.FindAll_infos(getblacklistsql);
                            dgvBlackList.Rows[0].Selected = false;

                        }
                    }
                    catch (Exception ex)
                    {

                        throw;
                    }
                }

                DataTable dtDriverList = driverListBll.FindAll_infos(getblacklistsql);

                dgvBlackList.DataSource = dtDriverList;
            }
        }