焊接修改
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
using FineUIPro;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class TrainNumberManageService
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private static IQueryable<Model.HJGL_TrainNumberManage> GetByQueryModle(Model.HJGL_TrainNumberManage table)
|
||||
{
|
||||
var q = from x in Funs.DB.HJGL_TrainNumberManage select x;
|
||||
if (table == null)
|
||||
{
|
||||
return q;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.Id))
|
||||
{
|
||||
q = q.Where(x => x.Id.Contains(table.Id));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.TrainNumber))
|
||||
{
|
||||
q = q.Where(x => x.TrainNumber.Contains(table.TrainNumber));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.ProjectId))
|
||||
{
|
||||
q = q.Where(x => x.ProjectId.Contains(table.ProjectId));
|
||||
}
|
||||
if (table.State != null)
|
||||
{
|
||||
q = q.Where(x => x.State == table.State);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.DriverName))
|
||||
{
|
||||
q = q.Where(x => x.DriverName.Contains(table.DriverName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.DriverPhone))
|
||||
{
|
||||
q = q.Where(x => x.DriverPhone.Contains(table.DriverPhone));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.LicensePlateNumber))
|
||||
{
|
||||
q = q.Where(x => x.LicensePlateNumber.Contains(table.LicensePlateNumber));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.ContactName))
|
||||
{
|
||||
q = q.Where(x => x.ContactName.Contains(table.ContactName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.ContactPhone))
|
||||
{
|
||||
q = q.Where(x => x.ContactPhone.Contains(table.ContactPhone));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(table.Remark))
|
||||
{
|
||||
q = q.Where(x => x.Remark.Contains(table.Remark));
|
||||
}
|
||||
q = q.OrderByDescending(x => x.TrainNumber);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
public static List<Model.HJGL_TrainNumberManage> GetListByQueryModle(Model.HJGL_TrainNumberManage table)
|
||||
{
|
||||
return GetByQueryModle(table).ToList();
|
||||
}
|
||||
|
||||
public static (List<Model.HJGL_TrainNumberManage> Data, int Total) GetListByQueryModle(Model.HJGL_TrainNumberManage table, int pageIndex = 0, int pageSize = 20)
|
||||
{
|
||||
var baseQuery = GetByQueryModle(table);
|
||||
var pagedData = baseQuery
|
||||
.Skip((pageIndex) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
// 获取总记录数(延迟计数优化)
|
||||
var totalCount = baseQuery.Count();
|
||||
|
||||
return (pagedData, totalCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.HJGL_TrainNumberManage table, Grid grid1)
|
||||
{
|
||||
var q = GetByQueryModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.TrainNumber,
|
||||
x.ProjectId,
|
||||
x.State,
|
||||
x.DriverName,
|
||||
x.DriverPhone,
|
||||
x.LicensePlateNumber,
|
||||
x.ContactName,
|
||||
x.ContactPhone,
|
||||
x.Remark,
|
||||
};
|
||||
}
|
||||
|
||||
public static Model.HJGL_TrainNumberManage GetModelById(string Id)
|
||||
{
|
||||
return Funs.DB.HJGL_TrainNumberManage.FirstOrDefault(x => x.Id == Id);
|
||||
}
|
||||
|
||||
//根据projectid 获取最新车次号
|
||||
public static string GetNewTrainNumber(string ProjectId)
|
||||
{
|
||||
var q = from x in Funs.DB.HJGL_TrainNumberManage
|
||||
where x.ProjectId == ProjectId
|
||||
select x.TrainNumber;
|
||||
var max = q.Count();
|
||||
var NewTrainNumber=(max+1).ToString().PadLeft(2, '0');
|
||||
return NewTrainNumber;
|
||||
|
||||
}
|
||||
|
||||
public static void Add(Model.HJGL_TrainNumberManage newtable)
|
||||
{
|
||||
Model.HJGL_TrainNumberManage table = new Model.HJGL_TrainNumberManage
|
||||
{
|
||||
Id = newtable.Id,
|
||||
TrainNumber = newtable.TrainNumber,
|
||||
ProjectId = newtable.ProjectId,
|
||||
State = newtable.State,
|
||||
DriverName = newtable.DriverName,
|
||||
DriverPhone = newtable.DriverPhone,
|
||||
LicensePlateNumber = newtable.LicensePlateNumber,
|
||||
ContactName = newtable.ContactName,
|
||||
ContactPhone = newtable.ContactPhone,
|
||||
Remark = newtable.Remark,
|
||||
};
|
||||
Funs.DB.HJGL_TrainNumberManage.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void Update(Model.HJGL_TrainNumberManage newtable)
|
||||
{
|
||||
Model.HJGL_TrainNumberManage table = Funs.DB.HJGL_TrainNumberManage.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.TrainNumber = newtable.TrainNumber;
|
||||
table.ProjectId = newtable.ProjectId;
|
||||
table.State = newtable.State;
|
||||
table.DriverName = newtable.DriverName;
|
||||
table.DriverPhone = newtable.DriverPhone;
|
||||
table.LicensePlateNumber = newtable.LicensePlateNumber;
|
||||
table.ContactName = newtable.ContactName;
|
||||
table.ContactPhone = newtable.ContactPhone;
|
||||
table.Remark = newtable.Remark;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteById(string Id)
|
||||
{
|
||||
Model.HJGL_TrainNumberManage table = Funs.DB.HJGL_TrainNumberManage.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.HJGL_TrainNumberManage.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitDownListOfTrainNumber(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
|
||||
{
|
||||
Model.HJGL_TrainNumberManage table = new Model.HJGL_TrainNumberManage();
|
||||
table.ProjectId = projectId;
|
||||
|
||||
dropName.DataValueField = "Id";
|
||||
dropName.DataTextField = "TrainNumber";
|
||||
dropName.DataSource = GetListByQueryModle(table);
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user