using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Vrg.Web {
public class Common {
public static void FillItemTypesDdl( DropDownList ddlItemType ) {
Dictionary<string, string> dct = Vrg.Web.AppState.GetItemTypeIdsToNames();
if( dct != null ) {
foreach( KeyValuePair<string, string> kvp in dct ) {
ddlItemType.Items.Add( new ListItem( kvp.Value, kvp.Key ) );
}
}
}
public static SqlDataSource GetItemTypeDataSource() {
SqlDataSource sds =
new SqlDataSource(Vrg.DB.DataBase._CONNSTR, "SELECT ITEM_TYPE_CD, NAME FROM ITEM_TYPE WHERE item_type_cd in('c','d','i','l','p','sa','q')");
sds.EnableCaching = true;
return sds;
}
public static bool GetSortDir( StateBag viewstate ) {//returns true id sorting descending
if( viewstate[QsKey.order_desc] != null && viewstate[QsKey.order_desc].Equals( "0" ) ) {
viewstate[QsKey.order_desc] = "1";
}
else {
viewstate[QsKey.order_desc] = "0";
}
return viewstate[QsKey.order_desc] == "1";
}
public static void AddStyleSheet( Page page, string sHref ) {
HtmlLink htmlLink = new HtmlLink(); htmlLink.Href = sHref;
htmlLink.Attributes.Add( "rel", "stylesheet" );
htmlLink.Attributes.Add( "type", "text/css" );
page.Header.Controls.Add( htmlLink );
}
public static void AddMetaDescription( Page page, string sDescription ) {
HtmlMeta htmlMeta = new HtmlMeta();
htmlMeta.Name = "description";
htmlMeta.Content = sDescription;
page.Header.Controls.Add( htmlMeta );
}
}
}