using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
namespace BLL
{
public class EmergencyMonthService
{
///
/// 添加
///
///
///
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;
}
}
///
/// 修改
///
///
///
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;
}
}
///
/// 删除
///
///
///
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;
}
}
///
/// 详细
///
///
///
public static Model.Report_EmergencyMonth Detail(string newId)
{
var result = Funs.DB.Report_EmergencyMonth.FirstOrDefault(a => a.Id == newId);
return result;
}
///
/// 根据项目Id、月份获取月报信息
///
///
///
///
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));
}
}
}