12 Answers, 1 is accepted
Please remove Width="100%" from the MasterTableView tag.
Please set TableLayout="Fixed".
Let me know if any concern.
Thanks,
Jayesh Goyani
The issue did not resolved.
One more information, all the columns are generating dynamically not a static one.
The described issue is not replicated on our side, so could you please provide a sample page which we can use to replicate it?
Thank you for the cooperation.
Regards,
Galin
Telerik
#region Page header
//-----------------------------------------------------------------------
// <copyright file="WashLibrary.aspx.cs" company="Ecolab">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Author: Rameshkumar Manickam
// Create date: 20-Nov-2012
// Description: This page is handling Wash information.
// Modified By: Rajan
// Modified date: 02-Feb-2013
// Description: Radgrid creation in runtime.
// </summary>
//-----------------------------------------------------------------------
#endregion
using System.IO;
using System.Text;
using Ecolab.Transformetrixx.Mediator.Entities.Views;
#region WashLibrary
namespace TFMxUI_CustomerSetUp.Reports
{
#region NameSpace
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataClass;
using DataClass.Template;
using Ecolab.Transformetrixx.Logging;
using Ecolab.Transformetrixx.Mediator.Entities.Interfaces;
using Ecolab.Transformetrixx.Mediator.Interfaces;
using Logging;
using Telerik.Web.UI;
using Telerik.Web.UI.Calendar;
#endregion
/// <summary>
/// The wash library.
/// </summary>
public partial class WashLibrary : BasePage
{
#region Variables
public string StrRefreshText = string.Empty;
public string StrDownLoadText = string.Empty;
private IRoleAccessPrivilege mRoleAccessPrivilege;
private ICIPSystem mSelectedSystem;
private ICIPLine mSelectedLine;
private IObject mSelectedObject;
private IArea mSelectedArea;
private DataTable mWashDataTable;
private GlobalProperties mGlobalProperties;
private TraceLogger mLogger;
private string mCurrentPage;
private IUser mUserObject;
private IPlant mPlantObject;
private FacadeCollection mFacadeCollection;
#endregion
#region Protected methods
/// <summary>
/// The page_ init.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void Page_Init(object sender, EventArgs e)
{
try
{
InitializeVariables();
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
if (Session[ApplicationConstant.SessionNameWashLibWashes] != null)
{
var listWashes = Session[ApplicationConstant.SessionNameWashLibWashes] as DataTable;
GenerateRadgrid(listWashes);
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The page_ load.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void Page_Load(object sender, EventArgs e)
{
InitializePageLoad();
if (!Page.IsPostBack)
{
Page.SmartNavigation = true;
Session["FilteredColumnName"] = null;
Session["FilteredColumnValue"] = null;
Session["FilteredColumnType"] = null;
}
}
/// <summary>
/// The ddl wash option_ selected index changed.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void ddlWashOption_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
lblMessage.Visible = false;
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
reqValCipArea.Enabled = false;
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
switch (ddlWashOption.SelectedItem.Value)
{
case ApplicationConstant.Number3:
{
IAreaFacade areaFacade = mFacadeCollection.GetAreaFacade();
ddlCipArea.Items.Clear();
ddlCipArea.DataSource = areaFacade.SelectPlantAreas(mPlantObject);
ddlCipArea.DataTextField = ApplicationConstant.Name;
ddlCipArea.DataValueField = ApplicationConstant.ID;
ddlCipArea.DataBind();
ddlCipArea.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlCipArea.SelectedValue = ApplicationConstant.NumberMinus1;
trCIPSystem.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPArea.Style.Value = ApplicationConstant.DisplayBlockSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayBlockSimple;
reqValCipArea.Enabled = true;
areaFacade.SelectPlantAreas(mPlantObject);
}
break;
case ApplicationConstant.Number1:
trCIPSystem.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPArea.Style.Value = ApplicationConstant.DisplayNoneSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayBlockSimple;
break;
case ApplicationConstant.NumberMinus1:
trCIPSystem.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPArea.Style.Value = ApplicationConstant.DisplayNoneSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayNoneSimple;
break;
default:
{
trCIPSystem.Style.Value = ApplicationConstant.DisplayBlockSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayBlockSimple;
trCIPArea.Style.Value = ApplicationConstant.DisplayNoneSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayBlockSimple;
IWashLibraryFacade washLibraryFacade = mFacadeCollection.GetWashLibraryFacade();
List<ICIPSystem> systems = washLibraryFacade.SelectCIPSystemForPlant(mPlantObject);
List<IObject> objects = washLibraryFacade.SelectCIPObjectsForPlant(mPlantObject);
ddlCipSystem.Items.Clear();
ddlCipSystem.DataSource = systems;
ddlCipSystem.DataTextField = ApplicationConstant.Name;
ddlCipSystem.DataValueField = ApplicationConstant.ID;
ddlCipSystem.DataBind();
ddlCipSystem.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlCipLine.SelectedValue = ApplicationConstant.NumberMinus1;
ddlObjects.Items.Clear();
ddlObjects.DataSource = objects;
ddlObjects.DataTextField = ApplicationConstant.Name;
ddlObjects.DataValueField = ApplicationConstant.ID;
ddlObjects.DataBind();
ddlObjects.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlObjects.SelectedValue = ApplicationConstant.NumberMinus1;
}
break;
}
dptodate.SelectedDate = null;
dpfromdate.SelectedDate = null;
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The ddl cip system_ selected index changed.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void ddlCipSystem_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
dptodate.SelectedDate = null;
dpfromdate.SelectedDate = null;
lblMessage.Visible = false;
IWashLibraryFacade washLibraryFacade = mFacadeCollection.GetWashLibraryFacade();
List<ICIPSystem> systems = washLibraryFacade.SelectCIPSystemForPlant(mPlantObject);
if (ddlCipSystem.SelectedIndex > 0)
{
mSelectedSystem = (from s in systems
where s.ID == ddlCipSystem.SelectedValue.ConvertToInt()
select s).FirstOrDefault();
if (mSelectedSystem != null)
{
ddlCipLine.DataSource = mSelectedSystem.CIPLines;
ddlCipLine.DataTextField = ApplicationConstant.Name;
ddlCipLine.DataValueField = ApplicationConstant.ID;
ddlCipLine.DataBind();
ddlCipLine.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlCipLine.SelectedValue = ApplicationConstant.NumberMinus1;
}
ddlObjects.SelectedValue = ApplicationConstant.NumberMinus1;
}
else if (ddlCipSystem.SelectedIndex == 0)
{
List<IObject> objects = washLibraryFacade.SelectCIPObjectsForPlant(mPlantObject);
ddlObjects.DataSource = objects;
ddlObjects.DataBind();
ddlObjects.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlObjects.SelectedValue = ApplicationConstant.NumberMinus1;
ddlCipLine.Items.Clear();
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
}
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
Session[ApplicationConstant.SessionNameWashLibWashes] = null;
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// Handles the dropdown list CIP Line Selected Index Changed Event.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">EventArgs.</param>
protected void ddlCipLine_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
dptodate.SelectedDate = null;
dpfromdate.SelectedDate = null;
lblMessage.Visible = false;
List<ICIPSystem> systems = mFacadeCollection.GetWashLibraryFacade().SelectCIPSystemForPlant(mPlantObject);
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
if (ddlCipSystem.SelectedIndex > 0)
{
mSelectedSystem = (from s in systems
where s.ID == ddlCipSystem.SelectedValue.ConvertToInt()
select s).FirstOrDefault();
}
if (ddlCipLine.SelectedValue != ApplicationConstant.NumberMinus1 && mSelectedSystem != null)
{
mSelectedLine = (from l in mSelectedSystem.CIPLines
where l.ID == ddlCipLine.SelectedValue.ConvertToInt()
select l).FirstOrDefault();
if (mSelectedLine != null)
{
ddlObjects.DataSource = mSelectedLine.Objects;
ddlObjects.DataTextField = ApplicationConstant.Name;
ddlObjects.DataValueField = ApplicationConstant.ID;
ddlObjects.DataBind();
ddlObjects.Items.Insert(0, new ListItem(select.ToString(), ApplicationConstant.NumberMinus1, true));
ddlObjects.SelectedValue = ApplicationConstant.NumberMinus1;
}
}
if (ddlCipLine.SelectedIndex == 0)
{
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
}
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
Session[ApplicationConstant.SessionNameWashLibWashes] = null;
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The ddl objects_ selected index changed.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void ddlObjects_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
dptodate.SelectedDate = null;
dpfromdate.SelectedDate = null;
IWashLibraryFacade washLibraryFacade = mFacadeCollection.GetWashLibraryFacade();
List<IObject> objects = washLibraryFacade.SelectCIPObjectsForPlant(mPlantObject);
List<ICIPSystem> systems = washLibraryFacade.SelectCIPSystemForPlant(mPlantObject);
if (ddlCipSystem.SelectedIndex > 0)
{
mSelectedSystem = (from s in systems
where s.ID == ddlCipSystem.SelectedValue.ConvertToInt()
select s).FirstOrDefault();
}
if (ddlCipLine.SelectedValue != ApplicationConstant.NumberMinus1 && mSelectedSystem != null)
{
mSelectedLine = (from l in mSelectedSystem.CIPLines
where l.ID == ddlCipLine.SelectedValue.ConvertToInt()
select l).FirstOrDefault();
}
lblMessage.Visible = false;
if (ddlObjects.SelectedValue != ApplicationConstant.NumberMinus1)
{
if (mSelectedLine != null)
{
mSelectedObject = (from o in mSelectedLine.Objects
where o.ID == ddlObjects.SelectedValue.ConvertToInt()
select o).FirstOrDefault();
}
else if (objects != null)
{
mSelectedObject = (from o in objects
where o.ID == ddlObjects.SelectedValue.ConvertToInt()
select o).FirstOrDefault();
}
if (mSelectedObject != null)
{
dptodate.SelectedDate = null;
}
}
if (ddlObjects.SelectedIndex == 0)
{
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
}
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
Session[ApplicationConstant.SessionNameWashLibWashes] = null;
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The dpfromdate_ selected date changed.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void dpfromdate_SelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
{
lblMessage.Visible = false;
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
}
/// <summary>
/// The dptodate_ selected date changed.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void dptodate_SelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
{
lblMessage.Visible = false;
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
}
/// <summary>
/// The lbtn show hide_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void lbtnShowHide_Click(object sender, EventArgs e)
{
try
{
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
if (lbtnShowHide.Text == Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES377")))
{
lbtnShowHide.Text = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES397"));
divShowHide.Style.Value = ApplicationConstant.DisplayBlockSimple;
if (dpfromdate.IsEmpty && dptodate.IsEmpty)
{
trCIPSystem.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayNoneSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayNoneSimple;
ddlWashOption.SelectedValue = ddlWashOption.Items.FindByText(select.ToString()).Value;
}
}
else
{
divShowHide.Style.Value = ApplicationConstant.DisplayNoneSimple;
lbtnShowHide.Text = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES377"));
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The lbtn recent wash_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void lbtnRecentWash_Click(object sender, EventArgs e)
{
try
{
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
DataTable washDataTable = null;
bool hasHeader = false;
DateTime dateTimeStart =
DateTime.SpecifyKind(DateTime.Now.AddHours(-24), DateTimeKind.Unspecified)
;
DateTime dateTimeEnd =
DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified)
;
List<IWashLibraryView> listWashes =
mFacadeCollection.GetWashLibraryFacade()
.SelectWashLibraryViewForPlantInPeriod(mPlantObject.ID, dateTimeStart, dateTimeEnd);
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash(new List<IWashLibraryView>());
washDataTable = GetWashHeaders();
}
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
ddlWashOption.SelectedValue = ddlWashOption.Items.FindByText(select.ToString()).Value;
trCIPSystem.Style.Value = ApplicationConstant.DisplayNoneSimple;
trCIPLine.Style.Value = ApplicationConstant.DisplayNoneSimple;
trDateRange.Style.Value = ApplicationConstant.DisplayNoneSimple;
lbtnShowHide.Text =
Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES377"));
divShowHide.Style.Value = ApplicationConstant.DisplayNoneSimple;
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The btn search_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void btnSearch_Click(object sender, EventArgs e)
{
try
{
var select = HttpContext.GetGlobalResourceObject(
ApplicationConstant.CustomerSetUpResource, "CSRES52");
Session["FilteredColumnName"] = null;
Session["FilteredColumnValue"] = null;
Session["FilteredColumnType"] = null;
IWashLibraryFacade washLibraryFacade = mFacadeCollection.GetWashLibraryFacade();
List<ICIPSystem> systems = washLibraryFacade.SelectCIPSystemForPlant(mPlantObject);
List<IObject> objects = washLibraryFacade.SelectCIPObjectsForPlant(mPlantObject);
if (ddlCipSystem.SelectedIndex > 0)
{
mSelectedSystem = (from s in systems
where s.ID == ddlCipSystem.SelectedValue.ConvertToInt()
select s).FirstOrDefault();
}
if (ddlCipLine.SelectedValue != ApplicationConstant.NumberMinus1 && mSelectedSystem != null)
{
mSelectedLine = (from l in mSelectedSystem.CIPLines
where l.ID == ddlCipLine.SelectedValue.ConvertToInt()
select l).FirstOrDefault();
if (mSelectedLine != null)
mSelectedObject = (from o in mSelectedLine.Objects
where o.ID == ddlObjects.SelectedValue.ConvertToInt()
select o).FirstOrDefault();
}
else if (objects != null)
{
mSelectedObject = (from o in objects
where o.ID == ddlObjects.SelectedValue.ConvertToInt()
select o).FirstOrDefault();
}
IAreaFacade areaFacade = mFacadeCollection.GetAreaFacade();
areaFacade.SelectPlantAreas(mPlantObject);
List<IArea> areas = areaFacade.SelectPlantAreas(mPlantObject).ToList();
lblMessage.Visible = false;
bool hasHeader = false;
DataTable washDataTable = null;
switch (ddlWashOption.SelectedValue)
{
case ApplicationConstant.Number1:
if (!dpfromdate.SelectedDate.HasValue || !dptodate.SelectedDate.HasValue)
{
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
lblMessage.Text =
Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES398"));
lblMessage.Visible = true;
}
else if (dpfromdate.SelectedDate > dptodate.SelectedDate)
{
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.None);
lblMessage.Text = Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES506"));
lblMessage.Visible = true;
}
else
{
List<IWashLibraryView> listWashes =
washLibraryFacade.SelectWashLibraryViewForPlantInPeriod(mPlantObject.ID,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWashes.Any())
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.BlockSmall);
lblMessage.Text = string.Empty;
}
break;
case ApplicationConstant.Number2:
if (dpfromdate.SelectedDate > dptodate.SelectedDate)
{
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.None);
lblMessage.Text = Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES506"));
lblMessage.Visible = true;
}
else if (mSelectedSystem != null && mSelectedLine != null && mSelectedObject != null)
{
List<IWashLibraryView> listWashes =
washLibraryFacade.SelectWashLibraryViewForObjectAndLineInPeriod(mSelectedObject,
mSelectedLine,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.Block);
lblMessage.Text = string.Empty;
}
else if (mSelectedSystem != null && mSelectedLine != null)
{
List<IWashLibraryView> listWashes =
washLibraryFacade.SelectWashLibraryViewForLineInPeriod(mSelectedLine,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.BlockSmall);
lblMessage.Text = string.Empty;
}
else if (mSelectedSystem != null)
{
List<IWashLibraryView> listWashes =
washLibraryFacade.SelectWashLibraryViewForCIPSystemInPeriod(mSelectedSystem,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.BlockSmall);
lblMessage.Text = string.Empty;
}
else if (mSelectedObject != null)
{
List<IWashLibraryView> listWashes =
washLibraryFacade.SelectWashLibraryViewForObjectInPeriod(mSelectedObject,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
//TODO : Code Observation : Rameshkumar M : This Session will not be moved as it is having business logic involvement
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.BlockSmall);
lblMessage.Text = string.Empty;
}
else
{
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.None);
lblMessage.Text = Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES505"));
lblMessage.Visible = true;
}
break;
case ApplicationConstant.Number3:
if (!dpfromdate.SelectedDate.HasValue && !dptodate.SelectedDate.HasValue)
{
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.None);
lblMessage.Text =
Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES398"));
lblMessage.Visible = true;
return;
}
if (dpfromdate.SelectedDate > dptodate.SelectedDate)
{
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.None);
lblMessage.Text = Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES506"));
lblMessage.Visible = true;
return;
}
if (ddlCipArea.SelectedItem.Text == select.ToString())
{
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.None);
lblMessage.Visible = true;
lblMessage.Text = Convert.ToString(
HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource,
"CSRES504"));
return;
}
mSelectedArea =
areas.FirstOrDefault(a => a.ID == ddlCipArea.SelectedValue.ConvertToInt());
List<IWashLibraryView> listWash =
washLibraryFacade.SelectWashLibraryViewForAreaInPeriod(mSelectedArea,
Convert.ToDateTime(string.Format("{0:d} {1}", dpfromdate.DbSelectedDate,
ApplicationConstant.TimeStart)),
Convert.ToDateTime(string.Format("{0:d} {1}", dptodate.DbSelectedDate,
ApplicationConstant.TimeEnd)));
if (listWash.Any())
{
SetMaterialforWash(listWash);
foreach (IWashLibraryView objWl in listWash)
{
if (!hasHeader)
{
washDataTable = GetWashHeaders();
hasHeader = true;
}
washDataTable = GetWashDatatoTable(objWl, washDataTable);
}
}
else
{
SetMaterialforWash((new List<IWashLibraryView>()));
washDataTable = GetWashHeaders();
}
Session[ApplicationConstant.SessionNameWashLibWashes] = washDataTable;
GenerateRadgrid(washDataTable);
divWashReport.Style.Add(ApplicationConstant.Display, ApplicationConstant.Block);
lblMessage.Text = string.Empty;
break;
default:
mGlobalProperties.LogSwitchWarning(mCurrentPage, "btnSearch_Click", ddlWashOption.SelectedValue);
break;
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The img btn view notifications_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void imgBtnViewNotifications_Click(object sender, EventArgs e)
{
try
{
var lbtn = sender as ImageButton;
if (lbtn != null)
{
var gdt = lbtn.Parent.NamingContainer as GridDataItem;
if (gdt != null)
{
Session[ApplicationConstant.SessionNameSourceWashNotification] = gdt.GetDataKeyValue("WashID").ConvertToInt();
}
}
Session[ApplicationConstant.SessionNameNotificationType] = ApplicationConstant.NotificationWash;
Response.Redirect(ApplicationConstant.NotificationTriggeredFromWashLibraryUrl, false);
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The img btn view notification list_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void imgBtnViewNotificationList_Click(object sender, EventArgs e)
{
Session[ApplicationConstant.SessionNameSourceWashNotification] = null;
Session[ApplicationConstant.DashboardPortletPeriod] = null;
Session[ApplicationConstant.SessionNameNotificationType] = ApplicationConstant.NotificationWash;
Response.Redirect(ApplicationConstant.NotificationTriggeredFromWashLibraryUrl, false);
}
/// <summary>
/// The lbtn wash date time_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void lbtnWashDateTime_Click(object sender, EventArgs e)
{
try
{
var lbtn = sender as LinkButton;
if (lbtn != null)
{
var gdt = lbtn.Parent.NamingContainer as GridDataItem;
if (gdt != null)
{
int washId = gdt.GetDataKeyValue("WashID").ConvertToInt();
Session[ApplicationConstant.SessionNameWashId] = washId;
}
}
var hashtable = new Hashtable();
hashtable.Add(ApplicationConstant.PageNameNavigate, Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES376")));
hashtable.Add(ApplicationConstant.PageUrlNavigate, ApplicationConstant.WashLibraryUrl);
Session[ApplicationConstant.SessionNameBreadCrumbNavigation] = hashtable;
Response.Redirect(ApplicationConstant.WashSummaryUrl, false);
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The dashboard_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void Dashboard_Click(object sender, EventArgs e)
{
Session[ApplicationConstant.SessionNameMenuFlag] = ApplicationConstant.Dashboard;
Response.Redirect(ApplicationConstant.DefaultPageURL, false);
}
#endregion
#region Private methods
/// <summary>
/// Load the Facility on the Page Load.
/// </summary>
private void LoadFacility()
{
bool hasHeader = false;
DateTime dateTimeStart = DateTime.SpecifyKind(DateTime.Now.AddHours(-24), DateTimeKind.Unspecified);
DateTime dateTimeEnd = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified);
List<IWashLibraryView> listWashes =
mFacadeCollection.GetWashLibraryFacade()
.SelectWashLibraryViewForPlantInPeriod(mPlantObject.ID, dateTimeStart, dateTimeEnd);
if (listWashes.Count > 0)
{
SetMaterialforWash(listWashes);
foreach (IWashLibraryView objWl in listWashes)
{
if (!hasHeader)
{
mWashDataTable = GetWashHeaders();
hasHeader = true;
}
mWashDataTable = GetWashDatatoTable(objWl, mWashDataTable);
}
}
else
{
SetMaterialforWash(new List<IWashLibraryView>());
mWashDataTable = GetWashHeaders();
}
Session[ApplicationConstant.SessionNameWashLibWashes] = mWashDataTable;
GenerateRadgrid(mWashDataTable);
divWashReport.Style.Add(ApplicationConstant.DisplaySmall, ApplicationConstant.BlockSmall);
divShowHide.Style.Value = ApplicationConstant.DisplayNoneSimple;
lbtnShowHide.Text = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES377"));
}
/// <summary>
/// The get wash headers.
/// </summary>
/// <returns>
/// The <see cref="DataTable"/>.
/// </returns>
private DataTable GetWashHeaders()
{
//// create DataTable object
var washDataTable = new DataTable();
// Wash id column
var dataColumn = new DataColumn("WashID", typeof(int));
washDataTable.Columns.Add(dataColumn);
// Wash start column
dataColumn = new DataColumn("WashStart", typeof(DateTime));
washDataTable.Columns.Add(dataColumn);
// Duration column
dataColumn = new DataColumn(ApplicationConstant.Duration, typeof(string));
washDataTable.Columns.Add(dataColumn);
// IsPerfect Wash
dataColumn = new DataColumn("IsPerfectWash", typeof(bool));
washDataTable.Columns.Add(dataColumn);
// CIP System column
dataColumn = new DataColumn(ApplicationConstant.SessionNameCipSystem, typeof(string));
washDataTable.Columns.Add(dataColumn);
// CIP Line column
dataColumn = new DataColumn(ApplicationConstant.SessionNameCipLine, typeof(string));
washDataTable.Columns.Add(dataColumn);
// CIP Object column
dataColumn = new DataColumn(ApplicationConstant.CipObject, typeof(string));
washDataTable.Columns.Add(dataColumn);
// Recipe column
dataColumn = new DataColumn(ApplicationConstant.Recipe, typeof(string));
washDataTable.Columns.Add(dataColumn);
// Total Cost column
dataColumn = new DataColumn("Total Cost", typeof(double));
washDataTable.Columns.Add(dataColumn);
// Has Notification column
dataColumn = new DataColumn("HasNotification", typeof(bool));
washDataTable.Columns.Add(dataColumn);
dataColumn = new DataColumn("NotificationStatus", typeof(string));
washDataTable.Columns.Add(dataColumn);
// Wash Descriptor column
dataColumn = new DataColumn(ApplicationConstant.WashDescriptor, typeof(string));
washDataTable.Columns.Add(dataColumn);
// Electrical Amount column
dataColumn = new DataColumn(ApplicationConstant.ElectricalAmount, typeof(double));
washDataTable.Columns.Add(dataColumn);
// Thermal Amount column
dataColumn = new DataColumn("Thermal Amount", typeof(double));
washDataTable.Columns.Add(dataColumn);
// Chemical Amount column
var selectedChemical = ViewState[ApplicationConstant.ViewStateChemicalConsumption] as List<string>;
if (selectedChemical != null)
{
foreach (string currentChemical in selectedChemical)
{
if (!dataColumn.ColumnName.Contains(string.Concat(currentChemical, " Amount")))
{
dataColumn = new DataColumn(string.Concat(currentChemical, " Amount"), typeof(double));
washDataTable.Columns.Add(dataColumn);
}
}
}
// Water Amount column
var selectedWater = ViewState[ApplicationConstant.ViewStateWaterConsumption] as List<string>;
if (selectedWater != null)
{
foreach (string currentWater in selectedWater.Where(currentWater => !dataColumn.ColumnName.Contains(string.Concat(currentWater, " Amount"))))
{
dataColumn = new DataColumn(string.Concat(currentWater, " Amount"), typeof(double));
washDataTable.Columns.Add(dataColumn);
}
}
// Electrical Cost column
dataColumn = new DataColumn("Electrical Cost", typeof(double));
washDataTable.Columns.Add(dataColumn);
// Thermal Cost column
dataColumn = new DataColumn("Thermal Cost", typeof(double));
washDataTable.Columns.Add(dataColumn);
// Chemical Cost column
if (selectedChemical != null)
{
foreach (string currentChemical in selectedChemical.Where(currentChemical => !dataColumn.ColumnName.Contains(string.Concat(currentChemical, " Cost"))))
{
dataColumn = new DataColumn(string.Concat(currentChemical, " Cost"), typeof(double));
washDataTable.Columns.Add(dataColumn);
}
}
// Total Chemical Cost column
dataColumn = new DataColumn(ApplicationConstant.TotalChemicalCost, typeof(double));
washDataTable.Columns.Add(dataColumn);
// Water Cost column
if (selectedWater != null)
{
foreach (string currentWater in selectedWater.Where(currentWater => !dataColumn.ColumnName.Contains(string.Concat(currentWater, " Cost"))))
{
dataColumn = new DataColumn(string.Concat(currentWater, " Cost"), typeof(double));
washDataTable.Columns.Add(dataColumn);
}
}
// Total Water Cost column
dataColumn = new DataColumn(ApplicationConstant.TotalWaterCost, typeof(double));
washDataTable.Columns.Add(dataColumn);
return washDataTable;
}
/// <summary>
/// The get wash datato table.
/// </summary>
/// <param name="objWash">
/// The obj wash.
/// </param>
/// <param name="washDataTable">
/// The wash data table.
/// </param>
/// <returns>
/// The <see cref="DataTable"/>.
/// </returns>
private DataTable GetWashDatatoTable(IWashLibraryView objWash, DataTable washDataTable)
{
DataRow washDataRow = washDataTable.NewRow();
washDataRow["WashID"] = objWash.WashID;
washDataRow["WashStart"] = objWash.LocalStart;
washDataRow[ApplicationConstant.Duration] = objWash.WashDuration;
washDataRow["IsPerfectWash"] = objWash.IsPerfectWash;
if (objWash.CipLine != null)
{
washDataRow[ApplicationConstant.SessionNameCipLine] = objWash.CipLine;
if (objWash.CipSystem != null)
{
washDataRow[ApplicationConstant.SessionNameCipSystem] = objWash.CipSystem;
}
else
{
washDataRow[ApplicationConstant.SessionNameCipSystem] = string.Empty;
}
}
else
{
washDataRow[ApplicationConstant.SessionNameCipLine] = string.Empty;
}
washDataRow[ApplicationConstant.CipObject] = objWash.CipObject;
washDataRow[ApplicationConstant.Recipe] = objWash.Recipe;
washDataRow[ApplicationConstant.WashDescriptor] = GetWashDescriptor(objWash.WashDescriptors);
// Chemical Amount & Cost column
var selectedChemical = ViewState[ApplicationConstant.ViewStateChemicalConsumption] as List<string>;
if (selectedChemical != null)
{
double totalChemicalcost = 0;
foreach (string currentChemical in selectedChemical)
{
double amountChemicalConsup = 0;
double costChemicalConsup = 0;
//foreach (IPhase objPhase in objWash.Phases)
//{
string chemical = currentChemical;
List<double> amountChemical = (from m in objWash.ChemicalConsumption.ToList()
where m.MaterialName == chemical
select m.Amount.Value).ToList();
List<double> costChemical = (from m in objWash.ChemicalConsumption.ToList()
where m.MaterialName == chemical
select m.Cost.Value).ToList();
amountChemicalConsup += amountChemical.Sum();
costChemicalConsup += costChemical.Sum();
//}
totalChemicalcost += costChemicalConsup;
washDataRow[string.Concat(currentChemical , " Amount")] = Math.Round(amountChemicalConsup, 2);
washDataRow[string.Concat(currentChemical , " Cost")] = Math.Round(costChemicalConsup, 2);
}
washDataRow[ApplicationConstant.TotalChemicalCost] = Math.Round(totalChemicalcost, 2);
}
// Water Amount & Cost column
var selectedWater = ViewState[ApplicationConstant.ViewStateWaterConsumption] as List<string>;
if (selectedWater != null)
{
double totalWatercost = 0;
foreach (string currentWater in selectedWater)
{
double amountWaterConsup = 0;
double costWaterConsup = 0;
//foreach (IPhase objPhase in objWash.Phases)
//{
string water = currentWater;
List<double> amountWater = (from m in objWash.WaterConsumption.ToList()
where m.MaterialName == water
select m.Amount.Value).ToList();
List<double> costWater = (from m in objWash.WaterConsumption.ToList()
where m.MaterialName == water
select m.Cost.Value).ToList();
amountWaterConsup += amountWater.Sum();
costWaterConsup += costWater.Sum();
// }
totalWatercost += costWaterConsup;
washDataRow[string.Concat(currentWater, " Amount")] = Math.Round(amountWaterConsup, 2);
washDataRow[string.Concat(currentWater, " Cost")] = Math.Round(costWaterConsup, 2);
}
washDataRow[ApplicationConstant.TotalWaterCost] = Math.Round(totalWatercost, 2);
}
// Electrical Amount & Cost column
double amountElectricalConsup = 0;
double costElectricalConsup = 0;
//foreach (IPhase objPhase in objWash.Phases)
//{
if (objWash.ElectricalConsumption.Any())
{
List<double> amountElectrical = (from m in objWash.ElectricalConsumption.ToList()
select m.Amount.Value).ToList();
List<double> costElectrical = (from m in objWash.ElectricalConsumption.ToList()
select m.Cost.Value).ToList();
amountElectricalConsup += amountElectrical.Sum();
costElectricalConsup += costElectrical.Sum();
}
//}
washDataRow[ApplicationConstant.ElectricalAmount] = Math.Round(amountElectricalConsup, 2);
washDataRow["Electrical Cost"] = Math.Round(costElectricalConsup, 2);
// Thermal Amount & Cost column
double amountThermalConsup = 0;
double costThermalConsup = 0;
//foreach (IPhase objPhase in objWash.Phases)
//{
if (objWash.ThermalConsumption.Any())
{
List<double> amountThermal = (from m in objWash.ThermalConsumption.ToList()
select m.Amount.Value).ToList();
List<double> costThermal = (from m in objWash.ThermalConsumption.ToList()
select m.Cost.Value).ToList();
amountThermalConsup += amountThermal.Sum();
costThermalConsup += costThermal.Sum();
}
//}
washDataRow["Thermal Amount"] = Math.Round(amountThermalConsup, 2);
washDataRow["Thermal Cost"] = Math.Round(costThermalConsup, 2);
double totalCost = washDataRow["Electrical Cost"].ConvertToDouble() + washDataRow[ApplicationConstant.TotalWaterCost].ConvertToDouble() + washDataRow[ApplicationConstant.TotalChemicalCost].ConvertToDouble() + washDataRow["Thermal Cost"].ConvertToDouble();
washDataRow["Total Cost"] = totalCost;
washDataRow["HasNotification"] = objWash.NotificationsTriggered;
washDataRow["NotificationStatus"] = objWash.NotificationsTriggered ? "Yes" : "No";
washDataTable.Rows.Add(washDataRow);
return washDataTable;
}
/// <summary>
/// The generate rad grid column.
/// </summary>
/// <param name="washDataTable">
/// The wash data table.
/// </param>
/// <param name="gvwWashLibrary">
/// The gv wash library.
/// </param>
private void GenerateRadGridColumn(DataTable washDataTable,RadGrid gvwWashLibrary)
{
string currentCurrency = mGlobalProperties.GetPlantCurrency();
var gridTemplateColumn = new GridTemplateColumn
{
AllowFiltering = true,
HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES389")),
DataField = @"WashStart",
DataType = typeof (DateTime),
SortExpression = @"WashStart",
UniqueName = @"FilterWashStart"
};
gridTemplateColumn.AllowFiltering = true;
gridTemplateColumn.FilterControlWidth = Unit.Pixel(100);
gridTemplateColumn.HeaderStyle.Width = Unit.Pixel(160);
gridTemplateColumn.HeaderStyle.Font.Bold = true;
gridTemplateColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
var dynamicTemplate = new WLDynamicTemplate(lbtnWashDateTime_Click, 1);
var pl = new PlaceHolder();
dynamicTemplate.InstantiateIn(pl);
gridTemplateColumn.ItemTemplate = dynamicTemplate;
gvwWashLibrary.Columns.Add(gridTemplateColumn);
var gridColumn = new GridBoundColumn
{
Visible = false,
DataField = @"WashStart",
HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES389")),
DataFormatString =string.Concat("{0:" , mGlobalProperties.ConvertDateformat(ApplicationConstant.DateTimeOption.DateTime) , "}")
};
gvwWashLibrary.Columns.Add(gridColumn);
mFacadeCollection.GetMaterialFacade().LoadMaterial(mPlantObject);
var costHashtable = new Hashtable();
var amountHashtable = new Hashtable();
foreach (DataColumn dataColumn in washDataTable.Columns)
{
if (dataColumn.DataType == typeof(double))
{
var numericColumn = new GridNumericColumn();
if (dataColumn.ColumnName.Contains("Cost"))
{
numericColumn.HeaderText = string.Concat(dataColumn.ColumnName , " (" , currentCurrency , ")");
numericColumn.DataFormatString = string.Concat("{0:", mGlobalProperties.GetCostFormatOnly(), "}");
numericColumn.ItemStyle.CssClass = ApplicationConstant.CssAlignRight;
costHashtable.Add(dataColumn.ColumnName, dataColumn.ColumnName);
}
else if (dataColumn.ColumnName.Contains("Amount"))
{
string[] columnName = dataColumn.ColumnName.Split(new[] { "Amount" }, StringSplitOptions.None);
IMaterial material;
if (columnName[0].Trim() == ApplicationConstant.Electrical)
{
material = (from f in mPlantObject.Materials where f.Name.Trim() == "Electricity" select f).FirstOrDefault() ??
(from f in mPlantObject.Materials where f.MaterialType.MaterialCategory.Name == "MatrCat_Electrical" select f).FirstOrDefault();
}
else if (columnName[0].Trim() == ApplicationConstant.Thermal)
{
material = (from f in mPlantObject.Materials where f.MaterialType.MaterialCategory.Name == "MatrCat_Thermal" select f).FirstOrDefault();
}
else
{
material = (from f in mPlantObject.Materials where f.Name.Trim() == columnName[0].Trim() select f).FirstOrDefault();
}
if (material != null)
{
amountHashtable.Add(dataColumn.ColumnName, dataColumn.ColumnName);
numericColumn.HeaderText = string.Concat(dataColumn.ColumnName , " (" , material.UnitOfMeasure.UnitName , ")");
numericColumn.DataFormatString = string.Concat("{0:", mGlobalProperties.GetAmountFormatOnly(), "}");
numericColumn.ItemStyle.CssClass = ApplicationConstant.CssAlignRight;
}
else
{
amountHashtable.Add(dataColumn.ColumnName, dataColumn.ColumnName);
numericColumn.HeaderText = dataColumn.ColumnName;
numericColumn.DataFormatString = string.Concat("{0:", mGlobalProperties.GetAmountFormatOnly(), "}");
numericColumn.ItemStyle.CssClass = ApplicationConstant.CssAlignRight;
}
}
else
{
numericColumn.HeaderText = dataColumn.ColumnName;
numericColumn.DataFormatString = string.Concat("{0:", mGlobalProperties.GetCostFormatOnly(), "}");
numericColumn.ItemStyle.CssClass = ApplicationConstant.CssAlignRight;
}
numericColumn.HeaderText = SetHeaderText(numericColumn.HeaderText);
numericColumn.DataField = dataColumn.ColumnName;
numericColumn.SortExpression = dataColumn.ColumnName;
numericColumn.AllowFiltering = true;
numericColumn.FilterControlWidth = Unit.Pixel(60);
numericColumn.AllowSorting = true;
numericColumn.UniqueName = dataColumn.ColumnName;
numericColumn.HeaderStyle.Width = Unit.Pixel(160);
numericColumn.HeaderStyle.Font.Bold = true;
numericColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
gvwWashLibrary.Columns.Add(numericColumn);
if (dataColumn.ColumnName == ApplicationConstant.TotalCost)
{
GenerateColumns(gvwWashLibrary);
}
}
else
{
var numericColumn = new GridBoundColumn();
switch (dataColumn.ColumnName)
{
case ApplicationConstant.Duration:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES390"));
numericColumn.DataType = typeof(string);
numericColumn.DataFormatString = "{0:T}";
break;
case ApplicationConstant.SessionNameCipSystem:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES391"));
break;
case ApplicationConstant.SessionNameCipLine:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES392"));
break;
case ApplicationConstant.CipObject:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES393"));
break;
case ApplicationConstant.Recipe:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES394"));
break;
case ApplicationConstant.WashDescriptor:
numericColumn.HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES395"));
break;
default:
numericColumn.Visible = false;
break;
}
numericColumn.DataField = dataColumn.ColumnName;
numericColumn.SortExpression = dataColumn.ColumnName;
numericColumn.AllowFiltering = true;
numericColumn.FilterControlWidth = Unit.Pixel(100);
numericColumn.AllowSorting = true;
//numericColumn.UniqueName = dColumn.ColumnName;
numericColumn.HeaderStyle.Width = Unit.Pixel(160);
numericColumn.HeaderStyle.Font.Bold = true;
numericColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
gvwWashLibrary.Columns.Add(numericColumn);
}
}
Session[ApplicationConstant.SessionNameCostConversion] = costHashtable;
Session[ApplicationConstant.SessionNameAmountConversion] = amountHashtable;
}
/// <summary>
/// The get wash descriptor.
/// </summary>
/// <param name="descriptor">
/// The descriptor.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
private string GetWashDescriptor(object descriptor)
{
string objDescriptor = null;
if (descriptor != null)
{
var washDescList = descriptor as List<IWashDescriptorView>;
bool isFirst = true;
if (washDescList != null)
{
foreach (WashDescriptorView washDescriptor in washDescList)
{
if (isFirst)
{
isFirst = false;
}
else
{
objDescriptor += @",";
}
if (washDescriptor.FactDefinition != null)
{
objDescriptor += string.Format("{0}: {1}", washDescriptor.FactDefinition,
washDescriptor.Value);
}
}
}
}
return objDescriptor;
}
/// <summary>
/// The set materialfor wash.
/// </summary>
/// <param name="listWashes">
/// The list washes.
/// </param>
private void SetMaterialforWash(List<IWashLibraryView> listWashes)
{
List<string> objWaterPd = (from w in listWashes
from pd in w.WaterConsumption
select pd.MaterialName).Distinct().ToList();
ViewState[ApplicationConstant.ViewStateWaterConsumption] = objWaterPd;
List<string> objChemicalPd = (from w in listWashes
from pd in w.ChemicalConsumption
select pd.MaterialName).Distinct().ToList();
ViewState[ApplicationConstant.ViewStateChemicalConsumption] = objChemicalPd;
}
/// <summary>
/// Initialize the Page load attributes used in the page
/// </summary>
private void InitializePageLoad()
{
StrRefreshText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES387"));
StrDownLoadText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES388"));
try
{
if (Page.IsPostBack) return;
Session[ApplicationConstant.SessionNameMenuFlag] = ApplicationConstant.Reports;
mRoleAccessPrivilege = mGlobalProperties.GetSingleCRUDDetails(ApplicationConstant.AccessWashLibrary);
if (mRoleAccessPrivilege != null && !mRoleAccessPrivilege.ReadPermission)
{
Response.Redirect(ApplicationConstant.DefaultPageURL, false);
}
SetClientDateFormat();
Session[ApplicationConstant.SessionNameWashLibWashes] = null;
LoadFacility();
lblCustomer.Text = string.Concat(mPlantObject.Customer.Name, ApplicationConstant.CommaSpace,
mPlantObject.Name);
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// Sets the client date formats
/// </summary>
private void SetClientDateFormat()
{
try
{
mGlobalProperties.SetCalendarDateformat(dpfromdate);
mGlobalProperties.SetCalendarDateformat(dptodate);
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The generate radgrid.
/// </summary>
/// <param name="washDataTable">
/// The wash data table.
/// </param>
private void GenerateRadgrid(DataTable washDataTable)
{
var englishCulture = new CultureInfo("en-US");
washDataTable.Locale = englishCulture;
var washlibrarygrid = new RadGrid();
washlibrarygrid.MasterTableView.SortExpressions.AddSortExpression(new GridSortExpression() { FieldName = @"WashStart", SortOrder = GridSortOrder.Descending });
washlibrarygrid.ClientSettings.Scrolling.AllowScroll = true;
washlibrarygrid.ClientSettings.Scrolling.UseStaticHeaders = true;
washlibrarygrid.ClientSettings.Scrolling.SaveScrollPosition = true;
washlibrarygrid.ClientSettings.ClientEvents.OnFilterMenuShowing = "filterMenuShowing";
washlibrarygrid.FilterMenu.OnClientShown = "MenuShowing";
washlibrarygrid.ExportSettings.ExportOnlyData = false;
washlibrarygrid.MasterTableView.EditMode = GridEditMode.InPlace;
washlibrarygrid.AllowMultiRowEdit = true;
washlibrarygrid.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
washlibrarygrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
washlibrarygrid.MasterTableView.CommandItemSettings.RefreshText = string.Empty;
washlibrarygrid.MasterTableView.CommandItemSettings.ExportToExcelText = string.Empty;
washlibrarygrid.MasterTableView.CommandItemSettings.ExportToExcelImageUrl = @"../images/xls.png";
washlibrarygrid.MasterTableView.CommandItemSettings.RefreshImageUrl = @"../images/icon-refresh.png";
washlibrarygrid.MasterTableView.CommandItemSettings.ShowRefreshButton = true;
washlibrarygrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
washlibrarygrid.ExportSettings.HideStructureColumns = true;
washlibrarygrid.ExportSettings.IgnorePaging = true;
washlibrarygrid.ExportSettings.OpenInNewWindow = false;
washlibrarygrid.GroupingSettings.CaseSensitive = false;
washlibrarygrid.PagerStyle.AlwaysVisible = true;
washlibrarygrid.AllowPaging = true;
washlibrarygrid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
washlibrarygrid.MasterTableView.DataKeyNames = new[] { "WashID" };
washlibrarygrid.AutoGenerateColumns = false;
washlibrarygrid.AllowFilteringByColumn = true;
washlibrarygrid.AllowSorting = true;
washlibrarygrid.ItemDataBound += gvWashLibrary_ItemDataBound;
washlibrarygrid.ItemCommand += gvWashLibrary_ItemCommand;
washlibrarygrid.ItemCreated += gvWashLibrary_ItemCreated;
washlibrarygrid.ID = "gvWashLibrary";
washlibrarygrid.Controls.Clear();
// GenerateColumns(washlibrarygrid);
GenerateRadGridColumn(washDataTable,washlibrarygrid);
washlibrarygrid.DataSource = washDataTable;
//ViewState["FilteredColumnName"] = null;
//ViewState["FilteredColumnValue"] = null;
//ViewState["FilteredColumnType"] = null;
if (Session["FilteredColumnName"] != null)
{
GridColumn coulumn = washlibrarygrid.MasterTableView.GetColumnSafe(Session["FilteredColumnName"].ToString());
// coulumn.CurrentFilterFunction = ViewState["FilteredColumnType"].ToString();
coulumn.CurrentFilterValue = Session["FilteredColumnValue"].ToString();
}
phWashGrid.Controls.Clear();
phWashGrid.Controls.Add(washlibrarygrid);
}
/// <summary>
/// The gv wash library_ item created.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void gvWashLibrary_ItemCreated(object sender, GridItemEventArgs e)
{
var pagerItem = e.Item as GridPagerItem;
if (pagerItem != null)
{
var item = pagerItem;
item.PagerContentCell.Controls.Clear();
var myPagerPanel = new Panel { CssClass = "clear" };
myPagerPanel.Controls.Add(
new PagerTemplate(pagerItem.OwnerTableView.PagingManager));
item.PagerContentCell.Controls.Add(myPagerPanel);
}
}
/// <summary>
/// The generate columns.
/// </summary>
/// <param name="washlibrarygrid">
/// The washlibrarygrid.
/// </param>
private void GenerateColumns(RadGrid washlibrarygrid)
{
var gridTemplateColumn = new GridTemplateColumn { AllowFiltering = true };
gridTemplateColumn.AllowFiltering = false;
gridTemplateColumn.HeaderStyle.Width = Unit.Pixel(100);
gridTemplateColumn.HeaderStyle.Font.Bold = true;
gridTemplateColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
var dynamicTemplate = new DynamicTemplate(imgBtnViewNotifications_Click, 3);
var pl = new PlaceHolder();
dynamicTemplate.InstantiateIn(pl);
gridTemplateColumn.ItemTemplate = dynamicTemplate;
var dynamicTemplate1 = new DynamicTemplate(imgBtnViewNotificationList_Click, 4);
var pl1 = new PlaceHolder();
dynamicTemplate.InstantiateIn(pl1);
gridTemplateColumn.HeaderTemplate = dynamicTemplate1;
gridTemplateColumn.DataField = "NotificationStatus";
gridTemplateColumn.SortExpression = "NotificationStatus";
washlibrarygrid.Columns.Add(gridTemplateColumn);
var gridColumn = new GridBoundColumn
{
HeaderText = "Exceptions Triggered",
Visible = false,
DataField = "NotificationStatus"
};
washlibrarygrid.Columns.Add(gridColumn);
gridTemplateColumn = new GridTemplateColumn
{
AllowFiltering = true,
HeaderText = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES396")),
Visible = false
};
gridTemplateColumn.AllowFiltering = false;
gridTemplateColumn.HeaderStyle.Width = Unit.Pixel(100);
gridTemplateColumn.HeaderStyle.Font.Bold = true;
gridTemplateColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
washlibrarygrid.Columns.Add(gridTemplateColumn);
}
/// <summary>
/// The gvWashLibrary NeedDataSource Event
/// </summary>
/// <param name="sender">
/// The sender
/// </param>
/// <param name="e">
/// The e
/// </param>
protected void gvWashLibrary_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
try
{
var listWashes = Session[ApplicationConstant.SessionNameWashLibWashes] as DataTable;
var gvWashLibrary = phWashGrid.FindControl("gvWashLibrary") as RadGrid;
if (gvWashLibrary != null)
{
gvWashLibrary.DataSource = listWashes;
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The gv wash library_ item data bound.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void gvWashLibrary_ItemDataBound(object sender, GridItemEventArgs e)
{
try
{
if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
{
var costHashtable = Session[ApplicationConstant.SessionNameCostConversion] as Hashtable;
var amountHashtable = Session[ApplicationConstant.SessionNameAmountConversion] as Hashtable;
var gridDataItemRow = e.Item as GridDataItem;
var lkStartDate = e.Item.FindControl("lkStartDate") as LinkButton;
var imgPerfectWash = e.Item.FindControl("imgPerfectWash") as Image;
if (costHashtable != null)
{
foreach (DictionaryEntry item in costHashtable)
{
if (gridDataItemRow[Convert.ToString(item.Key)] != null &&
gridDataItemRow[Convert.ToString(item.Key)].Text != string.Empty)
{
gridDataItemRow[Convert.ToString(item.Key)].Text =
mGlobalProperties.GetCostFormat(gridDataItemRow[Convert.ToString(item.Key)].Text, ApplicationConstant.CurrencyFilter.CostWithSymbol);
}
}
}
if (amountHashtable != null)
{
foreach (DictionaryEntry item in amountHashtable)
{
if (gridDataItemRow[Convert.ToString(item.Key)] != null &&
gridDataItemRow[Convert.ToString(item.Key)].Text != string.Empty)
{
gridDataItemRow[Convert.ToString(item.Key)].Text =
mGlobalProperties.GetCostFormat(gridDataItemRow[Convert.ToString(item.Key)].Text,
ApplicationConstant.CurrencyFilter.CostOlny);
}
}
}
var imgBtnViewNotifications = e.Item.FindControl("imgBtnViewNotifications") as ImageButton;
if (lkStartDate != null)
{
mRoleAccessPrivilege = mGlobalProperties.GetSingleCRUDDetails(ApplicationConstant.AccessWashSummary);
if (mRoleAccessPrivilege != null)
{
if (!mRoleAccessPrivilege.ReadPermission)
{
lkStartDate.Enabled = false; lkStartDate.CssClass = ApplicationConstant.Opacity;
lkStartDate.ToolTip = Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR85"));
}
}
lkStartDate.Text = mGlobalProperties.ConvertDateformat(DataBinder.Eval(e.Item.DataItem, "WashStart"), ApplicationConstant.DateTimeOption.DateTime);
}
if (imgPerfectWash != null)
{
imgPerfectWash.Visible = (bool)(DataBinder.Eval(e.Item.DataItem, "IsPerfectWash"));
}
if (imgBtnViewNotifications != null)
{
imgBtnViewNotifications.Visible = (bool)(DataBinder.Eval(e.Item.DataItem, "HasNotification"));
}
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// The gv wash library_ item command.
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void gvWashLibrary_ItemCommand(object source, GridCommandEventArgs e)
{
try
{
//if (e.CommandName == RadGrid.PageCommandName)
//{
// var gvWashLibrary = phWashGrid.FindControl("gvWashLibrary") as RadGrid;
// gvWashLibrary.MasterTableView.cu
//}
if (e.CommandName == RadGrid.ExportToExcelCommandName)
{
var gvWashLibrary = phWashGrid.FindControl("gvWashLibrary") as RadGrid;
////if (gvWashLibrary != null)
////{
//// gvWashLibrary.MasterTableView.Columns[0].Visible = false;
//// gvWashLibrary.MasterTableView.Columns[1].Visible = true;
//// gvWashLibrary.MasterTableView.Columns[10].Visible = true;
//// gvWashLibrary.MasterTableView.Columns[11].Visible = false;
//// gvWashLibrary.MasterTableView.Columns[12].Visible = true;
//// gvWashLibrary.MasterTableView.ExportToCSV();
////}
ExportToCsv();
}
if (e.CommandName == RadGrid.FilterCommandName)
{
var filterPair = e.CommandArgument as Pair;
if (filterPair != null)
{
string columnName = Convert.ToString(filterPair.Second);
string filterType = Convert.ToString(filterPair.First);
Session["FilteredColumnName"] = columnName;
Session["FilteredColumnValue"] = ((TextBox)
((GridFilteringItem)e.Item)[Convert.ToString(filterPair.Second)].Controls[0]).Text;
Session["FilteredColumnType"] = filterType;
if (filterType == ApplicationConstant.NoFilter)
{
Session["FilteredColumnName"] = null;
Session["FilteredColumnValue"] = null;
Session["FilteredColumnType"] = null;
}
if (columnName == "FilterWashStart")
{
if (filterType != ApplicationConstant.NoFilter)
{
string filteredStr =
((TextBox)
((GridFilteringItem)e.Item)[Convert.ToString(filterPair.Second)].Controls[0]).Text;
e.Canceled = true;
var listWashes = Session[ApplicationConstant.SessionNameWashLibWashes] as DataTable;
var gvWashLibrary = phWashGrid.FindControl("gvWashLibrary") as RadGrid;
if (gvWashLibrary != null)
{
if (!string.IsNullOrEmpty(filteredStr))
{
DateTime date = new DateTime();
if (mPlantObject != null &&
!DateTime.TryParseExact(filteredStr,
mGlobalProperties.ConvertDateformat(ApplicationConstant.DateTimeOption.DateTime),
CultureInfo.InvariantCulture, DateTimeStyles.None,
out date))
{
if (
!DateTime.TryParseExact(filteredStr.Trim(),
mGlobalProperties.ConvertDateformat(ApplicationConstant.DateTimeOption.Date),
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out date))
{
gvWashLibrary.DataSource = string.Empty;
gvWashLibrary.Rebind();
e.Canceled = true;
}
else
{
gvWashLibrary.DataSource = FilteredDataTable(filterType, listWashes,
date);
gvWashLibrary.Rebind();
((TextBox)
((GridFilteringItem)e.Item)[Convert.ToString(filterPair.Second)]
.Controls[
0]).Text = filteredStr.Replace(" - ", " ");
}
}
else
{
gvWashLibrary.DataSource = FilteredDataTable(filterType, listWashes, date);
gvWashLibrary.Rebind();
}
}
}
}
}
}
}
}
catch (Exception ex)
{
mLogger.Error(ex, string.Concat(mCurrentPage, ex.ToString()));
ShowMessagetoUser(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.EcolabErrors, "CSERR300")));
}
}
/// <summary>
/// gets the filtered datatable
/// </summary>
/// <param name="filterType">
/// The filterType
/// </param>
/// <param name="washListDt">
/// The washListDT
/// </param>
/// <param name="filteredDate">
/// The filteredDate
/// </param>
/// <returns></returns>
private DataTable FilteredDataTable(string filterType, DataTable washListDt, DateTime filteredDate)
{
DataTable returnValue;
switch (filterType)
{
case "EqualTo":
var results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) == filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "NotEqualTo":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) != filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "GreaterThan":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) > filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "LessThan":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) < filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "GreaterThanOrEqualTo":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) >= filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "LessThanOrEqualTo":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) <= filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "Between":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) <= filteredDate && myRow.Field<DateTime>(ApplicationConstant.WashStart) <= filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "NotBetween":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) <= filteredDate || myRow.Field<DateTime>(ApplicationConstant.WashStart) <= filteredDate
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "IsNull":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) == null
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
case "NotIsNull":
results = (from myRow in washListDt.AsEnumerable()
where myRow.Field<DateTime>(ApplicationConstant.WashStart) != null
select myRow);
returnValue = results.Any() ? results.CopyToDataTable() : new DataTable();
break;
default:
returnValue = washListDt;
break;
}
return returnValue;
}
/// <summary>
/// Initialize the variables used in the page
/// </summary>
private void InitializeVariables()
{
mGlobalProperties = new GlobalProperties();
mUserObject = mGlobalProperties.GetOrSetIUser;
mLogger = UIException.GetLogger(mUserObject.UserName);
mCurrentPage = UIException.CurrentPageName;
mPlantObject = mGlobalProperties.GetOrSetIPlant;
mFacadeCollection = new FacadeCollection();
}
private string SetHeaderText(string headerText)
{
string returnValue;
if (headerText.ToLower().Contains("total consumption amount"))
{
returnValue = headerText.Replace("Total Consumption Amount", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES483")));
}
else if (headerText.ToLower().Contains("total cost"))
{
returnValue = headerText.Replace("Total Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES484")));
}
else if (headerText.ToLower().Contains("total water cost"))
{
returnValue = headerText.Replace("Total Water Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES485")));
}
else if (headerText.ToLower().Contains("total chemical cost"))
{
returnValue = headerText.Replace("Total Chemical Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES486")));
}
else if (headerText.ToLower().Contains("electrical cost"))
{
returnValue = headerText.Replace("Electrical Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES507")));
}
else if (headerText.ToLower().Contains("thermal cost"))
{
returnValue = headerText.Replace("Thermal Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES508")));
}
else if (headerText.ToLower().Contains("electrical amount"))
{
returnValue = headerText.Replace("Electrical Amount", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES540")));
}
else if (headerText.ToLower().Contains("thermal amount"))
{
returnValue = headerText.Replace("Thermal Amount", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES541")));
}
else if (headerText.ToLower().Contains("amount"))
{
returnValue = headerText.Replace("Amount", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES526")));
}
else if (headerText.ToLower().Contains("cost"))
{
returnValue = headerText.Replace("Cost", Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "SIMRES6")));
}
else
{
returnValue = headerText;
}
return returnValue;
}
/// <summary>
/// This method is to export the wash summary to csv file
/// </summary>
private void ExportToCsv()
{
try
{
var globalResourceObject = HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES355");
if (globalResourceObject != null)
{
string filename = string.Format("WashLibrary" + ".xls", mPlantObject.Customer.Name.Replace(" ", "_"));
if (filename.Length > ApplicationConstant.ExcelLimit)
{
filename = filename.Substring(0, ApplicationConstant.ExcelLimit);
}
HttpResponse response = Page.Response;
var excelTemplate = CreateWorkBook();
var worksheets = CreateWorkSheets();
var excelXml = string.Format(excelTemplate, worksheets);
response.Clear();
response.AppendHeader("Content-Type", "application/vnd.ms-excel");
response.AppendHeader("Content-disposition", "attachment; filename=" + filename);
response.Write(excelXml);
response.Flush();
response.End();
}
}
catch (Exception ex)
{
UIException.LogException(ex, ApplicationConstant.WashSummaryFile, "exportCSV");
}
}
/// <summary>
/// This method is to create the workbook xml schema
/// </summary>
/// <returns></returns>
private string CreateWorkBook()
{
var workbookformat = new StringBuilder(818);
workbookformat.AppendFormat(@"<?xml version=""1.0""?>{0}", Environment.NewLine);
workbookformat.AppendFormat(@"<?mso-application progid=""Excel.Sheet""?>{0}", Environment.NewLine);
workbookformat.AppendFormat(@"<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""{0}", Environment.NewLine);
workbookformat.AppendFormat(@" xmlns:o=""urn:schemas-microsoft-com:office:office""{0}", Environment.NewLine);
workbookformat.AppendFormat(@" xmlns:x=""urn:schemas-microsoft-com:office:excel""{0}", Environment.NewLine);
workbookformat.AppendFormat(@" xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""{0}", Environment.NewLine);
workbookformat.AppendFormat(@" xmlns:html=""{0'>http://www.w3.org/TR/REC-html40"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Styles>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Style ss:ID=""Default"" ss:Name=""Normal"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Alignment ss:Vertical=""Bottom""/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Borders/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000""/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Interior/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <NumberFormat/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Protection/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Style>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Style ss:ID=""s62"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""11"" ss:Color=""#000000""{0}", Environment.NewLine);
workbookformat.AppendFormat(@" ss:Bold=""1""/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Style>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Style ss:ID=""s63"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <NumberFormat ss:Format=""Short Date""/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Style>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Style ss:ID=""s64"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <NumberFormat />{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Style>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <Style ss:ID=""s65"">{0}", Environment.NewLine);
workbookformat.AppendFormat(@" <NumberFormat ss:Format=""Short Time""/>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Style>{0}", Environment.NewLine);
workbookformat.AppendFormat(@" </Styles>{0}", Environment.NewLine);
workbookformat.Append(@"{0}\r\n</Workbook>");
return workbookformat.ToString();
}
/// <summary>
/// The replace xml char.
/// </summary>
/// <param name="input">
/// The input.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
private static string ReplaceXmlChar(string input)
{
input = input.Replace("&", "&");
input = input.Replace("<", "<");
input = input.Replace(">", ">");
input = input.Replace("\"", """);
input = input.Replace("'", "'");
return input;
}
/// <summary>
/// This method is to create the worksheets
/// </summary>
/// <returns></returns>
private string CreateWorkSheets()
{
string returnValue;
var washList = (DataTable)Session[ApplicationConstant.SessionNameWashLibWashes];
using (var worksheets = new StringWriter())
{
var gvWashLibrary = phWashGrid.FindControl("gvWashLibrary") as RadGrid;
worksheets.Write(
string.Format(ApplicationConstant.WorkSheet,
ReplaceXmlChar("WashLibrary")) + ApplicationConstant.TableTag);
worksheets.Write(ApplicationConstant.NewColumn, "85");
worksheets.Write(ApplicationConstant.NewColumn, "85");
worksheets.Write(ApplicationConstant.NewColumn, "85");
worksheets.Write(ApplicationConstant.NewColumn, "85");
worksheets.Write(ApplicationConstant.NewColumn, "85");
worksheets.Write(ApplicationConstant.NewColumn, "85");
foreach (DataColumn column in washList.Columns)
{
worksheets.Write(ApplicationConstant.NewColumn, "85");
}
if (Session[ApplicationConstant.SessionNameWashLibWashes] != null)
{
worksheets.Write(ApplicationConstant.RowOpenTag);
foreach (DataColumn column in washList.Columns)
{
if (column.ColumnName != "WashID" && column.ColumnName != "WashNotesName" && column.ColumnName != "IsPerfectWash" && column.ColumnName != "HasNotification" && column.ColumnName != "WashNoteDateAndTime" && column.ColumnName != "WashNotes")
{
var columnHeader = gvWashLibrary.Columns.FindByUniqueNameSafe(column.ColumnName);
if (column.ColumnName == "NotificationStatus")
{
worksheets.Write(ApplicationConstant.HeaderCell,
ReplaceXmlChar(Convert.ToString(HttpContext.GetGlobalResourceObject(ApplicationConstant.CustomerSetUpResource, "CSRES322"))));
}
else
{
worksheets.Write(ApplicationConstant.HeaderCell,
ReplaceXmlChar(columnHeader.HeaderText));
}
}
}
worksheets.Write(ApplicationConstant.RowEndTag);;
foreach (DataRow dataRow in washList.Rows)
{
worksheets.Write(ApplicationConstant.RowOpenTag);
foreach (DataColumn column in washList.Columns)
{
if (column.ColumnName != "WashID" && column.ColumnName != "WashNotesName" && column.ColumnName != "IsPerfectWash" && column.ColumnName != "HasNotification" && column.ColumnName != "WashNoteDateAndTime" && column.ColumnName != "WashNotes")
{
if (column.ColumnName.Contains("Amount") || column.ColumnName.Contains("Cost"))
{
var dob = (double)dataRow[column.ColumnName];
worksheets.Write(ApplicationConstant.GeneralCell, dob.ToString(CultureInfo.InvariantCulture));
}
else
{
worksheets.Write(ApplicationConstant.DataCell,
ReplaceXmlChar(dataRow[column.ColumnName].ToString()));
}
}
}
worksheets.Write(ApplicationConstant.RowEndTag);
}
}
worksheets.Write(ApplicationConstant.TableEndTag + ApplicationConstant.WorkSheetEndTag);
returnValue = worksheets.ToString();
}
return returnValue;
}
/// <summary>
/// Show message to user
/// </summary>
private void ShowMessagetoUser(string errorMessage)
{
lblShowMessage.Text = errorMessage;
var page = HttpContext.Current.CurrentHandler as Page;
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("ShowMessage"))
{
ScriptManager.RegisterStartupScript(page, page.GetType(), "Show_Message", "showMessagetoUser();", true);
}
}
#endregion
}
}
#endregion
I am afraid the issue you are facing is still not replicable on our side. Bellow you can find my test page for your reference. Please let me know if you manage to reproduce what you are getting in this project and what steps to follow, so that we can test it too.
<%@ Page Language="C#" AutoEventWireup="true" %>
<
script
runat
=
"server"
>
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
GridSortExpression sortExpr = new GridSortExpression();
sortExpr.FieldName = "Column1";
sortExpr.SortOrder = GridSortOrder.Ascending;
RadGrid1.MasterTableView.SortExpressions.AddSortExpression(sortExpr);
}
}
protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataRow dr;
int colsNum = 10;
int rowsNum = 30;
string colName = "Column";
for (int j = 1; j <= colsNum; j++)
{
dt.Columns.Add(String.Format("{0}{1}", colName, j));
}
for (int i = 1; i <= rowsNum; i++)
{
dr = dt.NewRow();
for (int k = 1; k <= colsNum; k++)
{
dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
}
dt.Rows.Add(dr);
}
(sender as RadGrid).DataSource = dt;
}
</
script
>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
</
style
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function expandGrid()
{
var radGrid = $find("<%= RadGrid1.ClientID %>");
radGrid.get_element().style.height = "500px";
radGrid.repaint();
}
</
script
>
</
telerik:RadCodeBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
class
=
"wrapper"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
></
telerik:RadScriptManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnNeedDataSource
=
"RadGrid_NeedDataSource"
Height
=
"300px"
Width
=
"900px"
AllowSorting
=
"True"
PageSize
=
"20"
AllowPaging
=
"True"
>
<
HeaderStyle
Width
=
"200px"
/>
<
MasterTableView
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
SaveScrollPosition
=
"true"
UseStaticHeaders
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
br
/>
<
br
/>
<
telerik:RadButton
runat
=
"server"
AutoPostBack
=
"false"
OnClientClicked
=
"expandGrid"
Text
=
"Expand Grid"
></
telerik:RadButton
>
</
div
>
</
form
>
</
body
>
</
html
>
Regards,
Galin
Telerik
Did you try in chrome browser?
We are creating all the columns dynamically? Nothing in HTML part.
Can you please provide me update on this query?
I tried the scenario in Chrome Version 30.0.1599.101, but the issue still does not occur. Could you try to modify the sent project so we can replicate the problem in our side?
In the meantime check out the fallowing scenarios which can cause the misalignment:
- Javasript error
- ItemStyle-Width
It is highly unrecommended to use ItemStyle-Width and only HeaderStyle-Width should be used for setting columns width.
- Custom styles - this can break the alignment only in IE 6/7, but there the CSS padding of the header cells and data cells should be equal. нико
Regards,
Galin
Telerik
You can reproduce the issue if you have more columns in the grid, We have more than 25 columns in the grid in that most of the columns creating dynamically in the grid.
We have already tried with more columns but there is something else that causes this behavior. Please try to replicate the issue and send it to use by opening a formal support ticket so we can test and debug it locally. In the meantime you can refer to this forum thread and see if it helps: Best Practice for Grid and Column widths.
Regards,
Venelin
Telerik
I could not upload solution as zip file in this thread, please let me know how to upload the solution.
Right now I provide the code snippet.
Apart from this issue , I have another issue in the same page.
The issue detail in the below thread
.http://www.telerik.com/community/forums/reply-thread.aspx?messageId=0&threadId=746464
In order to send your project you have to open a regular support ticket.
Regards,
Venelin
Telerik