113 lines
3.5 KiB
C#
113 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public class EmergencyMonthService
|
|
{
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool Insert(Model.Report_EmergencyMonth model)
|
|
{
|
|
try
|
|
{
|
|
Funs.DB.Report_EmergencyMonth.InsertOnSubmit(model);
|
|
Funs.DB.SubmitChanges();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"插入数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static bool Update(Model.Report_EmergencyMonth model)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_EmergencyMonth.FirstOrDefault(a => a.Id == model.Id);
|
|
if (result != null)
|
|
{
|
|
result.Unitid = model.Unitid;
|
|
result.Months = model.Months;
|
|
result.States = model.States;
|
|
result.ProjectId = model.ProjectId;
|
|
|
|
result.EmName = model.EmName;
|
|
result.EmDate = model.EmDate;
|
|
result.EmPerson = model.EmPerson;
|
|
result.EmMoney = model.EmMoney;
|
|
result.EmType = model.EmType;
|
|
result.CreateDate = model.CreateDate;
|
|
result.States = model.States;
|
|
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"更新表数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static bool Delete(string newId)
|
|
{
|
|
try
|
|
{
|
|
var result = Funs.DB.Report_EmergencyMonth.Where(a => a.Id == newId).ToList();
|
|
if (result.Count > 0)
|
|
{
|
|
Funs.DB.Report_EmergencyMonth.DeleteAllOnSubmit(result);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 详细
|
|
/// </summary>
|
|
/// <param name="newId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Report_EmergencyMonth Detail(string newId)
|
|
{
|
|
var result = Funs.DB.Report_EmergencyMonth.FirstOrDefault(a => a.Id == newId);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据项目Id、月份获取月报信息
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="month"></param>
|
|
/// <returns></returns>
|
|
public static Model.Report_EmergencyMonth GetReportByMonth(string projectId, string month)
|
|
{
|
|
return Funs.DB.Report_EmergencyMonth.FirstOrDefault(e => e.ProjectId == projectId && e.Months == Convert.ToDateTime(month));
|
|
}
|
|
}
|
|
}
|