256 lines
12 KiB
C#
256 lines
12 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.IO;
|
|
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class WeldingRodBaking : PageBase
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private static List<Model.HJGL_BakeRecords> reportLists = new List<Model.HJGL_BakeRecords>();
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.drpProjectId.DataTextField = "ProjectCode";
|
|
this.drpProjectId.DataValueField = "ProjectId";
|
|
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectList("1");
|
|
this.drpProjectId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProjectId);
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
BindGrid();
|
|
}
|
|
}
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT BakeRecords.BakeRecordsId,
|
|
BakeRecords.BakeDate,
|
|
BakeRecords.Brand,
|
|
BakeRecords.BatchNum,
|
|
BakeRecords.InboundSelfNum,
|
|
BakeRecords.Specifications,
|
|
BakeRecords.Quantity,
|
|
BakeRecords.PowerTime,
|
|
datepart(HOUR,BakeRecords.PowerTime) as PowerTimeHour,
|
|
datepart(MINUTE,BakeRecords.PowerTime) as PowerTimeMin,
|
|
BakeRecords.PowerTemperature,
|
|
BakeRecords.ConstantTemperature,
|
|
BakeRecords.ConstantStartTime,
|
|
datepart(HOUR,BakeRecords.ConstantStartTime) as ConstantStartHour,
|
|
datepart(MINUTE,BakeRecords.ConstantStartTime) as ConstantStartMin,
|
|
BakeRecords.ConstantEndTime,
|
|
datepart(HOUR,BakeRecords.ConstantEndTime) as ConstantEndHour,
|
|
datepart(MINUTE,BakeRecords.ConstantEndTime) as ConstantEndMin,
|
|
BakeRecords.MoveInsulationBoxTime,
|
|
datepart(HOUR,BakeRecords.MoveInsulationBoxTime) as MoveInsulationBoxHour,
|
|
datepart(MINUTE,BakeRecords.MoveInsulationBoxTime) as MoveInsulationBoxMin,
|
|
BakeRecords.MoveInsulationBoxTemperature,
|
|
BakeRecords.BakingFrequency,
|
|
BakeRecords.Bakers,
|
|
BakeRecords.UnitStoreId,
|
|
BakeRecords.Type,
|
|
store.UnitStoreName
|
|
FROM dbo.HJGL_BakeRecords AS BakeRecords
|
|
LEFT JOIN dbo.Weld_UnitStore store ON store.UnitStoreId=BakeRecords.UnitStoreId
|
|
WHERE BakeRecords.Type='1' ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//listStr.Add(new SqlParameter("@projectId",this.drpProjectId.SelectedValue));
|
|
if (!string.IsNullOrEmpty(this.txtBrand.Text.Trim()))
|
|
{
|
|
strSql += " AND BakeRecords.Brand LIKE @Brand";
|
|
listStr.Add(new SqlParameter("@Brand", "%" + this.txtBrand.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
|
|
{
|
|
strSql += " AND BakeRecords.BakeDate >= @startDate";
|
|
listStr.Add(new SqlParameter("@startDate", this.txtStartDate.Text.Trim()));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
|
|
{
|
|
strSql += " AND BakeRecords.BakeDate <= @endDate";
|
|
listStr.Add(new SqlParameter("@endDate", this.txtEndDate.Text.Trim()));
|
|
}
|
|
strSql += " order by BakeRecords.BakeDate desc";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = tb;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, 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 btnSure_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpProjectId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择项目!");
|
|
return;
|
|
}
|
|
reportLists.Clear();
|
|
if (Grid1.SelectedRowIDArray.Length <= 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!");
|
|
return;
|
|
}
|
|
string[] selectRowId = Grid1.SelectedRowIDArray;
|
|
int n = 0;
|
|
int j = 0;
|
|
int[] selections = new int[selectRowId.Count()];
|
|
foreach (GridRow row in Grid1.Rows)
|
|
{
|
|
if (selectRowId.Contains(row.DataKeys[0]))
|
|
{
|
|
selections[n] = j;
|
|
n++;
|
|
}
|
|
j++;
|
|
}
|
|
|
|
var select = selections.Distinct();
|
|
foreach (int i in select)
|
|
{
|
|
var bakeRecords = BLL.BakeRecordsService.GetBakeRecordsById(Grid1.DataKeys[i][0].ToString());
|
|
if (bakeRecords != null)
|
|
{
|
|
reportLists.Add(bakeRecords);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtBrand.Text.Trim()))
|
|
{
|
|
reportLists = (from x in reportLists where x.Brand.Contains(this.txtBrand.Text.Trim()) select x).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
|
|
{
|
|
reportLists = (from x in reportLists where x.BakeDate >= Funs.GetNewDateTime(this.txtStartDate.Text.Trim()) select x).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
|
|
{
|
|
reportLists = (from x in reportLists where x.BakeDate <= Funs.GetNewDateTime(this.txtEndDate.Text.Trim()) select x).ToList();
|
|
}
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.drpProjectId.SelectedValue);
|
|
if (project != null)
|
|
{
|
|
keyValuePairs.Add("ProjectName", project.ProjectName);
|
|
}
|
|
}
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("BakeDateMonth");
|
|
dt.Columns.Add("BakeDateDay");
|
|
dt.Columns.Add("Brand");
|
|
dt.Columns.Add("BatchNum");
|
|
dt.Columns.Add("InboundSelfNum");
|
|
dt.Columns.Add("Specifications");
|
|
dt.Columns.Add("Quantity");
|
|
dt.Columns.Add("PowerTimeHour");
|
|
dt.Columns.Add("PowerTimeMin");
|
|
dt.Columns.Add("PowerTemperature");
|
|
dt.Columns.Add("ConstantTemperature");
|
|
dt.Columns.Add("ConstantStartHour");
|
|
dt.Columns.Add("ConstantStartMin");
|
|
dt.Columns.Add("ConstantEndHour");
|
|
dt.Columns.Add("ConstantEndMin");
|
|
dt.Columns.Add("MoveInsulationBoxHour");
|
|
dt.Columns.Add("MoveInsulationBoxMin");
|
|
dt.Columns.Add("MoveInsulationBoxTemperature");
|
|
dt.Columns.Add("BakingFrequency");
|
|
dt.Columns.Add("Bakers");
|
|
reportLists = reportLists.OrderBy(x => x.BakeDate).ToList();
|
|
foreach (var item in reportLists)
|
|
{
|
|
var newRow = dt.NewRow();
|
|
newRow["BakeDateMonth"] = item.BakeDate.Value.Month.ToString();
|
|
newRow["BakeDateDay"] = item.BakeDate.Value.Day.ToString();
|
|
newRow["Brand"] = item.Brand;
|
|
newRow["BatchNum"] = item.BatchNum;
|
|
newRow["InboundSelfNum"] = item.InboundSelfNum;
|
|
newRow["Specifications"] = item.Specifications;
|
|
newRow["Quantity"] = item.Quantity.Value.ToString("0.#");
|
|
newRow["PowerTimeHour"] = item.PowerTime.HasValue ? item.PowerTime.Value.Hour.ToString() : "";
|
|
newRow["PowerTimeMin"] = item.PowerTime.HasValue ? item.PowerTime.Value.Minute.ToString() : "";
|
|
newRow["PowerTemperature"] = item.PowerTemperature.HasValue ? item.PowerTemperature.Value.ToString("0.#") : "";
|
|
newRow["ConstantTemperature"] = item.ConstantTemperature.HasValue ? item.ConstantTemperature.Value.ToString("0.#") : "";
|
|
newRow["ConstantStartHour"] = item.ConstantStartTime.HasValue ? item.ConstantStartTime.Value.Hour.ToString() : "";
|
|
newRow["ConstantStartMin"] = item.ConstantStartTime.HasValue ? item.ConstantStartTime.Value.Minute.ToString() : "";
|
|
newRow["ConstantEndHour"] = item.ConstantEndTime.HasValue ? item.ConstantEndTime.Value.Hour.ToString() : "";
|
|
newRow["ConstantEndMin"] = item.ConstantEndTime.HasValue ? item.ConstantEndTime.Value.Minute.ToString() : "";
|
|
newRow["MoveInsulationBoxHour"] = item.MoveInsulationBoxTime.HasValue ? item.MoveInsulationBoxTime.Value.Hour.ToString() : "";
|
|
newRow["MoveInsulationBoxMin"] = item.MoveInsulationBoxTime.HasValue ? item.MoveInsulationBoxTime.Value.Minute.ToString() : "";
|
|
newRow["MoveInsulationBoxTemperature"] = item.MoveInsulationBoxTemperature.HasValue ? item.MoveInsulationBoxTemperature.Value.ToString("0.#") : "";
|
|
newRow["BakingFrequency"] = item.BakingFrequency.ToString();
|
|
newRow["Bakers"] = item.Bakers;
|
|
dt.Rows.Add(newRow);
|
|
}
|
|
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
initTemplatePath = "File\\Fastreport\\焊条烘烤记录.frx";
|
|
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查找
|
|
/// <summary>
|
|
/// 查找
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |