using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.HJGLServer.BaseInfo { public partial class JointImageItem : PageBase { /// /// 简图Id /// //private string JointImageId //{ // get // { // return (string)ViewState["JointImageId"]; // } // set // { // ViewState["JointImageId"] = value; // } //} #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //string jointImageId = Request.Params["JointImageId"]; this.drpWME_ID.DataTextField = "WME_Name"; this.drpWME_ID.DataValueField = "WME_ID"; this.drpWME_ID.DataSource = BLL.HJGL_WeldingMethodService.GetWeldMethodNameList(); this.drpWME_ID.DataBind(); Funs.FineUIPleaseSelect(this.drpWME_ID); ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 BindGrid(); } } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT Item.JointImageItemId,Item.JointImageId,Item.Code,Item.WME_ID,Item.WeldCurrent,Item.WeldVoltage,Item.WeldSpeed,WeldMethod.WME_Name" + @" FROM HJGL_WeldingProcedure_JointImageItem AS Item" + @" LEFT JOIN HJGL_BS_WeldMethod AS WeldMethod ON WeldMethod.WME_ID = Item.WME_ID" + @" WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(Request.Params["JointImageId"])) { strSql += " AND Item.JointImageId = @JointImageId"; listStr.Add(new SqlParameter("@JointImageId", Request.Params["JointImageId"])); } 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 分页排序 /// /// /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 分页下拉选择 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 删除事件 /// /// 删除 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointImageMenuId, Const.BtnDelete)) { if (judgementDelete(hfFormID.Text, true)) { BLL.HJGL_JointImageItemService.DeleteJointImageItemById(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; } } /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointImageMenuId, Const.BtnDelete)) { this.DeleteData(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 删除方法 /// 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_JointImageItemService.DeleteJointImageItemById(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 编辑 /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointImageMenuId, Const.BtnModify)) { this.EditData(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string Id = Grid1.SelectedRowID; var jointImageItem = BLL.HJGL_JointImageItemService.GetJointImageItemById(Id); if (jointImageItem != null) { this.txtCode.Text = jointImageItem.Code; if (!string.IsNullOrEmpty(jointImageItem.WME_ID)) { this.drpWME_ID.SelectedValue = jointImageItem.WME_ID; } this.txtWeldCurrent.Text = jointImageItem.WeldCurrent; this.txtWeldVoltage.Text = jointImageItem.WeldVoltage; this.txtWeldSpeed.Text = jointImageItem.WeldSpeed; //this.JointImageId = jointImageItem.JointImageId; hfFormID.Text = Id; this.btnDelete.Enabled = true; } } #endregion #region 提交按钮 /// /// 提交按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointImageMenuId, Const.BtnSave)) { string strRowID = hfFormID.Text; Model.HJGL_WeldingProcedure_JointImageItem jointImageItem = new Model.HJGL_WeldingProcedure_JointImageItem(); jointImageItem.Code = this.txtCode.Text.Trim(); if (this.drpWME_ID.SelectedValue != BLL.Const._Null) { jointImageItem.WME_ID = this.drpWME_ID.SelectedValue; } jointImageItem.WeldCurrent = this.txtWeldCurrent.Text.Trim(); jointImageItem.WeldVoltage = this.txtWeldVoltage.Text.Trim(); jointImageItem.WeldSpeed = this.txtWeldSpeed.Text.Trim(); jointImageItem.JointImageId = Request.Params["JointImageId"]; if (string.IsNullOrEmpty(strRowID)) { strRowID = SQLHelper.GetNewID(typeof(Model.HJGL_WeldingProcedure_JointImageItem)); jointImageItem.JointImageItemId = strRowID; BLL.HJGL_JointImageItemService.AddJointImageItem(jointImageItem); BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加焊接接头简图明细"); } else { jointImageItem.JointImageItemId = strRowID; BLL.HJGL_JointImageItemService.UpdateJointImageItem(jointImageItem); 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 判断是否可删除 /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content, MessageBoxIcon.Error); } return false; } } #endregion } }