/// <summary> /// 修改材料类型表记录 /// </summary> /// <param name="depotForPersonnel">Linq数据集</param> /// <param name="szLid">关系ID</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool UpdateDepotForPersonnel(S_DepotTypeForPersonnel depotForPersonnel, string szLid, out string error) { try { error = null; if (DeleteDepotForPersonnel(szLid, out error)) { if (AddDepotForPersonnel(depotForPersonnel, out error)) { return(true); } else { return(false); } } else { return(false); } } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 填充DepotForPersonnel Linq值 /// </summary> /// <returns>返回材料类别责任人数据列表</returns> private S_DepotTypeForPersonnel CreateLinqDepotForPersonnel() { S_DepotTypeForPersonnel depotforpersonnel = new S_DepotTypeForPersonnel(); depotforpersonnel.ZlID = txtZlID.Text; depotforpersonnel.ZlName = txtZlName.Text; if (txtPersonnelName.DataResult == null) { depotforpersonnel.PersonnelID = txtPersonnelName.Tag.ToString(); } else { depotforpersonnel.PersonnelID = txtPersonnelName["工号"].ToString(); } depotforpersonnel.PersonnelName = txtPersonnelName.Text; return(depotforpersonnel); }
/// <summary> /// 添加材料类别编码表记录 /// </summary> /// <param name="depotForPersonnel">要添加的数据集合</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool AddDepotForPersonnel(S_DepotTypeForPersonnel depotForPersonnel, out string error) { try { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result_ZL = from c in dataContxt.S_DepotTypeForPersonnel where c.ZlID == depotForPersonnel.ZlID select c; var result_Personnel = from c in dataContxt.S_DepotTypeForPersonnel where c.PersonnelID == depotForPersonnel.PersonnelID select c; if (result_ZL.Count() == 0 && result_Personnel.Count() == 0) { dataContxt.S_DepotTypeForPersonnel.InsertOnSubmit(depotForPersonnel); dataContxt.SubmitChanges(); } else if (result_ZL.Count() != 0) { error = string.Format("材料类别编码 {0} 已经存在, 不允许重复添加", depotForPersonnel.ZlID); return(false); } else if (result_Personnel.Count() != 0) { error = string.Format("材料管理人 {0} 已经存在, 不允许重复添加", depotForPersonnel.PersonnelName); return(false); } return(true); } catch (Exception exce) { error = exce.Message; return(false); } }