public Procurementschedulehead CreateProcurementschedulehead(Procurementschedulehead info,List<Procurementscheduledetail> detailInfos)
 {
     var coderuleManagement=new CoderuleManagement(Management);
         info.Psid = coderuleManagement.GenerateCodeRule(Procurementschedulehead.RuleCode+DateTime.Today.ToString("yyyyMM"),false);
         foreach (var detailInfo in detailInfos)
         {
             detailInfo.Psid = info.Psid;
         }
         var detailManagement = new ProcurementscheduledetailManagement(Management);
         try
         {
             Management.BeginTransaction();
             Management.CreateProcurementschedulehead(info);
             foreach (var detailInfo in detailInfos)
             {
                 detailManagement.CreateProcurementscheduledetail(detailInfo);
             }
             Management.Commit();
         }
         catch
         {
             Management.Rollback();
             throw;
         }
     return info;
 }
 public void DeleteProcurementscheduleheadByPsid(string psid)
 {
     try
     {
         //var headInfo = Management.RetrieveProcurementscheduleheadByPsid(psid);
         //if(headInfo==null){return;}
         //headInfo.Approveresult = ApproveResult.Deleted;
         //Management.BeginTransaction();
         //Management.UpdateProcurementscheduleheadByPsid(headInfo);
         //Management.Commit();
         var detailManagement=new ProcurementscheduledetailManagement(Management);
         Management.BeginTransaction();
         detailManagement.DeleteProcurementscheduledetailsByPsid(new List<string>(){psid});
         Management.DeleteProcurementscheduleheadByPsid(psid);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
 }
 public Procurementschedulehead UpdateProcurementscheduleheadByPsid(Procurementschedulehead info, List<Procurementscheduledetail> detailInfos)
 {
     foreach (var detailInfo in detailInfos)
         {
             detailInfo.Psid = info.Psid;
         }
         var detailManagement = new ProcurementscheduledetailManagement(Management);
         var dbDetails = detailManagement.RetrieveProcurementscheduledetailListByPsid(info.Psid);
         try
         {
             Management.BeginTransaction();
             Management.UpdateProcurementscheduleheadByPsid(info);
             foreach (var detail in detailInfos)
             {
                 var existInfo = dbDetails.Where(p => p.Detailid == detail.Detailid).FirstOrDefault();
                 if (existInfo == null)
                 {
                     detailManagement.CreateProcurementscheduledetail(detail);
                 }
                 else
                 {
                     detailManagement.UpdateProcurementscheduledetailByDetailid(detail);
                 }
             }
             Management.Commit();
         }
         catch
         {
             Management.Rollback();
             throw;
         }
     return info;
 }