コード例 #1
0
        /// <summary>
        /// 根据日期获得最近的一条月报告信息
        /// </summary>
        /// <param name="date">日期</param>
        /// <returns></returns>
        public static Model.Manager_MonthReportD GetLastMonthReportByDate(DateTime date, int freezeDay, string projectId)
        {
            Model.Manager_MonthReportD LastMonth = null;
            DateTime?monthDate = null;

            var q = from x in Funs.DB.Manager_MonthReportD where x.ProjectId == projectId && x.Months < date orderby x.Months descending select x;

            if (q.Count() > 0)
            {
                if (date.Day < freezeDay)
                {
                    DateTime c = date.AddMonths(-1).Date;
                    monthDate = Convert.ToDateTime(c.Year + "-" + c.Month + "-01");  //当月
                }
                else
                {
                    monthDate = Convert.ToDateTime(date.Year + "-" + date.Month + "-01");  //当月
                }

                var month = from x in q where x.Months == monthDate select x;

                if (month.Count() > 0)  // 表示存在当月记录
                {
                    if (q.Count() > 1)
                    {
                        LastMonth = q.ToList()[1];
                    }
                }
                else    // 表示不存在当月记录
                {
                    LastMonth = q.ToList()[0];
                }
            }
            return(LastMonth);
        }
コード例 #2
0
        /// <summary>
        /// 修改月报告信息
        /// </summary>
        /// <param name="monthReport">月报告实体</param>
        public static void UpdateMonthReport(Model.Manager_MonthReportD monthReport)
        {
            Model.SUBHSSEDB            db             = Funs.DB;
            Model.Manager_MonthReportD newMonthReport = db.Manager_MonthReportD.First(e => e.MonthReportId == monthReport.MonthReportId);
            newMonthReport.MonthReportCode = monthReport.MonthReportCode;
            newMonthReport.ProjectId       = monthReport.ProjectId;
            newMonthReport.Months          = monthReport.Months;
            newMonthReport.MonthReportDate = monthReport.MonthReportDate;
            newMonthReport.ReportMan       = monthReport.ReportMan;
            newMonthReport.States          = monthReport.States;

            db.SubmitChanges();
        }
コード例 #3
0
 /// <summary>
 /// 根据月报告主键删除一个月报告信息
 /// </summary>
 /// <param name="monthReportId">月报告主键</param>
 public static void DeleteMonthReportByMonthReportId(string monthReportId)
 {
     Model.SUBHSSEDB            db          = Funs.DB;
     Model.Manager_MonthReportD monthReport = db.Manager_MonthReportD.FirstOrDefault(e => e.MonthReportId == monthReportId);
     if (monthReport != null)
     {
         ///删除编码表记录
         BLL.CodeRecordsService.DeleteCodeRecordsByDataId(monthReportId);
         BLL.CommonService.DeleteAttachFileById(monthReportId);//删除附件
         //BLL.MonthSafetyRecordDService.DeleteMonthSafetyRecordDByMonthReportId(monthReportId);
         //BLL.MonthSummaryDService.DeleteMonthSummaryDByMonthReportId(monthReportId);
         //BLL.HSSEMeetingDService.DeleteHSSEMeetingDByMonthReportId(monthReportId);
         BLL.SafetyDataDService.DeleteSafetyDataDByMonthReportId(monthReportId);
         //BLL.EnvironmentalHealthMonthlyDService.DeleteEnvironmentalHealthMonthlyDByMonthReportId(monthReportId);
         //BLL.CheckDayRecordDService.DeleteCheckDayRecordDByMonthReportId(monthReportId);
         db.Manager_MonthReportD.DeleteOnSubmit(monthReport);
         db.SubmitChanges();
     }
 }
コード例 #4
0
        /// <summary>
        /// 增加月报告信息
        /// </summary>
        /// <param name="monthReport">月报告实体</param>
        public static void AddMonthReport(Model.Manager_MonthReportD monthReport)
        {
            Model.SUBHSSEDB            db             = Funs.DB;
            Model.Manager_MonthReportD newMonthReport = new Model.Manager_MonthReportD
            {
                MonthReportId   = monthReport.MonthReportId,
                MonthReportCode = monthReport.MonthReportCode,
                ProjectId       = monthReport.ProjectId,
                Months          = monthReport.Months,
                MonthReportDate = monthReport.MonthReportDate,
                ReportMan       = monthReport.ReportMan,
                States          = monthReport.States
            };

            db.Manager_MonthReportD.InsertOnSubmit(newMonthReport);
            db.SubmitChanges();
            ////增加一条编码记录
            BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectManagerMonthCMenuId, monthReport.ProjectId, null, monthReport.MonthReportId, monthReport.MonthReportDate);
        }
コード例 #5
0
        /// <summary>
        /// 根据日期获得最近的一条月报告信息
        /// </summary>
        /// <param name="date">日期</param>
        /// <returns></returns>
        public static Model.Manager_MonthReportD GetLastMonthReportByDate(DateTime date, string projectId)
        {
            Model.Manager_MonthReportD LastMonth = null;

            var q = from x in Funs.DB.Manager_MonthReportD where x.ProjectId == projectId && x.Months <= date orderby x.Months descending select x;

            if (q.Count() > 0)
            {
                var month = from x in q where x.Months == date select x;
                if (month.Count() > 0)  // 表示存在当月记录
                {
                    if (q.Count() > 1)
                    {
                        LastMonth = q.ToList()[1];
                    }
                }
                else    // 表示不存在当月记录
                {
                    LastMonth = q.ToList()[0];
                }
            }
            return(LastMonth);
        }