/// <summary> /// 插入明细 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="billNo">单据号</param> /// <param name="listInfo">零件明细信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> private bool InsertReviewList(DepotManagementDataContext dataContext, string billNo, DataTable listInfo, out string error) { error = null; try { for (int i = 0; i < listInfo.Rows.Count; i++) { YX_SalesOrderReview lnqList = new YX_SalesOrderReview(); lnqList.BillNo = billNo; lnqList.DeptCode = listInfo.Rows[i]["DeptCode"].ToString(); dataContext.YX_SalesOrderReview.InsertOnSubmit(lnqList); } return true; } catch (Exception ex) { error = ex.Message; return false; } }
/// <summary> /// 操作业务 /// </summary> /// <param name="salesOrder">单据信息数据集</param> /// <param name="listPartInfo">零件明细信息</param> /// <param name="listReviewInfo">评审部门信息</param> /// <param name="deptCode">部门编码</param> /// <param name="opinion">部门评审意见</param> /// <param name="status">单据状态</param> /// <param name="type">操作类型(主管审核、部门评审、评审结果)</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool OperationInfo(YX_SalesOrder salesOrder, DataTable listPartInfo, DataTable listReviewInfo, string deptCode, string opinion, string status, string type, out string error) { error = null; try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.YX_SalesOrder where a.BillNo == salesOrder.BillNo select a; var resultReview = from a in dataContext.YX_SalesOrderReview where a.BillNo == salesOrder.BillNo && a.DeptCode == deptCode select a; if (varData.Count() == 1) { YX_SalesOrder lnqBill = varData.Single(); switch (type) { case "主管审核": lnqBill.Status = status; if (listReviewInfo != null && listReviewInfo.Rows.Count > 0) { if (resultReview.Count() > 0) { foreach (YX_SalesOrderReview item in resultReview) { YX_SalesOrderReviewHistory history = new YX_SalesOrderReviewHistory(); history.BillNo = salesOrder.BillNo; history.Confirmation = UniversalFunction.GetPersonnelCode(item.Confirmation); history.ConfirmDate = Convert.ToDateTime(item.ConfirmDate); history.DeptCode = item.DeptCode; history.Opinion = item.Opinion; dataContext.YX_SalesOrderReviewHistory.InsertOnSubmit(history); } } if (!DeleteReviewList(dataContext, salesOrder.BillNo, out error)) { return false; } if (!InsertReviewList(dataContext, salesOrder.BillNo, listReviewInfo, out error)) { return false; } if (!DeletePartList(dataContext, salesOrder.BillNo, out error) && !DeleteReviewList(dataContext, salesOrder.BillNo, out error)) { return false; } if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error)) { throw new Exception(error); } } else { lnqBill.Auditer = salesOrder.Auditer; lnqBill.AuditDate = salesOrder.AuditDate; } break; case "部门评审": if (resultReview.Count() == 1) { YX_SalesOrderReview review = resultReview.Single(); review.Opinion = opinion; review.Confirmation = BasicInfo.LoginID; review.ConfirmDate = ServerTime.Time; lnqBill.Status = status; } else { error = "请确认评审部门!"; return false; } break; case "确认评审": lnqBill.Status = status; break; case "评审结果": lnqBill.ResultPerson = salesOrder.ResultPerson; lnqBill.ReviewResult = salesOrder.ReviewResult; lnqBill.Status = status; lnqBill.ResultDate = salesOrder.ResultDate; if (!DeletePartList(dataContext, salesOrder.BillNo, out error)) { return false; } if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error)) { return false; } break; default: break; } dataContext.SubmitChanges(); } else { error = "数据不唯一"; return false; } return true; } catch (Exception ex) { error = ex.Message; return false; } }
/// <summary> /// 操作业务 /// </summary> /// <param name="salesOrder">单据信息数据集</param> /// <param name="listPartInfo">零件明细信息</param> /// <param name="listReviewInfo">评审部门信息</param> /// <param name="deptCode">部门编码</param> /// <param name="opinion">部门评审意见</param> /// <param name="status">单据状态</param> /// <param name="type">操作类型(主管审核、部门评审、评审结果)</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool OperationInfo(YX_SalesOrder salesOrder, DataTable listPartInfo, DataTable listReviewInfo, string deptCode, string opinion, string status, string type, out string error) { error = null; try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.YX_SalesOrder where a.BillNo == salesOrder.BillNo select a; if (varData.Count() == 1) { YX_SalesOrder lnqBill = varData.Single(); switch (type) { case "主管审核": lnqBill.Status = status; lnqBill.Auditer = salesOrder.Auditer; lnqBill.AuditDate = salesOrder.AuditDate; if (!DeleteReviewList(dataContext, salesOrder.BillNo, out error)) { return(false); } if (!InsertReviewList(dataContext, salesOrder.BillNo, listReviewInfo, out error)) { return(false); } break; case "部门评审": var resultReview = from a in dataContext.YX_SalesOrderReview where a.BillNo == salesOrder.BillNo && a.DeptCode == deptCode select a; if (resultReview.Count() == 1) { YX_SalesOrderReview review = resultReview.Single(); review.Opinion = opinion; review.Confirmation = BasicInfo.LoginID; review.ConfirmDate = ServerTime.Time; lnqBill.Status = status; } else { error = "请确认评审部门!"; return(false); } break; case "确认评审": lnqBill.Status = status; break; case "评审结果": lnqBill.ResultPerson = salesOrder.ResultPerson; lnqBill.ReviewResult = salesOrder.ReviewResult; lnqBill.Status = status; lnqBill.ResultDate = salesOrder.ResultDate; if (!DeletePartList(dataContext, salesOrder.BillNo, out error)) { return(false); } if (!InsertPartList(dataContext, salesOrder.BillNo, listPartInfo, out error)) { return(false); } break; default: break; } dataContext.SubmitChanges(); } else { error = "数据不唯一"; return(false); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }