/// <summary> /// 修改材料类别表记录 /// </summary> /// <param name="depot">Linq数据集</param> /// <param name="depotCode">材料类别编码</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool UpdateBill(S_Depot depot, string depotCode, out string error) { error = null; try { if (DeleteBill(depotCode, out error)) { if (AddBill(depot, out error)) { return(true); } else { return(false); } } else { return(false); } } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 添加材料类别表记录 /// </summary> /// <param name="depot">要添加的材料类别信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool AddBill(S_Depot depot, out string error) { try { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from c in dataContxt.S_Depot where c.DepotCode == depot.DepotCode select c; if (result.Count() == 0) { dataContxt.S_Depot.InsertOnSubmit(depot); dataContxt.SubmitChanges(); } else { error = string.Format("编码 {0} 的材料类别已经存在, 不允许重复添加", depot.DepotCode); return(false); } return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 填充Depot Linq值 /// </summary> /// <param name="NowNode">树节点</param> /// <returns>返回材料类别信息列表</returns> private S_Depot CreateLinqDepot(TreeNode tnNowNode) { S_Depot SaveDepot = new S_Depot(); SaveDepot.DepotCode = tnNowNode.Tag.ToString(); SaveDepot.DepotName = tnNowNode.Text; SaveDepot.DepotGrade = Convert.ToByte(tnNowNode.Tag.ToString().Length / 2 - 1); SaveDepot.IsEnd = tnNowNode.Nodes.Count == 0 ? true : false; return(SaveDepot); }