Data Access Layer//Getter and setter methodpublic string Url{ get { return _url; } set { _url = value; }}public string TargetAudience{ get { return _targetAudience; } set { _targetAudience = value; }}public string Image{ get { return _image; } set { _image = value; }}public string OnMouseOverText{ get { return _onMouseOverText; } set { _onMouseOverText = value; }}public int AdvertisementID{ get { return _advertisementID; } set { _advertisementID = value; }}public int Location{ get { return _location; } set { _location = value; }}//Constructor public AdvertisementDAL(){} public AdvertisementDAL(int advertisementID, int location,string image, string targetAudience,string url, string onMouseOverText){ _advertisementID = advertisementID; _location = location; _image = image; _targetAudience = targetAudience; _url = url; _onMouseOverText = onMouseOverText;} public int updateNoOfClick(DateTime now, int ID) { string sql = "Select NoOfClick From AdvertisementRecord " + "Where RecordDate = @recordDate AND FK_AdvertisementID = @aID"; SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@recordDate", now); cmd.Parameters.AddWithValue("@aID", ID); conn.Open(); int noOfClick = int.Parse(cmd.ExecuteScalar().ToString()); noOfClick++; conn.Close(); string sql1 = "Update AdvertisementRecord SET NoOfClick = @Click " + "WHERE RecordDate = @Date AND FK_ADvertisementID = @aID"; //SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd1 = new SqlCommand(sql1, conn); cmd1.Parameters.AddWithValue("@Click", noOfClick); cmd1.Parameters.AddWithValue("@aID", ID); cmd1.Parameters.AddWithValue("@Date", now); conn.Open(); int row = 0; row = cmd1.ExecuteNonQuery(); conn.Close(); return row; } public AdvertisementDAL selectAdvertisementLocation1(DateTime now, string gender) { AdvertisementDAL dal = null; string sql = "Select * From Advertisement Where @currentDate between StartDate AND EndDate AND TargetAudience = @gender AND Location = 1"; SqlConnection conn = new SqlConnection(_connStr); SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@currentDate", now); cmd.Parameters.AddWithValue("@gender", gender); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { _advertisementID = int.Parse(dr["AdvertisementID"].ToString()); _location = int.Parse(dr["Location"].ToString()); _image = dr["Image"].ToString(); _targetAudience = dr["TargetAudience"].ToString(); _url = dr["Url"].ToString(); _onMouseOverText = dr["OnMouseOverText"].ToString(); dal = new AdvertisementDAL(_advertisementID, _location, _image, _targetAudience, _url, _onMouseOverText); } conn.Close(); dr.Close(); dr.Dispose(); return dal; }This is my business Logic Layerpublic AdvertisementDAL selectAdLocation1(DateTime now, string gender) { AdvertisementDAL dal = new AdvertisementDAL(); return dal.selectAdvertisementLocation1(now, gender); } public void InsertOrUpdateupdateNoOfClick(DateTime now, int aID) { AdvertisementDAL dal = new AdvertisementDAL(); int existDate = dal.checkRecordDateIsExist(now, aID); if (existDate == 0) { dal.insertAdvertisementRecord(now, aID); } else if (existDate > 0) { dal.updateNoOfClick(now, aID); } }
Presentation Layer.
<telerik:RadRotator ID="RadRotator1" runat="server">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server"
Height="224px" Width="102px" />
</ItemTemplate>
</telerik:RadRotator>
I have a radrotator with a image button control. I wanted the rad rotator look similar like this
http://demos.telerik.com/aspnet-ajax/rotator/examples/bannerrotation/defaultcs.aspx
They will load a lot of advertisement images.
when a user click on the specific advertisement,
they will update the specific advertisement the no of click.
The problem is how do I do it in aspx.cs? at page_load