You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.4 KiB
87 lines
2.4 KiB
4 years ago
|
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 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <returns>数据列表</returns>
|
||
|
public List<Capacity> GetList(Capacity condition)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new CapacityDAL().GetList(condition);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 保存数据
|
||
|
/// <summary>
|
||
|
/// 保存数据
|
||
|
/// <param name="dt"></param>
|
||
|
/// </summary>
|
||
|
/// <returns>原数据表</returns>
|
||
|
public void Save(Capacity condition, List<Capacity> 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
|
||
|
}
|
||
|
}
|