376 lines
14 KiB
C#
376 lines
14 KiB
C#
namespace FineUIPro.Web.HJGLServer.BaseInfo
|
||
{
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using BLL;
|
||
|
||
public partial class MaterialCompare : PageBase
|
||
{
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
////材质
|
||
this.drpName.DataTextField = "STE_Name";
|
||
this.drpName.DataValueField = "STE_ID";
|
||
this.drpName.DataSource = BLL.HJGL_MaterialService.GetSteelList();
|
||
this.drpName.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpName);
|
||
|
||
this.drpSteel.DataTextField = "STE_Name";
|
||
this.drpSteel.DataValueField = "STE_ID";
|
||
this.drpSteel.DataSource = BLL.HJGL_MaterialService.GetSteelList();
|
||
this.drpSteel.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpSteel);
|
||
|
||
////焊接方法
|
||
this.drpWME.DataTextField = "WME_Name";
|
||
this.drpWME.DataValueField = "WME_ID";
|
||
this.drpWME.DataSource = BLL.HJGL_WeldingMethodService.GetWeldMethodNameList();
|
||
this.drpWME.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpWME);
|
||
|
||
////焊丝
|
||
this.drpWMT1.DataTextField = "WMT_MatCode";
|
||
this.drpWMT1.DataValueField = "WMT_ID";
|
||
this.drpWMT1.DataSource = BLL.HJGL_ConsumablesService.GetMaterialList("1");
|
||
this.drpWMT1.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpWMT1);
|
||
|
||
////焊条
|
||
this.drpWMT2.DataTextField = "WMT_MatCode";
|
||
this.drpWMT2.DataValueField = "WMT_ID";
|
||
this.drpWMT2.DataSource = BLL.HJGL_ConsumablesService.GetMaterialList("2");
|
||
this.drpWMT2.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpWMT2);
|
||
|
||
// 绑定表格
|
||
BindGrid();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定数据
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
string strSql = @"SELECT MaterialCompare.MaterialCompareId,MaterialCompare.STE_ID,Steel.STE_Name,MaterialCompare.WME_ID,WeldMethod .WME_Name,MaterialCompare.WMT_ID1,WeldMaterial1.WMT_MatName as WeldMaterial1,MaterialCompare.WMT_ID2,WeldMaterial2.WMT_MatName as WeldMaterial2,MaterialCompare.Remark"
|
||
+ @" FROM dbo.HJGL_BS_MaterialCompare AS MaterialCompare"
|
||
+ @" LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID = MaterialCompare.STE_ID"
|
||
+ @" LEFT JOIN dbo.HJGL_BS_WeldMethod AS WeldMethod ON WeldMethod .WME_ID=MaterialCompare.WME_ID"
|
||
+ @" LEFT JOIN dbo.HJGL_BS_WeldMaterial AS WeldMaterial1 ON WeldMaterial1.WMT_ID=MaterialCompare.WMT_ID1"
|
||
+ @" LEFT JOIN dbo.HJGL_BS_WeldMaterial AS WeldMaterial2 ON WeldMaterial2.WMT_ID=MaterialCompare.WMT_ID2 WHERE 1=1";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
if (this.drpName.SelectedValue != BLL.Const._Null)
|
||
{
|
||
strSql += " AND STE_ID = @STE_ID";
|
||
listStr.Add(new SqlParameter("@STE_ID", this.drpName.SelectedValue));
|
||
}
|
||
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页排序
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
Grid1.PageIndex = e.NewPageIndex;
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 分页下拉选择
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_FilterChange(object sender, EventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||
{
|
||
Grid1.SortDirection = e.SortDirection;
|
||
Grid1.SortField = e.SortField;
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 删除事件
|
||
/// <summary>
|
||
/// 删除
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialCompareMenuId, Const.BtnDelete))
|
||
{
|
||
if (judgementDelete(hfFormID.Text, true))
|
||
{
|
||
BLL.HJGL_MaterialCompareService.DeleteMaterialCompare(hfFormID.Text);
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除材质焊材对照信息");
|
||
// 重新绑定表格,并模拟点击[新增按钮]
|
||
BindGrid();
|
||
PageContext.RegisterStartupScript("onNewButtonClick();");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 右键删除事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialCompareMenuId, Const.BtnDelete))
|
||
{
|
||
this.DeleteData();
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除方法
|
||
/// </summary>
|
||
private void DeleteData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||
{
|
||
bool isShow = true;
|
||
if (Grid1.SelectedRowIndexArray.Length > 1)
|
||
{
|
||
isShow = false;
|
||
}
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
if (judgementDelete(rowID, isShow))
|
||
{
|
||
BLL.HJGL_MaterialCompareService.DeleteMaterialCompare(rowID);
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除材质焊材对照信息");
|
||
Alert.ShowInTop("删除完成!", MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
|
||
BindGrid();
|
||
PageContext.RegisterStartupScript("onNewButtonClick();");
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 编辑
|
||
/// <summary>
|
||
/// 右键编辑事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialCompareMenuId, Const.BtnModify))
|
||
{
|
||
this.EditData();
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 编辑数据方法
|
||
/// </summary>
|
||
private void EditData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!",MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string Id = Grid1.SelectedRowID;
|
||
var mc = BLL.HJGL_MaterialCompareService.getMaterialCompare(Id);
|
||
if (mc != null)
|
||
{
|
||
if (!String.IsNullOrEmpty(mc.STE_ID))
|
||
{
|
||
this.drpSteel.SelectedValue = mc.STE_ID;
|
||
}
|
||
if (!String.IsNullOrEmpty(mc.WME_ID))
|
||
{
|
||
this.drpWME.SelectedValue = mc.WME_ID;
|
||
}
|
||
if (!String.IsNullOrEmpty(mc.WMT_ID1))
|
||
{
|
||
this.drpWMT1.SelectedValue = mc.WMT_ID1;
|
||
}
|
||
if (!String.IsNullOrEmpty(mc.WMT_ID2))
|
||
{
|
||
this.drpWMT2.SelectedValue = mc.WMT_ID2;
|
||
}
|
||
|
||
this.txtRemark.Text = mc.Remark;
|
||
|
||
hfFormID.Text = Id;
|
||
this.btnDelete.Enabled = true;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 提交按钮
|
||
/// <summary>
|
||
/// 提交按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialCompareMenuId, Const.BtnSave))
|
||
{
|
||
string strRowID = hfFormID.Text;
|
||
if (BLL.HJGL_MaterialCompareService.IsExistMaterialCompare(this.drpSteel.SelectedValue,this.drpWME.SelectedValue, strRowID))
|
||
{
|
||
Alert.ShowInTop("此材质焊材对照代号已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
Model.HJGL_BS_MaterialCompare mc = new Model.HJGL_BS_MaterialCompare();
|
||
if (this.drpSteel.SelectedValue != BLL.Const._Null)
|
||
{
|
||
mc.STE_ID = this.drpSteel.SelectedValue;
|
||
}
|
||
if (this.drpWME.SelectedValue != BLL.Const._Null)
|
||
{
|
||
mc.WME_ID = this.drpWME.SelectedValue;
|
||
}
|
||
if (this.drpWMT1.SelectedValue != BLL.Const._Null)
|
||
{
|
||
mc.WMT_ID1 = this.drpWMT1.SelectedValue;
|
||
}
|
||
if (this.drpWMT2.SelectedValue != BLL.Const._Null)
|
||
{
|
||
mc.WMT_ID2 = this.drpWMT2.SelectedValue;
|
||
}
|
||
mc.Remark = this.txtRemark.Text.Trim();
|
||
|
||
if (string.IsNullOrEmpty(strRowID))
|
||
{
|
||
BLL.HJGL_MaterialCompareService.AddMaterialCompare(mc);
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加材质焊材对照信息");
|
||
}
|
||
else
|
||
{
|
||
mc.MaterialCompareId = strRowID;
|
||
BLL.HJGL_MaterialCompareService.updateMaterialCompare(mc);
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改材质焊材对照信息");
|
||
}
|
||
|
||
// 重新绑定表格,并点击当前编辑或者新增的行
|
||
BindGrid();
|
||
|
||
Alert.ShowInTop("提交成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript("onNewButtonClick();");
|
||
//PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, UnitQualitySort.UnitQualitySortId));
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 判断是否可删除
|
||
/// <summary>
|
||
/// 判断是否可以删除
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool judgementDelete(string id, bool isShow)
|
||
{
|
||
string content = string.Empty;
|
||
//if (BLL.HJGL_MaterialCompareService.GetMaterialCompareCountByWMT(id) > 0)
|
||
//{
|
||
// content = "材质对照表中已经使用了该焊材,不能删除!";
|
||
//}
|
||
|
||
if (string.IsNullOrEmpty(content))
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
if (isShow)
|
||
{
|
||
Alert.ShowInTop(content, MessageBoxIcon.Error);
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
}
|
||
} |