public static void MemoryImage( DriverList driverList) { OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "//translate.accdb"); OleDbCommand command = new OleDbCommand(); //command.CommandText = "insert into TB_DriverList values(@User_ChineseName,@User_EnglishName,@Department_ChineseName,@Department_EnglishName,@Job,@Sex,@Birthdy,@Identification_Type,@Identification_Number,@Employer,@TELEPHONE,@Photo,@CensusRegister,@CurrentResidence)"; command.CommandText = "insert into TB_DriverList (User_ChineseName,User_EnglishName,Department_ChineseName,Department_EnglishName,Job,Sex,Birthdy,Identification_Type,Identification_Number,Employer,TELEPHONE,Photo,CensusRegister,CurrentResidence) values(@User_ChineseName,@User_EnglishName,@Department_ChineseName,@Department_EnglishName,@Job,@Sex,@Birthdy,@Identification_Type,@Identification_Number,@Employer,@TELEPHONE,@Photo,@CensusRegister,@CurrentResidence)"; command.Parameters.AddWithValue("@User_ChineseName", driverList.User_EnglishName); command.Parameters.AddWithValue("@User_EnglishName", driverList.Department_EnglishName); command.Parameters.AddWithValue("@Department_ChineseName", driverList.Department_ChineseName); command.Parameters.AddWithValue("@Department_EnglishName", driverList.Department_EnglishName); command.Parameters.AddWithValue("@Job", driverList.Job); command.Parameters.AddWithValue("@Sex", driverList.Sex); command.Parameters.AddWithValue("@Birthdy", driverList.Birthdy); command.Parameters.AddWithValue("@Identification_Type", driverList.Identification_Type); command.Parameters.AddWithValue("@Identification_Number", driverList.Identification_Number); command.Parameters.AddWithValue("@Employer", driverList.Employer); command.Parameters.AddWithValue("@TELEPHONE", driverList.Employer); command.Parameters.AddWithValue("@Photo", driverList.Photo); command.Parameters.AddWithValue("@CensusRegister", driverList.CensusRegister); command.Parameters.AddWithValue("@CurrentResidence", driverList.CensusRegister); command.Connection = conn; conn.Open(); int i = command.ExecuteNonQuery(); conn.Close(); command = null; }
/// <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; } }
/// <summary> ///获取司机列表每行的数据 /// </summary> public DriverList GetDriverByRow() { DriverList driver = new DriverList(); driver.Id = dgvDriverListSJ.CurrentRow.Cells["Id"].Value.ToString(); driver.User_ChineseName = dgvDriverListSJ.CurrentRow.Cells["中文名称"].Value.ToString(); driver.User_EnglishName = dgvDriverListSJ.CurrentRow.Cells["英文名称"].Value.ToString(); driver.Department_ChineseName = dgvDriverListSJ.CurrentRow.Cells["单位中文名称"].Value.ToString(); driver.Department_EnglishName = dgvDriverListSJ.CurrentRow.Cells["单位英文名称"].Value.ToString(); driver.Job = dgvDriverListSJ.CurrentRow.Cells["职务"].Value.ToString(); driver.Birthdy = dgvDriverListSJ.CurrentRow.Cells["出生日期"].Value.ToString(); driver.Identification_Type = dgvDriverListSJ.CurrentRow.Cells["身份证件类型"].Value.ToString(); driver.Identification_Number = dgvDriverListSJ.CurrentRow.Cells["身份证件号码"].Value.ToString(); driver.Sex = dgvDriverListSJ.CurrentRow.Cells["性别"].Value.ToString(); driver.Telephone = dgvDriverListSJ.CurrentRow.Cells["联系方式"].Value.ToString(); return driver; }
/// <summary> /// 编辑司机数据 /// </summary> /// <param name="Id"></param> public void UpdateDriver(DriverList driverList) { string sql = "update TB_DriverList set "; if (!string.IsNullOrEmpty(driverList.User_ChineseName) || driverList.User_ChineseName != "") { sql += "User_ChineseName='" + driverList.User_ChineseName + "'"; } if (!string.IsNullOrEmpty(driverList.User_EnglishName) || driverList.User_EnglishName != "") { sql += ",User_EnglishName='" + driverList.User_EnglishName + "'"; } if (!string.IsNullOrEmpty(driverList.Department_ChineseName) || driverList.Department_ChineseName != "") { sql += ",Department_ChineseName='" + driverList.Department_ChineseName + "'"; } if (!string.IsNullOrEmpty(driverList.Department_EnglishName) || driverList.Department_EnglishName != "") { sql += ",Department_EnglishName='" + driverList.Department_EnglishName + "'"; } if (!string.IsNullOrEmpty(driverList.Job) || driverList.Job != "") { sql += ",Job='" + driverList.Job + "'"; } if (!string.IsNullOrEmpty(driverList.Sex) || driverList.Sex != "") { sql += ",Sex='" + driverList.Sex + "'"; } if (!string.IsNullOrEmpty(driverList.Birthdy) || driverList.Birthdy != "") { sql += ",Birthdy='" + driverList.Birthdy + "'"; } if (!string.IsNullOrEmpty(driverList.Identification_Type) || driverList.Identification_Type != "") { sql += ",Identification_Type='" + driverList.Identification_Type + "'"; } if (!string.IsNullOrEmpty(driverList.Identification_Number) || driverList.Identification_Number != "") { sql += ",Identification_Number='" + driverList.Identification_Number + "'"; } if (!string.IsNullOrEmpty(driverList.Employer) || driverList.Employer != "") { sql += ",Employer='" + driverList.Employer + "'"; } if (!string.IsNullOrEmpty(driverList.Telephone) || driverList.Telephone != "") { sql += ",TELEPHONE='" + driverList.Telephone + "'"; } sql += " where id=" + driverList.Id + ""; AccessHelper.SQLExecute(sql); }
public void UpdateDriver(DriverList driverList) { driverListDAL.UpdateDriver(driverList); }
public EditDriverForm(DriverList driverList) { this.driverlist = driverList; InitializeComponent(); labType.Text = "编辑"; }