using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QMFrameWork.Common.Util;
using QMAPP.BLL;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.DAL.Basic;
namespace QMAPP.FJC.BLL.Basic
{
public class CapacityBLL : BaseBLL
{
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据列表
public List GetList(Capacity condition)
{
try
{
return new CapacityDAL().GetList(condition);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存数据
///
/// 保存数据
///
///
/// 原数据表
public void Save(Capacity condition, List datas)
{
DataTable dt = null;
CapacityDAL umDal = new CapacityDAL();
//获取原始数据
dt = umDal.GetTable(condition);
//绑定新增及修改数据
foreach (Capacity item in datas)
{
DataRow row = dt.Rows.Find(item.PID);
if (row != null)
{
item.UPDATEUSER = this.LoginUser.UserID;
//更新
BindHelper.BindDataTable(item, row, true);
}
else
{
item.PID = Guid.NewGuid().ToString();
item.CREATEUSER = this.LoginUser.UserID;
item.UPDATEUSER = this.LoginUser.UserID;
item.FLGDEL = "0";
//新增
row = dt.NewRow();
BindHelper.BindDataTable(item, row, true);
dt.Rows.Add(row);
}
}
//绑定删除数据
for (int i = dt.Rows.Count - 1; i >= 0; i--)
{
string key = dt.Rows[i]["PID"].ToString();
bool exists = datas.Exists(p => p.PID == key);
if (exists == false)
{
dt.Rows[i].Delete();
}
}
//保存
umDal.Save(dt);
}
#endregion
}
}