207 lines
7.8 KiB
C#
207 lines
7.8 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.Material
|
|
{
|
|
public partial class EquipmentSearch : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义集合
|
|
/// </summary>
|
|
private static List<string> list = new List<string>();
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
list = new List<string>();
|
|
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, true);
|
|
BLL.MainItemService.InitMainItemDownList(drpMainItem, this.ProjectId, true);
|
|
if (!string.IsNullOrEmpty(this.CurrUser.UnitId))
|
|
{
|
|
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
|
|
}
|
|
BindGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
|
|
public void BindGrid()
|
|
{
|
|
DataTable tb = ChecklistData();
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
protected DataTable ChecklistData()
|
|
{
|
|
string strSql = @"select C.*,M.MainItemName,U.UnitName from [dbo].[Material_Equipment] C
|
|
left join [dbo].[ProjectData_MainItem] M on C.MainItemId=M.MainItemId
|
|
left join [dbo].[Base_Unit] U on U.UnitId=C.UnitId where C.InspectionId is null";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
strSql += " AND C.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|
if (drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND C.UnitId=@UnitId";
|
|
listStr.Add(new SqlParameter("@UnitId", drpUnit.SelectedValue));
|
|
}
|
|
if (drpMainItem.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND C.MainItemId=@MainItem";
|
|
listStr.Add(new SqlParameter("@MainItem", drpMainItem.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEquipmentCode.Text.Trim()))
|
|
{
|
|
strSql += " AND EquipmentCode like @EquipmentCode";
|
|
listStr.Add(new SqlParameter("@EquipmentCode", "%" + this.txtEquipmentCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEquipmentName.Text.Trim()))
|
|
{
|
|
strSql += " AND EquipmentName like @EquipmentName";
|
|
listStr.Add(new SqlParameter("@EquipmentName", "%" + this.txtEquipmentName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSpecificationAndModel.Text.Trim()))
|
|
{
|
|
strSql += " AND SpecificationAndModel like @SpecificationAndModel";
|
|
listStr.Add(new SqlParameter("@SpecificationAndModel", "%" + this.txtSpecificationAndModel.Text.Trim() + "%"));
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
/// <summary>
|
|
/// 窗体关闭
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#region Grid行点击事件
|
|
/// <summary>
|
|
/// Grid1行点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string rowID = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
if (e.CommandName == "IsSelected")
|
|
{
|
|
CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
|
if (checkField.GetCheckedState(e.RowIndex))
|
|
{
|
|
if (!list.Contains(rowID))
|
|
{
|
|
list.Add(rowID);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list.Contains(rowID))
|
|
{
|
|
list.Remove(rowID);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 重置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnRset_Click(object sender, EventArgs e)
|
|
{
|
|
drpUnit.SelectedIndex = 0;
|
|
drpMainItem.SelectedIndex = 0;
|
|
txtEquipmentCode.Text = "";
|
|
txtEquipmentName.Text = "";
|
|
BindGrid();
|
|
}
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpUnit.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请先选择单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
ShowNotify("请至少选择一项!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.Material_Inspection ins = new Model.Material_Inspection();
|
|
ins.InspectionId = SQLHelper.GetNewID();
|
|
ins.ProjectId = this.CurrUser.LoginProjectId;
|
|
ins.InspectionType = "E";
|
|
string prefix = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectCode + "-" + BLL.UnitService.GetUnitCodeByUnitId(this.CurrUser.UnitId) + "-SBBY-";
|
|
ins.InspectionCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode4ByProjectId", "dbo.Material_Inspection", "InspectionCode", this.CurrUser.LoginProjectId, prefix);
|
|
ins.UnitId = this.drpUnit.SelectedValue;
|
|
ins.State = BLL.Const.Inspection_Compile;
|
|
ins.CompileMan = this.CurrUser.PersonId;
|
|
ins.CompileDate = DateTime.Now;
|
|
BLL.CQMS_InspectionService.AddInspection(ins);
|
|
Model.Material_InspectionApprove approve = new Model.Material_InspectionApprove();
|
|
approve.InspectionId = ins.InspectionId;
|
|
approve.ApproveMan = CurrUser.PersonId;
|
|
approve.ApproveType = Const.Inspection_Compile;
|
|
BLL.CQMS_InspectionApproveService.AddInspectionApprove(approve);
|
|
foreach (var item in list)
|
|
{
|
|
Model.Material_Equipment equipment = BLL.CQMS_EquipmentService.GetEquipmentByEquipmentId(item);
|
|
if (equipment != null)
|
|
{
|
|
equipment.InspectionId = ins.InspectionId;
|
|
BLL.CQMS_EquipmentService.UpdateEquipment(equipment);
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(ins.InspectionId)
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
}
|
|
} |