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 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;
 }