using FineUIPro;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class Base_CompanytemplateService
{
#region 获取列表
///
/// 记录数
///
public static int count
{
get;
set;
}
public static List GetBase_CompanyTemplateByModle(Model.Base_CompanyTemplate table)
{
var q = from x in Funs.DB.Base_CompanyTemplate
where
(string.IsNullOrEmpty(table.TemplateId) || x.TemplateId.Contains(table.TemplateId)) &&
(string.IsNullOrEmpty(table.Code) || x.Code.Contains(table.Code)) &&
(string.IsNullOrEmpty(table.Name) || x.Name.Contains(table.Name)) &&
(string.IsNullOrEmpty(table.FilePath) || x.FilePath.Contains(table.FilePath)) &&
(string.IsNullOrEmpty(table.Remarks) || x.Remarks.Contains(table.Remarks))
select x
;
return q.ToList();
}
/// 获取分页列表
///
/// 页码
/// 每页数量
///
public static IEnumerable getListData(Model.Base_CompanyTemplate table, Grid Grid1)
{
var q = GetBase_CompanyTemplateByModle(table);
count = q.Count();
if (count == 0)
{
return null;
}
// q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
x.TemplateId,
x.Code,
x.Name,
x.FilePath,
x.Remarks,
};
}
#endregion
public static Model.Base_CompanyTemplate GetBase_CompanyTemplateById(string TemplateId)
{
return Funs.DB.Base_CompanyTemplate.FirstOrDefault(x => x.TemplateId == TemplateId);
}
public static Model.Base_CompanyTemplate GetBase_CompanyTemplateByCode(string Code)
{
return Funs.DB.Base_CompanyTemplate.FirstOrDefault(x => x.Code == Code);
}
public static bool IsExitCode(string Code)
{
bool result = false;
var q = (from x in Funs.DB.Base_CompanyTemplate where x.Code == Code select x).FirstOrDefault();
if (q != null)
{
result = true;
}
return result;
}
public static void AddBase_CompanyTemplate(Model.Base_CompanyTemplate newtable)
{
Model.Base_CompanyTemplate table = new Model.Base_CompanyTemplate
{
TemplateId = newtable.TemplateId,
Code = newtable.Code,
Name = newtable.Name,
FilePath = newtable.FilePath,
Remarks = newtable.Remarks,
};
Funs.DB.Base_CompanyTemplate.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void AddBulkBase_CompanyTemplate(List newtables)
{
Funs.DB.Base_CompanyTemplate.InsertAllOnSubmit(newtables);
Funs.DB.SubmitChanges();
}
public static void UpdateBase_CompanyTemplate(Model.Base_CompanyTemplate newtable)
{
Model.Base_CompanyTemplate table = Funs.DB.Base_CompanyTemplate.FirstOrDefault(x => x.TemplateId == newtable.TemplateId);
if (table != null)
{
table.TemplateId = newtable.TemplateId;
table.Code = newtable.Code;
table.Name = newtable.Name;
table.FilePath = newtable.FilePath;
table.Remarks = newtable.Remarks;
Funs.DB.SubmitChanges();
}
}
public static void DeleteBase_CompanyTemplateById(string TemplateId)
{
Model.Base_CompanyTemplate table = Funs.DB.Base_CompanyTemplate.FirstOrDefault(x => x.TemplateId == TemplateId);
if (table != null)
{
Funs.DB.Base_CompanyTemplate.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
public static void DeleteALLBase_CompanyTemplate()
{
if (Funs.DB.Base_CompanyTemplate != null)
{
Funs.DB.Base_CompanyTemplate.DeleteAllOnSubmit(Funs.DB.Base_CompanyTemplate);
Funs.DB.SubmitChanges();
}
}
public static void InitBase_CompanyTemplateDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "TemplateId";
dropName.DataTextField = "Name";
dropName.DataSource = GetBase_CompanyTemplateByModle(new Model.Base_CompanyTemplate());
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
}
}