315 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			315 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						||
using System;
 | 
						||
using System.Collections.Generic;
 | 
						||
using System.Linq;
 | 
						||
using System.Data;
 | 
						||
using System.Data.SqlClient;
 | 
						||
 | 
						||
namespace FineUIPro.Web.HJGL.BaseInfo
 | 
						||
{
 | 
						||
    public partial class WeldingMethod : PageBase
 | 
						||
    {
 | 
						||
        #region 加载
 | 
						||
        /// <summary>
 | 
						||
        /// 加载页面
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Page_Load(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (!IsPostBack)
 | 
						||
            {
 | 
						||
                this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | 
						||
                // 绑定表格
 | 
						||
                this.BindGrid();
 | 
						||
 | 
						||
                //if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
 | 
						||
                //{
 | 
						||
                //    this.btnNew.Hidden = true;
 | 
						||
                //    this.btnMenuEdit.Hidden = true;
 | 
						||
                //    this.btnMenuDelete.Hidden = true;
 | 
						||
                //    this.Grid1.EnableRowDoubleClickEvent = false;
 | 
						||
                //}
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 绑定数据
 | 
						||
        /// <summary>
 | 
						||
        /// 绑定数据
 | 
						||
        /// </summary>
 | 
						||
        private void BindGrid()
 | 
						||
        {
 | 
						||
            string strSql = @"SELECT WeldingMethodId,WeldingMethodCode,WeldingMethodName,Remark"
 | 
						||
                         + @" FROM dbo.Base_WeldingMethod WHERE 1=1 ";
 | 
						||
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						||
 | 
						||
            if (!string.IsNullOrEmpty(this.txtWeldingMethodCode.Text.Trim()))
 | 
						||
            {
 | 
						||
                strSql += " AND WeldingMethodCode LIKE @WeldingMethodCode";
 | 
						||
                listStr.Add(new SqlParameter("@WeldingMethodCode", "%" + this.txtWeldingMethodCode.Text.Trim() + "%"));
 | 
						||
            }
 | 
						||
            if (!string.IsNullOrEmpty(this.txtWeldingMethodName.Text.Trim()))
 | 
						||
            {
 | 
						||
                strSql += " AND WeldingMethodName LIKE @WeldingMethodName";
 | 
						||
                listStr.Add(new SqlParameter("@WeldingMethodName", "%" + this.txtWeldingMethodName.Text.Trim() + "%"));
 | 
						||
            }
 | 
						||
            SqlParameter[] parameter = listStr.ToArray();
 | 
						||
            DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | 
						||
 | 
						||
            Grid1.RecordCount = tb.Rows.Count;
 | 
						||
            //tb = GetFilteredTable(Grid1.FilteredData, tb);
 | 
						||
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						||
            Grid1.DataSource = table;
 | 
						||
            Grid1.DataBind();
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 改变索引事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						||
        {
 | 
						||
            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_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | 
						||
        {
 | 
						||
            BindGrid();
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 关闭弹出窗口
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Window1_Close(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            BindGrid();
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 增加按钮事件
 | 
						||
        /// <summary>
 | 
						||
        /// 增加按钮事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnNew_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (GetButtonPower(Const.BtnAdd))
 | 
						||
            {
 | 
						||
                PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingMethodEdit.aspx", "新增 - ")));
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 编辑
 | 
						||
        /// <summary>
 | 
						||
        /// 双击事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | 
						||
        {
 | 
						||
            this.EditData();
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 右键编辑事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnMenuEdit_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            this.EditData();
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 编辑数据方法
 | 
						||
        /// </summary>
 | 
						||
        private void EditData()
 | 
						||
        {
 | 
						||
 | 
						||
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						||
            {
 | 
						||
                Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
 | 
						||
            ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
 | 
						||
            if (GetButtonPower(Const.BtnModify))
 | 
						||
            {
 | 
						||
                PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingMethodEdit.aspx?WeldingMethodId={0}", Grid1.SelectedRowID, "编辑 - ")));
 | 
						||
            }
 | 
						||
            else if (GetButtonPower(Const.BtnSee))
 | 
						||
            {
 | 
						||
                PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingMethodView.aspx?WeldingMethodId={0}", Grid1.SelectedRowID, "查看 - ")));
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 删除
 | 
						||
        /// <summary>
 | 
						||
        /// 右键删除事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnMenuDelete_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (GetButtonPower(Const.BtnDelete))
 | 
						||
            {
 | 
						||
                if (Grid1.SelectedRowIndexArray.Length > 0)
 | 
						||
                {
 | 
						||
                    string strShowNotify = string.Empty;
 | 
						||
                    foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | 
						||
                    {
 | 
						||
                        string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | 
						||
                        var getWeldingMethod = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(rowID);
 | 
						||
                        if (getWeldingMethod != null)
 | 
						||
                        {
 | 
						||
                            string cont = judgementDelete(rowID);
 | 
						||
                            if (string.IsNullOrEmpty(cont))
 | 
						||
                            {
 | 
						||
                                BLL.Base_WeldingMethodService.DeleteWeldingMethodByWeldingMethodId(rowID);
 | 
						||
                                //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldingMethodMenuId, Const.BtnDelete, rowID);
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                strShowNotify += "焊接方法" + ":" + getWeldingMethod.WeldingMethodCode + cont;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    BindGrid();
 | 
						||
                    if (!string.IsNullOrEmpty(strShowNotify))
 | 
						||
                    {
 | 
						||
                        Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        ShowNotify("删除成功!", MessageBoxIcon.Success);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        #region 判断是否可删除
 | 
						||
        /// <summary>
 | 
						||
        /// 判断是否可以删除
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        private string judgementDelete(string id)
 | 
						||
        {
 | 
						||
            string content = string.Empty;
 | 
						||
            //if (Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldingMethodId == id) != null)
 | 
						||
            //{
 | 
						||
            //    content += "已在【焊口信息】中使用,不能删除!";
 | 
						||
            //}
 | 
						||
 | 
						||
            return content;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 查询
 | 
						||
        /// <summary>
 | 
						||
        /// 查询
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnQuery_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            this.BindGrid();
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 查看按钮
 | 
						||
        /// <summary>
 | 
						||
        /// 查看按钮
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnView_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingMethodView.aspx?WeldingMethodId={0}", Grid1.SelectedRowID, "查看 - ")));
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 格式化字符串
 | 
						||
        /// <summary>
 | 
						||
        /// 焊材类型(1-焊丝,2-焊条)
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="consumablesType"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        //protected string ConvertConsumablesType(object consumablesType)
 | 
						||
        //{
 | 
						||
        //    string name = string.Empty;
 | 
						||
        //    if (consumablesType != null)
 | 
						||
        //    {
 | 
						||
        //        var lists = consumablesType.ToString().Split(',');
 | 
						||
        //        foreach (var item in lists)
 | 
						||
        //        {
 | 
						||
        //            if (item == "1")
 | 
						||
        //            {
 | 
						||
        //                name += "焊丝" + ",";
 | 
						||
        //            }
 | 
						||
        //            if (item == "2")
 | 
						||
        //            {
 | 
						||
        //                name += "焊条" + ",";
 | 
						||
        //            }
 | 
						||
        //        }
 | 
						||
        //        if (!string.IsNullOrEmpty(name))
 | 
						||
        //        {
 | 
						||
        //            name = name.Substring(0, name.LastIndexOf(','));
 | 
						||
        //        }
 | 
						||
        //    }
 | 
						||
        //    return name;
 | 
						||
        //}
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 获取按钮权限
 | 
						||
        /// <summary>
 | 
						||
        /// 获取按钮权限
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="button"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        private bool GetButtonPower(string button)
 | 
						||
        {
 | 
						||
            return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldingMethodMenuId, button);
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
    }
 | 
						||
} |