ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/YLRQ/ReportInputOut/WeldAppearance.aspx.cs

245 lines
8.9 KiB
C#

using BLL;
using Model;
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.YLRQ.ReportInputOut
{
public partial class WeldAppearance : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BridProjectGrid();
BindGrid();
}
}
#region
/// <summary>
/// 绑定项目
/// </summary>
public void BridProjectGrid()
{
GridProject.DataSource = BLL.Base_ProjectService.GetYlrqProjectListByUserId(this.CurrUser.UserId, "2");
GridProject.DataBind();
drpProject.Value = this.CurrUser.LoginProjectId;
}
/// <summary>
/// 施工号下拉框
/// </summary>
protected void drpProject_TextChanged(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
if (string.IsNullOrEmpty(drpProject.Value))
{
Grid1.DataSource = null;
Grid1.DataBind();
return;
}
string strSql = @"select a.WeldingId,a.WeldingCode,a.ProjectId,b.AppearanceId,b.MaxStaggerEdge,b.MaxAngularity,b.MaxUndercutDepth,b.MaxUndercutLength,b.MaxContinuousLength,b.WeldLegHeigth,b.InspectConclusion,b.InspectTime from PV_WeldInformation as a left join PV_WeldAppearanceRecord as b on a.WeldingId=b.WeldingId where 1=1 and a.Confirmation=1 and a.ProjectId=@ProjectId ";
//是否录入
if (rblIsEnter.SelectedValue == "1")
{
strSql += " and b.AppearanceId is null ";
}
else
{
strSql += " and b.AppearanceId is not null ";
}
//焊缝编号
if (!string.IsNullOrEmpty(txtWeldingCode.Text))
{
strSql += " and a.WeldingCode like '%" + txtWeldingCode.Text + "%' ";
}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", drpProject.Value));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
/// <summary>
/// 绑定Grid2
/// </summary>
public void BindGrid1(string weldingId)
{
//获取当前焊缝信息
var ndtIds = Funs.DB.PV_ManagementMethod.Where(p => p.WeldingId == weldingId).Select(p => p.NdtId);
if (ndtIds.Count() > 0)
{
var list = Funs.DB.PV_TestMethod.Where(p => ndtIds.Contains(p.Ndt_Id));
if (list.Count() > 0)
{
// 2.获取当前分页数据
Grid2.RecordCount = list.Count();
var table = this.GetPagedDataTable(Grid2, list);
Grid2.DataSource = table;
Grid2.DataBind();
}
}
else
{
Grid2.DataSource = null;
Grid2.DataBind();
}
}
/// <summary>
/// 是否录入
/// </summary>
protected void rblIsEnter_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 点击行事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
{
if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
{
BindGrid1(this.Grid1.SelectedRowID);
}
}
#endregion
#region
/// <summary>
/// 页索引改变事件
/// </summary>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#endregion
#region
/// <summary>
/// 保存
/// </summary>
protected void btnSave_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldAppearance, Const.BtnSubmit))
{
var addFlag = false;
List<PV_WeldAppearanceRecord> list = new List<PV_WeldAppearanceRecord>();
Dictionary<int, Dictionary<string, object>> modifiedDict = Grid1.GetModifiedDict();
//删除所有已存在的
foreach (int rowIndex in modifiedDict.Keys)
{
var weldingId = Grid1.DataKeys[rowIndex][0].ToString();
var weldingCode = Grid1.DataKeys[rowIndex][1].ToString();
var appearanModel = Funs.DB.PV_WeldAppearanceRecord.FirstOrDefault(p => p.WeldingId == weldingId);
if (appearanModel == null)
{
addFlag = true;
appearanModel = new PV_WeldAppearanceRecord();
appearanModel.AppearanceId = Guid.NewGuid().ToString();
appearanModel.WeldingId = weldingId;
appearanModel.WeldingCode = weldingCode;
appearanModel.CreateId = this.CurrUser.UserId;
appearanModel.CreateTime = DateTime.Now;
}
if (modifiedDict[rowIndex].ContainsKey("MaxStaggerEdge"))
{
appearanModel.MaxStaggerEdge = decimal.Parse(modifiedDict[rowIndex]["MaxStaggerEdge"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("MaxAngularity"))
{
appearanModel.MaxAngularity = decimal.Parse(modifiedDict[rowIndex]["MaxAngularity"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("MaxUndercutDepth"))
{
appearanModel.MaxUndercutDepth = decimal.Parse(modifiedDict[rowIndex]["MaxUndercutDepth"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("MaxUndercutLength"))
{
appearanModel.MaxUndercutLength = decimal.Parse(modifiedDict[rowIndex]["MaxUndercutLength"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("MaxContinuousLength"))
{
appearanModel.MaxContinuousLength = decimal.Parse(modifiedDict[rowIndex]["MaxContinuousLength"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("WeldLegHeigth"))
{
appearanModel.WeldLegHeigth = decimal.Parse(modifiedDict[rowIndex]["WeldLegHeigth"].ToString());
}
if (modifiedDict[rowIndex].ContainsKey("InspectConclusion"))
{
appearanModel.InspectConclusion = modifiedDict[rowIndex]["InspectConclusion"].ToString();
}
if (modifiedDict[rowIndex].ContainsKey("InspectTime"))
{
appearanModel.InspectTime = DateTime.Parse(modifiedDict[rowIndex]["InspectTime"].ToString());
}
if (addFlag) Funs.DB.PV_WeldAppearanceRecord.InsertOnSubmit(appearanModel);
Funs.DB.SubmitChanges();
}
BindGrid();
ShowNotify("操作成功!");
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
}
}