public static ReklamCollection GetSelect(int width, int height) { ReklamCollection rvReklam = new ReklamCollection(); using (MConnection conneciton = new MConnection(MClientProvider.MSSQL)) { switch (conneciton.State) { case System.Data.ConnectionState.Closed: conneciton.Open(); break; } using (MCommand cmd = new MCommand(CommandType.Text, "SELECT TOP(10) * FROM Reklam WHERE Width=@Width AND Height=@Height AND IsActive=1", conneciton)) { cmd.Parameters.Add("Width", width, MSqlDbType.Int); cmd.Parameters.Add("Height", height, MSqlDbType.Int); using (IDataReader IDR = cmd.ExecuteReader()) { while (IDR.Read()) { rvReklam.Add(new Reklam(MConvert.NullToInt(IDR["ID"]), MConvert.NullToString(IDR["BannerName"]), MConvert.NullToString(IDR["ImageUrl"]), MConvert.NullToString(IDR["NavigateUrl"]), MConvert.NullToString(IDR["AlternateText"]), MConvert.NullToString(IDR["Keyword"]), MConvert.NullToInt(IDR["Impressions"]), MConvert.NullToInt(IDR["Width"]), MConvert.NullToInt(IDR["Height"]), MConvert.NullToBool(IDR["IsActive"]))); } IDR.Close(); } } switch (conneciton.State) { case System.Data.ConnectionState.Open: conneciton.Close(); break; } } return(rvReklam); }
/// <summary> /// Reklam Liste Getir /// </summary> public static ReklamCollection GetList(CommandType cmdType, string sqlQuery, MParameterCollection parameters) { ReklamCollection rvReklam = new ReklamCollection(); using (MConnection conneciton = new MConnection(MClientProvider.MSSQL)) { switch (conneciton.State) { case System.Data.ConnectionState.Closed: conneciton.Open(); break; } using (MCommand cmd = new MCommand(cmdType, sqlQuery, conneciton)) { if (parameters != null) { foreach (MParameter item in parameters) { cmd.Parameters.Add(item); } } using (IDataReader IDR = cmd.ExecuteReader()) { while (IDR.Read()) { rvReklam.Add(new Reklam(MConvert.NullToInt(IDR["ID"]), MConvert.NullToString(IDR["BannerName"]), MConvert.NullToString(IDR["ImageUrl"]), MConvert.NullToString(IDR["NavigateUrl"]), MConvert.NullToString(IDR["AlternateText"]), MConvert.NullToString(IDR["Keyword"]), MConvert.NullToInt(IDR["Impressions"]), MConvert.NullToInt(IDR["Width"]), MConvert.NullToInt(IDR["Height"]), MConvert.NullToBool(IDR["IsActive"]))); } IDR.Close(); } } switch (conneciton.State) { case System.Data.ConnectionState.Open: conneciton.Close(); break; } } return(rvReklam); }