391 lines
15 KiB
C#
391 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
|
|
namespace BLL
|
|
{
|
|
public class BaseService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
/// <summary>
|
|
/// 根据主键获取工程量基础表信息
|
|
/// </summary>
|
|
/// <param name="BaseId"></param>
|
|
/// <returns></returns>
|
|
public static Model.QuantityManagement_Base GetBaseById(string BaseId)
|
|
{
|
|
return Funs.DB.QuantityManagement_Base.FirstOrDefault(e => e.BaseId == BaseId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加工程量基础表
|
|
/// </summary>
|
|
/// <param name="Base"></param>
|
|
public static void AddBase(Model.QuantityManagement_Base Base)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.QuantityManagement_Base newBase = new Model.QuantityManagement_Base();
|
|
newBase.BaseId = Base.BaseId;
|
|
newBase.ProjectId = Base.ProjectId;
|
|
newBase.DrawingId = Base.DrawingId;
|
|
newBase.Part = Base.Part;
|
|
newBase.ProjectContent = Base.ProjectContent;
|
|
newBase.Unit = Base.Unit;
|
|
newBase.Amount = Base.Amount;
|
|
newBase.WorkTeam = Base.WorkTeam;
|
|
newBase.CompileMan = Base.CompileMan;
|
|
newBase.CompileDate = Base.CompileDate;
|
|
newBase.State = Base.State;
|
|
|
|
db.QuantityManagement_Base.InsertOnSubmit(newBase);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改工程量基础表
|
|
/// </summary>
|
|
/// <param name="Base"></param>
|
|
public static void UpdateBase(Model.QuantityManagement_Base Base)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.QuantityManagement_Base newBase = db.QuantityManagement_Base.FirstOrDefault(e => e.BaseId == Base.BaseId);
|
|
if (newBase != null)
|
|
{
|
|
newBase.ProjectId = Base.ProjectId;
|
|
newBase.DrawingId = Base.DrawingId;
|
|
newBase.Part = Base.Part;
|
|
newBase.ProjectContent = Base.ProjectContent;
|
|
newBase.Unit = Base.Unit;
|
|
newBase.Amount = Base.Amount;
|
|
newBase.WorkTeam = Base.WorkTeam;
|
|
newBase.CompileMan = Base.CompileMan;
|
|
newBase.State = Base.State;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除工程量基础表
|
|
/// </summary>
|
|
/// <param name="BaseId"></param>
|
|
public static void DeleteBase(string BaseId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.QuantityManagement_Base Base = db.QuantityManagement_Base.FirstOrDefault(e => e.BaseId == BaseId);
|
|
if (Base != null)
|
|
{
|
|
db.QuantityManagement_Base.DeleteOnSubmit(Base);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 部位下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitPartDropDownList(FineUIPro.DropDownList dropName, string drawingId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Value";
|
|
dropName.DataTextField = "Text";
|
|
dropName.DataSource = GetPartListByDrawingId(drawingId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 部位下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitAllPartDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Value";
|
|
dropName.DataTextField = "Text";
|
|
dropName.DataSource = GetAllPartListByProjectId(projectId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据图纸Id获取部位下拉选择项
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetAllPartListByProjectId(string projectId)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var q = (from x in db.QuantityManagement_Base
|
|
where x.ProjectId == projectId && x.State == BLL.Const.Base_Complete
|
|
orderby x.Part
|
|
select x.Part).Distinct().ToList();
|
|
ListItem[] list = new ListItem[q.Count()];
|
|
for (int i = 0; i < list.Count(); i++)
|
|
{
|
|
list[i] = new ListItem(q[i] ?? "", q[i]);
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据图纸Id获取部位下拉选择项
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetPartListByDrawingId(string drawingId)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var q = (from x in db.QuantityManagement_Base
|
|
where x.DrawingId == drawingId && x.State == BLL.Const.Base_Complete
|
|
orderby x.Part
|
|
select x.Part).Distinct().ToList();
|
|
ListItem[] list = new ListItem[q.Count()];
|
|
for (int i = 0; i < list.Count(); i++)
|
|
{
|
|
list[i] = new ListItem(q[i] ?? "", q[i]);
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目内容下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitProjectContentDropDownList(FineUIPro.DropDownList dropName, string drawingId, string part, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "BaseId";
|
|
dropName.DataTextField = "ProjectContent";
|
|
dropName.DataSource = GetProjectContentListByDrawingId(drawingId, part);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目内容下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitAllProjectContentDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Value";
|
|
dropName.DataTextField = "Text";
|
|
dropName.DataSource = GetAllProjectContentListByProjectId(projectId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据项目Id获取项目内容下拉选择项
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetAllProjectContentListByProjectId(string projectId)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var q = (from x in db.QuantityManagement_Base
|
|
where x.ProjectId == projectId && x.State == BLL.Const.Base_Complete
|
|
orderby x.ProjectContent
|
|
select x.ProjectContent).Distinct().ToList();
|
|
ListItem[] list = new ListItem[q.Count()];
|
|
for (int i = 0; i < list.Count(); i++)
|
|
{
|
|
list[i] = new ListItem(q[i] ?? "", q[i]);
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据图纸Id和部位获取项目内容下拉选择项
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.QuantityManagement_Base> GetProjectContentListByDrawingId(string drawingId, string part)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
return (from x in db.QuantityManagement_Base
|
|
where x.DrawingId == drawingId && x.Part == part && x.State == BLL.Const.Base_Complete
|
|
orderby x.ProjectContent
|
|
select x).ToList();
|
|
}
|
|
}
|
|
|
|
public static void Init(FineUIPro.DropDownList dropName, string state, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Value";
|
|
dropName.DataTextField = "Text";
|
|
dropName.DataSource = GetDHandleTypeByState(state);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据状态选择下一步办理类型
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetDHandleTypeByState(string state)
|
|
{
|
|
if (state == Const.Base_Compile || state == Const.Base_ReCompile) //无是否同意
|
|
{
|
|
ListItem[] lis = new ListItem[1];
|
|
lis[0] = new ListItem("审核", Const.Base_Audit1);
|
|
return lis;
|
|
}
|
|
else if (state == Const.Base_Audit1)//有是否同意
|
|
{
|
|
ListItem[] lis = new ListItem[2];
|
|
lis[0] = new ListItem("审批完成", Const.Base_Complete);//是 加载
|
|
lis[1] = new ListItem("重新编制", Const.Base_ReCompile);//否加载
|
|
return lis;
|
|
}
|
|
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取模拟树表格
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static DataTable GetAllTreeDataTable(string projectId)
|
|
{
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
IQueryable<Model.Base_CNProfessional> cNProfessionals = from x in db.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x;
|
|
IQueryable<Model.View_QuantityManagement_Base> bases = from x in db.View_QuantityManagement_Base where x.ProjectId == projectId select x;
|
|
DataTable table = new DataTable();
|
|
table.Columns.Add(new DataColumn("BaseId", typeof(String)));
|
|
table.Columns.Add(new DataColumn("SupId", typeof(String)));
|
|
table.Columns.Add(new DataColumn("Name", typeof(String)));
|
|
table.Columns.Add(new DataColumn("ProjectId", typeof(String)));
|
|
table.Columns.Add(new DataColumn("DrawingNo", typeof(String)));
|
|
table.Columns.Add(new DataColumn("DrawingName", typeof(String)));
|
|
table.Columns.Add(new DataColumn("Part", typeof(String)));
|
|
table.Columns.Add(new DataColumn("ProjectContent", typeof(String)));
|
|
table.Columns.Add(new DataColumn("Unit", typeof(String)));
|
|
table.Columns.Add(new DataColumn("Amount", typeof(decimal)));
|
|
table.Columns.Add(new DataColumn("WorkTeam", typeof(String)));
|
|
table.Columns.Add(new DataColumn("State", typeof(String)));
|
|
|
|
DataRow row;
|
|
row = table.NewRow();
|
|
row[0] = "0";
|
|
row[1] = null;
|
|
row[2] = "工程量基础表";
|
|
row[3] = projectId;
|
|
row[4] = "";
|
|
row[5] = "";
|
|
row[6] = "";
|
|
row[7] = "";
|
|
row[8] = "";
|
|
row[9] = DBNull.Value;
|
|
row[10] = "";
|
|
row[11] = "";
|
|
table.Rows.Add(row);
|
|
foreach (var item in cNProfessionals)
|
|
{
|
|
row = table.NewRow();
|
|
row[0] = item.CNProfessionalId;
|
|
row[1] = "0";
|
|
row[2] = item.ProfessionalName;
|
|
row[3] = projectId;
|
|
row[4] = "";
|
|
row[5] = "";
|
|
row[6] = "";
|
|
row[7] = "";
|
|
row[8] = "";
|
|
row[9] = DBNull.Value;
|
|
row[10] = "";
|
|
row[11] = "";
|
|
table.Rows.Add(row);
|
|
var workSections = bases.Where(x => x.Major == item.ProfessionalName).Select(x => x.WorkSection).Distinct().ToList();
|
|
foreach (var workSection in workSections)
|
|
{
|
|
row = table.NewRow();
|
|
row[0] = item.CNProfessionalId + workSection;
|
|
row[1] = item.CNProfessionalId;
|
|
row[2] = workSection;
|
|
row[3] = projectId;
|
|
row[4] = "";
|
|
row[5] = "";
|
|
row[6] = "";
|
|
row[7] = "";
|
|
row[8] = "";
|
|
row[9] = DBNull.Value;
|
|
row[10] = "";
|
|
row[11] = "";
|
|
table.Rows.Add(row);
|
|
var bs = from x in bases
|
|
where x.WorkSection == workSection && x.Major == item.ProfessionalName
|
|
orderby x.DrawingNo, x.Part, x.WorkSection
|
|
select x;
|
|
foreach (var b in bs)
|
|
{
|
|
row = table.NewRow();
|
|
row[0] = b.BaseId;
|
|
row[1] = item.CNProfessionalId + workSection;
|
|
row[2] = b.Part;
|
|
row[3] = projectId;
|
|
row[4] = b.DrawingNo;
|
|
row[5] = b.DrawingName;
|
|
row[6] = b.Part;
|
|
row[7] = b.ProjectContent;
|
|
row[8] = b.Unit;
|
|
row[9] = b.Amount;
|
|
row[10] = b.WorkTeam;
|
|
row[11] = b.State;
|
|
table.Rows.Add(row);
|
|
}
|
|
}
|
|
}
|
|
//foreach (var item in bases)
|
|
//{
|
|
// row = table.NewRow();
|
|
// row[0] = item.BaseId;
|
|
// row[1] = "0";
|
|
// row[2] = item.ProfessionalName;
|
|
// row[3] = projectId;
|
|
// row[4] = "";
|
|
// row[5] = "";
|
|
// row[6] = "";
|
|
// row[7] = "";
|
|
// row[8] = "";
|
|
// row[9] = DBNull.Value;
|
|
// row[10] = "";
|
|
// row[11] = "";
|
|
// table.Rows.Add(row);
|
|
//}
|
|
return table;
|
|
}
|
|
}
|
|
}
|
|
}
|