/// <summary> /// 人员信息修改 /// </summary> /// <param name="info">人员信息</param> /// <returns>bool类型</returns> public Result Update(person_basic info) { Result r = new Result(); try { // 判断是否操作成功 if (new DAL.PersonInfo.PersonBasicDAL().Update(info) > 0) { // 成功 r.Code = RES.OK; r.Message = "添加成功!"; } else { // 失败 r.Code = RES.ERROR; r.Message = "添加失败!"; } } catch (Exception) { } return(r); }
public static person_basic GetSelectPersonBasic(string identityNumber) { person_basic personBasic = null; foreach (person_basic pb in PersonBasics) { if (identityNumber.Equals(pb.identity_number)) { personBasic = pb; break; } } return(personBasic); }
/// <summary> /// 人员信息检索(管理页面) /// </summary> /// <param name="info">查询条件</param> /// <returns>List类型</returns> public List <person_basic> Query(person_basic info) { List <person_basic> list = new List <person_basic>(); try { // 接收列表 list = new DAL.PersonInfo.PersonBasicDAL().Query(info); } catch (Exception) { } // 返回列表 return(list); }
/// <summary> /// 人员信息修改 /// </summary> /// <param name="info">需要更新的人员信息</param> /// <returns>更新条数</returns> public int Update(person_basic info) { try { // sql语句 string sql = "update person_basic set " + "name = @name, former_name = @former_name, gender = @gender, identity_number = @identity_number, birth_date = @birth_date, native_place = @native_place, marry_status = @marry_status, job_status = @job_status, income = @income, temper = @temper, family = @family, person_type_id = @person_type_id, qq = @qq, address = @address, phone = @phone, belong_place_id = @belong_place_id, nation = @nation, input_time = @input_time, user_id = @user_id, isdel = @isdel " + "where id = @id"; // 参数赋值 SqlParameter name = new SqlParameter("@name", info.name); SqlParameter former_name = new SqlParameter("@former_name", info.former_name); SqlParameter gender = new SqlParameter("@gender", info.gender); SqlParameter identity_number = new SqlParameter("@identity_number", info.identity_number); SqlParameter birth_date = new SqlParameter("@birth_date", info.birth_date); SqlParameter native_place = new SqlParameter("@native_place", info.native_place); SqlParameter marry_status = new SqlParameter("@marry_status", info.marry_status); SqlParameter job_status = new SqlParameter("@job_status", info.job_status); SqlParameter income = new SqlParameter("@income", info.income); SqlParameter temper = new SqlParameter("@temper", info.temper); SqlParameter family = new SqlParameter("@family", info.family); SqlParameter person_type_id = new SqlParameter("@person_type_id", info.person_type_id); SqlParameter qq = new SqlParameter("@qq", info.qq); SqlParameter address = new SqlParameter("@address", info.address); SqlParameter phone = new SqlParameter("@phone", info.phone); SqlParameter belong_place_id = new SqlParameter("@belong_place_id", info.belong_place_id); SqlParameter nation = new SqlParameter("@nation", info.nation); SqlParameter input_time = new SqlParameter("@input_time", info.input_time); SqlParameter user_id = new SqlParameter("@user_id", info.user_id); SqlParameter isdel = new SqlParameter("@isdel", info.isdel); SqlParameter id = new SqlParameter("@id", info.id); // 执行sql语句 res = SqlHelper.ExecuteNonQuery(DALBase.ConStr, CommandType.Text, sql, name, former_name, gender, identity_number, birth_date, native_place, marry_status, job_status, income, temper, family, person_type_id, qq, address, phone, belong_place_id, nation, input_time, user_id, isdel, id); // 添加用户日志 new LogUserDAL().Add(LogOperations.LogUser("人员信息修改")); } catch (Exception e) { // 添加系统日志 new LogSysDAL().Add(LogOperations.LogSys("人员信息修改:" + e.Message)); //return 0; } // 返回执行成功条数 return(res); }
private void btnSearchPerson_Click(object sender, EventArgs e) { dgvPerson.AutoGenerateColumns = false; person_basic pb = new person_basic() { user_id = UserInfoBLL.UserId, isdel = 0, name = TxtPersonName.Text, identity_number = TxtIdentityNum.Text, native_place = TxtPersonNation.Text }; foreach (var item in new SysSettingBLL().SelectByDictName(sys_dict_type.Person)) { if (item.category_name.Equals(CmbPersonType.Text)) { pb.person_type_id = item.id; } } dgvPerson.DataSource = new PersonBasicDAL().Query(pb); }
private void BtnQueryPerson_Click(object sender, EventArgs e) { List <string> vs = DGVOperations.SelectPersonBasic(dgvPerson); if (vs.Count > 1) { MessageBoxCustom.Show("只能选择一条记录!", "提示", this); return; } else if (vs.Count < 1) { MessageBoxCustom.Show("需要选择一条记录!", "提示", this); return; } person_basic personBasic = DGVOperations.GetSelectPersonBasic(vs[0]); if (personBasic != null) { PersonDetailForm personDetailForm = new PersonDetailForm(personBasic); personDetailForm.ShowDialog(); } }
public PersonDetailForm(person_basic personBasic) { InitializeComponent(); PersonBasic = personBasic; }
/// <summary> /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PersonBasicForm_Load(object sender, EventArgs e) { if ("人员信息录入".Equals(Text)) { LblOldPlace1.Hide(); LblOldPlace2.Hide(); #region 初始选项 // 省 Provinces = new List <string> { province }; CmbProvince.DataSource = Provinces; // 市 Cities = new List <string> { city }; CmbCity.DataSource = Cities; // 县/区 Places = new List <string> { place }; CmbPlace.DataSource = Places; // 初始省(优化卡顿) Provinces = new NativePlaceBLL().QueryProvince(); // 婚姻状况 Marry = new List <string> { "未婚" }; CmbMarry.DataSource = Marry; // 民族 Nation = new List <string> { "汉族" }; CmbNation.DataSource = Nation; // 人员类别 PersonType = new SysSettingBLL().SelectByDictName(sys_dict_type.Person); List <string> personTypeList = new List <string>(); foreach (var item in PersonType) { personTypeList.Add(item.category_name); } CmbPersonType.DataSource = personTypeList; // 归属地 BelongPlace = new SysSettingBLL().SelectByDictName(sys_dict_type.BelongPlace); List <string> belongPlaceList = new List <string>(); foreach (var item in BelongPlace) { belongPlaceList.Add(item.category_name); } CmbBelongPlace.DataSource = belongPlaceList; #endregion } if ("人员信息修改".Equals(Text)) { #region 初始选项 person_basic pb = new person_basic(); pb.id = 1027; pb.user_id = UserInfoBLL.UserId; List <person_basic> list = new PersonBasicBLL().Query(pb); // 姓名 TxtName.Text = list[0].name; // 曾用名 TxtFormerName.Text = list[0].former_name; // 性别 if (list[0].gender.Equals("男")) { RdoMale.Checked = true; } if (list[0].gender.Equals("女")) { RdoFemale.Checked = true; } // 身份证 TxtIdentityNumber.Text = list[0].identity_number; // 出生日期 TimeBirthDate.Value = list[0].birth_date; // 归属地 BelongPlace = new SysSettingBLL().SelectByDictName(sys_dict_type.BelongPlace); foreach (var item in BelongPlace) { if (item.id.Equals(list[0].belong_place_id)) { CmbBelongPlace.DataSource = new List <string>() { item.category_name }; } } // 民族 Nation = new List <string> { "汉族" }; CmbNation.DataSource = Nation; // 地址 TxtAddress.Text = list[0].address; // 籍贯 // 省 Provinces = new List <string> { province }; CmbProvince.DataSource = Provinces; // 市 Cities = new List <string> { city }; CmbCity.DataSource = Cities; // 县/区 Places = new List <string> { place }; CmbPlace.DataSource = Places; // 初始省(优化卡顿) Provinces = new NativePlaceBLL().QueryProvince(); // 原籍贯 LblOldPlace2.Text = list[0].native_place; // 收入状况 TxtIncome.Text = list[0].income.ToString(); // 性格特征 TxtTemper.Text = list[0].temper; // 就业状况 TxtJob.Text = list[0].job_status; // 婚姻状况 if (list[0].marry_status) { CmbMarry.DataSource = new List <string>() { "已婚" } } ; if (!list[0].marry_status) { CmbMarry.DataSource = new List <string>() { "未婚" } } ; // 家庭状况 TxtFamily.Text = list[0].family; // 重点人员类别 PersonType = new SysSettingBLL().SelectByDictName(sys_dict_type.Person); foreach (var item in PersonType) { if (item.id.Equals(list[0].person_type_id)) { CmbPersonType.DataSource = new List <string>() { item.category_name }; } } // qq TxtQQ.Text = list[0].qq; // 电话 TxtPhone.Text = list[0].phone; #endregion } #region 错误提示 LblName.Hide(); LblFormerName.Hide(); LblIdentityNumber.Hide(); LblBirthDate.Hide(); LblAddress.Hide(); LblNativePlace.Hide(); LblIncome.Hide(); LblPhone.Hide(); #endregion }
/// <summary> /// 确认提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnConfirm_Click(object sender, EventArgs e) { person_basic pb = new person_basic(); pb.user_id = pb.id = 1027; pb.user_id = UserInfoBLL.UserId; #region 姓名 string name = TxtName.Text.Replace(" ", ""); if (RegexComm.IsValidName(name)) { LblName.Hide(); pb.name = name; } else { LblName.Show(); return; } #endregion #region 曾用名 if (!string.IsNullOrEmpty(TxtFormerName.Text)) { string formerName = TxtFormerName.Text.Replace(" ", ""); if (RegexComm.IsValidName(formerName)) { LblFormerName.Hide(); pb.former_name = formerName; } else { LblFormerName.Show(); return; } } #endregion #region 性别 if (RdoMale.Checked) { pb.gender = RdoMale.Text; } if (RdoFemale.Checked) { pb.gender = RdoFemale.Text; } #endregion #region 身份证号 if (RegexComm.IsValidIdNum(TxtIdentityNumber.Text)) { LblIdentityNumber.Hide(); pb.identity_number = TxtIdentityNumber.Text; } else { LblIdentityNumber.Show(); return; } #endregion #region 出生日期 if (DateTime.Compare(TimeBirthDate.Value, DateTime.Now) > 0) { LblBirthDate.Show(); return; } else { LblBirthDate.Hide(); pb.birth_date = TimeBirthDate.Value; } #endregion #region 籍贯 if (CmbProvince.Text.Equals(province) || CmbCity.Text.Equals(city) || CmbPlace.Text.Equals(place)) { LblNativePlace.Show(); } else { LblNativePlace.Hide(); pb.native_place = CmbProvince.Text + CmbCity.Text + CmbPlace.Text; } #endregion #region 婚姻状况 if (CmbMarry.Text.Equals("已婚")) { pb.marry_status = true; } if (CmbMarry.Text.Equals("未婚")) { pb.marry_status = false; } #endregion #region 工作状况 pb.job_status = TxtJob.Text; #endregion #region 收入状况 if (!string.IsNullOrEmpty(TxtIncome.Text)) { if (Convert.ToDecimal(TxtIncome.Text) < 0) { LblIncome.Show(); return; } else { LblIncome.Hide(); pb.income = Convert.ToDecimal(TxtIncome.Text); } } #endregion #region 性格特征 pb.temper = TxtTemper.Text; #endregion #region 家庭成员 pb.family = TxtFamily.Text; #endregion #region 人员类型 PersonType = new SysSettingBLL().SelectByDictName(sys_dict_type.Person); foreach (var item in PersonType) { if (item.category_name.Equals(CmbPersonType.Text)) { pb.person_type_id = item.id; } } #endregion #region QQ pb.qq = TxtQQ.Text; #endregion #region 住址 if (string.IsNullOrEmpty(TxtAddress.Text)) { LblAddress.Show(); } else { LblAddress.Hide(); pb.address = TxtAddress.Text; } #endregion #region 电话 if (!string.IsNullOrWhiteSpace(TxtPhone.Text)) { string phone = TxtPhone.Text.Replace(" ", ""); if (RegexComm.IsValidPhone(phone)) { LblPhone.Hide(); pb.phone = phone; } else { LblPhone.Show(); return; } } else { LblPhone.Show(); return; } #endregion #region 归属地 BelongPlace = new SysSettingBLL().SelectByDictName(sys_dict_type.BelongPlace); foreach (var item in BelongPlace) { if (item.category_name.Equals(CmbBelongPlace.Text)) { pb.belong_place_id = item.id; } } #endregion #region 民族 pb.nation = CmbNation.Text; #endregion #region 添加日期 pb.input_time = DateTime.Now; #endregion #region 用户id pb.user_id = UserInfoBLL.UserId; #endregion #region 除标记 pb.isdel = 0; #endregion #region 判断结果 Result r; if (Text.Equals("人员信息录入")) { r = new PersonBasicBLL().Add(pb); } else { r = new PersonBasicBLL().Update(pb); } //if (r.Code == RES.OK) //{ // MessageBoxCustom.Show(r.Message, "", this); //} //else //{ // MessageBoxCustom.Show(r.Message, "", this); //} MessageBoxCustom.Show(r.Message, "提示", this); #endregion }
/// <summary> /// 人员信息检索 /// </summary> /// <param name="info">查询条件</param> /// <returns>List类型</returns> public List <person_basic> Query(person_basic info) { // 用于返回的列表 List <person_basic> list = new List <person_basic>(); if (info.Equals(null)) { return(list); } try { // sql语句 string sql = "select * from person_basic where isdel = " + info.isdel + " and user_id = " + info.user_id; // 用于拼接查询 List <SqlParameter> sqlPara = new List <SqlParameter>(); // 判断参数 if (info.id != 0) // id { sql += " and id = " + info.id; } if (!string.IsNullOrEmpty(info.name)) // name { sql += " and name like @name"; sqlPara.Add(new SqlParameter("@name", "%" + info.name + "%")); } if (!string.IsNullOrEmpty(info.identity_number)) // identity_number { sql += " and identity_number like @identity_number"; sqlPara.Add(new SqlParameter("@identity_number", "%" + info.identity_number + "%")); } if (info.person_type_id > 0) // person_type_id { sql += " and person_type_id = " + info.person_type_id; } if (!string.IsNullOrEmpty(info.native_place)) // native_place { sql += " and native_place like @native_place"; sqlPara.Add(new SqlParameter("@native_place", "%" + info.native_place + "%")); } DataSet ds = new DataSet(); // 执行sql语句并返回数据集 ds = SqlHelper.ExecuteDataset(DALBase.ConStr, CommandType.Text, sql, sqlPara.ToArray()); // 遍历表中的行 foreach (DataRow dr in ds.Tables[0].Rows) { // 封装实体类 person_basic pb = new person_basic(); pb.id = int.Parse(dr[0].ToString()); pb.name = dr[1].ToString(); pb.former_name = dr[2].ToString(); pb.gender = dr[3].ToString(); pb.identity_number = dr[4].ToString(); pb.birth_date = DateTime.Parse(dr[5].ToString()); pb.native_place = dr[6].ToString(); pb.marry_status = bool.Parse(dr[7].ToString()); pb.job_status = dr[8].ToString(); if (!(dr[9] is DBNull)) { pb.income = decimal.Parse(dr[9].ToString()); } pb.temper = dr[10].ToString(); pb.family = dr[11].ToString(); pb.person_type_id = int.Parse(dr[12].ToString()); pb.qq = dr[13].ToString(); pb.address = dr[14].ToString(); pb.phone = dr[15].ToString(); pb.belong_place_id = int.Parse(dr[16].ToString()); pb.nation = dr[17].ToString(); pb.input_time = DateTime.Parse(dr[18].ToString()); pb.user_id = int.Parse(dr[19].ToString()); pb.isdel = int.Parse(dr[20].ToString()); list.Add(pb); } // 添加用户日志 new LogUserDAL().Add(LogOperations.LogUser("人员信息检索")); } catch (Exception e) { // 添加系统日志 new LogSysDAL().Add(LogOperations.LogSys("人员信息检索:" + e.Message)); } // 返回列表 return(list); }