閲覧総計:4786 (本日:1 昨日:0)
カレンダ コントロールの祝日・会社休日をピンクで表示する方法を確認した。
DBに祝日・会社休日情報を用意し、カレンダ表示に反映させる。
土日は、カレンダ コントロールのプロパティ設定:WeekendDayStyleのBackColorを
LightPinkに設定する事で対応する。 10/08/10
【稼働画面】
※会社休日夏休み:8/9(月)〜8/13(金)
※9/23秋分の日は会社出勤日
開発環境:VWD2008 + Access2003 + SQL Server2008
サーバ:ASP.NET3.5 + Access2003
【HolidayRender_ads.aspx】
<%@ Page Language="VB" %> <%@ Import Namespace = "System.Data" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub cal_dayrender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) ads.SelectParameters.Clear() ads.SelectParameters.Add("CalDate", e.Day.Date.ToString("yyyy/MM/dd")) Dim reader As IDataReader = ads.Select(DataSourceSelectArguments.Empty) ' 日付セル(e.Call)毎に繰り返し Do While reader.Read() '祝日・会社休日をLightPinkに e.Cell.BackColor = Drawing.Color.LightPink Loop End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> カレンダの祝日・会社休日ピンク表示 10/08/10<br /> <br /> <asp:AccessDataSource ID="ads" runat="server" DataFile="~/App_Data/AccessDB.mdb" DataSourceMode="DataReader" SelectCommand="SELECT [ID], [Holiday] FROM [CompanyHolidays] WHERE [Holiday] = @CalDate"> </asp:AccessDataSource> <asp:Calendar id="cal" runat="server" DayHeaderStyle-BackColor="#FFCC66" onDayRender="cal_DayRender" ShowGridLines="true" BorderWidth="3" BorderColor="Black" Font-Name="Verdana" Font-Size="10px" TitleStyle-BackColor="#FFCC66" TitleStyle-Font-Size="12px" TitleStyle-Font-Bold="true" DayStyle-VerticalAlign="Top" DayStyle-Height="50px" DayStyle-Width="14%" SelectedDayStyle-BackColor="Navy" ShowNextPrev="True" NextPrevFormat="FullMonth" Width="504px"> <SelectedDayStyle BackColor="#CC5533" /> <WeekendDayStyle BackColor="LightPink" /> <DayStyle VerticalAlign="Top" Height="50px" Width="14%"></DayStyle> <DayHeaderStyle BackColor="#FFCC66"></DayHeaderStyle> <TitleStyle BackColor="#FFCC66" Font-Bold="True" Font-Size="12px"></TitleStyle> </asp:Calendar> <br /> </div> </form> </body> </html>
【参考にしたページ】
なし
【HolidayRender_direct.aspx】
<%@ Page Language="VB" %> <%@ Import Namespace="System.Data.Common" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> 'MS-AccessDBのConnectionString Dim MyDbConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AccessDB.mdb;Persist Security Info=True" 'MS-AccessDBのProviderName Dim MyDbProviderName As String = "System.Data.OleDb" ' カレンダのそれぞれの日付セルをレンダリングするタイミングで実行 Sub cal_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Dim setting As ConnectionStringSettings = _ ConfigurationManager.ConnectionStrings(MyDbConnectionString) Dim factory As DbProviderFactory = _ DbProviderFactories.GetFactory(MyDbProviderName) Using db As DbConnection = factory.CreateConnection() db.ConnectionString = MyDbConnectionString ' 出力する日付セルに対応するスケジュール情報を抽出 Dim comm As DbCommand = factory.CreateCommand() comm.CommandText = "SELECT [ID],[Holiday] FROM [CompanyHolidays] WHERE [Holiday]=@CalDate" comm.Connection = db Dim param As DbParameter = factory.CreateParameter() param.ParameterName = "@CalDate" param.Value = e.Day.Date.ToString("yyyy/MM/dd") comm.Parameters.Add(param) db.Open() Dim reader As DbDataReader = comm.ExecuteReader() ' 日付セル(e.Call)毎に繰り返し Do While reader.Read() '祝日・会社休日をLightPinkに e.Cell.BackColor = Drawing.Color.LightPink Loop End Using End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> カレンダの祝日・会社休日をピンク表示(DB直接アクセス法) 10/08/10<br /> <br /> <asp:Calendar id="cal" runat="server" DayHeaderStyle-BackColor="#FFCC66" onDayRender="cal_DayRender" ShowGridLines="true" BorderWidth="3" BorderColor="Black" Font-Name="Verdana" Font-Size="10px" TitleStyle-BackColor="#FFCC66" TitleStyle-Font-Size="12px" TitleStyle-Font-Bold="true" DayStyle-VerticalAlign="Top" DayStyle-Height="50px" DayStyle-Width="14%" SelectedDayStyle-BackColor="Navy" ShowNextPrev="True" NextPrevFormat="FullMonth" Width="504px"> <SelectedDayStyle BackColor="#CC5533" /> <WeekendDayStyle BackColor="LightPink" /> <DayStyle VerticalAlign="Top" Height="50px" Width="14%"></DayStyle> <DayHeaderStyle BackColor="#FFCC66"></DayHeaderStyle> <TitleStyle BackColor="#FFCC66" Font-Bold="True" Font-Size="12px"></TitleStyle> </asp:Calendar> <br /> </div> </form> </body> </html>
【参考にしたページ】
なし
http://www.tiffany-jewelry.net/ will http://www.nike-air-max.com.de/ rely http://www.adidas-superstar.nl/ on http://www.tommy-hilfiger.com.de/ the http://www.basketballshoes.com.co/ holding http://www.pradahandbags.net.co/ to http://www.hermes-outlet.com.co/ go, http://www.thenorth-faces.co.uk/ if http://www.newbalance-outlet.org/ there http://www.louisvuitton-outlet.com.co/ is http://www.ugg-australia.com.de/ any http://www.newbalance-shoes.org/ sign http://www.cheap-raybans.com/ of trouble, but also http://www.burberry-handbagsoutlet.com.co/ possession http://www.cheaprayban.com.co/ of http://www.adidas.org.es/ arms http://www.coachblackfriday.com/ aunt. http://www.hollisterclothingstore.org/ Her http://www.barbour-jacketsoutlet.com/ body http://www.timberlandshoes.net.co/ will http://www.pulseras-pandora.com.es/ always http://www.tommyhilfiger.net.co/ be a http://www.nike-schuhe.com.de/ good http://www.cheapjerseys.com.co/ smell, http://www.guccioutlet-sale.in.net/ grassy http://www.ralphlaurenepolo.com/ taste http://www.p90xworkout.us.com/ of http://www.eyeglassesonline.us.com/ green http://www.the-north-face.ca/ time, http://www.uggs-onsale.net/ even http://www.airjordans.us/ more http://www.mcmsworldwide.com/ than his http://www.uggboots.com.de/ grandmother sandalwood incense http://www.salvatoreferragamo.in.net/ out many http://www.tiffany-andco.com.au/ times. http://www.soft-ballbats.com/ (Read the http://www.replica-handbags.in.net/ article http://www.nike-shoes-canada.ca/ Network: www.sanwen.net)So, I http://www.handbagsoutlet.net.co/ like http://www.christianlouboutinoutlet.net.co/ aunt, http://www.nfl-jersey.us.com/ preferring to http://www.michael-kors-outlet.us.org/ let http://www.nikeskos.dk/ her http://www.chanel-bags.com.co/ hold. http://www.abercrombie-fitchsale.com/ Aunt http://supra.shoesoutlet.us.com/ grandmother http://www.thenorthfacejackets.net.co/ is http://www.cheapjerseys.us.org/ to http://www.yoga-pants.ca/ allow http://www.bottegaveneta-bagsoutlet.com/ a http://www.michael-kors-outlet-online.us.org/ lot http://www.the-northfacejackets.us.com/ of care http://www.mk-outlet.us.com/ of http://www.pandora-charms.org.uk/ me and http://www.burberry2016.co.uk/ coax me http://www.nike-shoesoutlet.us.com/ play.Most http://www.ray-ban-outlet.us.com/ of http://www.asics-outlet.us.com/ the http://www.ralphlaurenoutletonline.in.net/ time http://www.nikefree-run.net/ we http://www.nike-air-max.ca/ were http://www.polooutlets-store.com/ running http://www.supra-shoes.org/ out Feng Wan, http://www.tommy-hilfiger-online-shop.de/ climb http://www.airmax-90.org/ the http://www.oakley-sunglasses.mex.com/ hill http://www.vans-schuhe.com.de/ pick berries, http://www.rosherun.org.uk/ go http://www.longchamp.us.org/ to http://www.hollister-abercrombie.com.se/ the http://www.swarovski-online-shop.de/ stream http://www.the-northface.net.co/ edge http://www.abercrombie-hollister.nl/ scoop tadpoles and grass http://www.longchamp-handbags.us.com/ carp. http://coach.euro-us.net/ I especially http://www.ralphlaurenoutlet.us.com/ like http://www.michael-kors-handbags.us.com/ to http://www.asicsgels.de/ play, http://www.toms-outlets.us.com/ but http://www.outlet-burberry.net.co/ also are http://www.mcmhandbags.com.co/ a http://www.tomsshoes-outlet.us.com/ go http://www.toms--outlet.com.co/ pestering http://www.ugg-boots.us.org/ aunt, http://www.tommy-hilfigeroutlet.com/ in http://www.mcm-bags.in.net/ childhood, http://www.rolex-watch.me.uk/ she used http://www.hollister-clothing.in.net/ to http://www.michaeljordan.com.de/ be http://www.truereligion-outlet.com.co/ my http://www.michael-kors.com.co/ best http://www.michael-kors-taschen.com.de/ friend, http://www.ugg-boots.ca/ even http://www.adidasshoes.top/ though http://www.nike-air-max.us/ she http://www.thejoreseproject.com/ was http://www.louisvuitton.so/ more http://www.jordanrelease-dates.us.com/ than http://www.ferragamo.com.co/ I http://www.oakley-sunglasses-canada.ca/ was http://www.longchamphandbagsoutlet.net/ up http://www.beats-by-dre.com.co/ a http://www.coach-purseoutlet.net/ big http://www.pandorajewelry.top/ slice. http://www.swarovski-australia.com.au/ She http://www.coach-factory.in.net/ often http://www.levisjeans.com.co/ cajole, http://www.cheapoakley-sunglasses.com/ and http://nike.shoesoutlet.us.com/ looked at http://www.hollisters-canada.ca/ me http://www.bcbg-max-azria.ca/ to http://www.ralph-laurenoutlet.ca/ sleep, http://www.rayban-sunglassesoutlet.co.uk/ I http://www.coachoutletstore-online.com.co/ do http://www.coco-chanel.com.de/ not http://www.nikestore.com.de/ want http://www.ugg-uggboots.net/ a http://www.canada-goosesjackets.us.com/ person to sleep, http://www.burberry-outletonlinesale.in.net/ especially http://www.cheap-baseballbats.net/ in http://www.pandora.com.de/ the http://www.uggsoutlet.com.co/ cabin http://www.jimmy-choos.com/ my http://www.raybans.us.org/ own http://airhuarache.shoesoutlet.us.com/ house, http://www.moncler-outlet.us.org/ I http://www.ferragamoshoes.in.net/ will http://www.nike-roshe-run.de/ pull http://www.burberryonlineshop.de/ aunt http://www.oakley-sunglassoutlet.net/ sleeves, http://www.tommy-hilfiger.co.nl/ let http://www.rolexwatchesforsale.us.com/ her http://www.nike-skor.com.se/ tell http://www.chiflatiron.net.co/ me stories http://www.airhuarache.co.uk/ before http://www.abercrombie-fitchs.us.com/ they http://www.hollister.us.org/ agree http://www.tomsoutletonline.net/ to http://www.abercrombie-kids.us.com/ sleep. http://www.pumaonline-shop.de/ Sometimes http://www.adidas-schuhe-online.de/ aunt http://www.hermesbags.jp.net/ tired, http://www.rayban.org.es/ rest will be http://www.weddingdressesuk.org.uk/ lying next http://www.michael-kors-australia.com.au/ to http://www.burberrysoutlet2016.com/ me, http://www.tommy-hilfiger-canada.ca/ but http://www.hollisteronlineshop.com.de/ my http://www.nikestore.us/ time is the http://www.christian--louboutin.in.net/ most mischievous of http://www.converse-shoes.net/ the opportunity, I http://www.polo-ralph-lauren.de/ would http://www.celine-bags.org/ deliberately http://www.ralphslauren-outlet.co.uk/ squeezed http://www.kate-spade.gb.net/ her, http://airmax.shoesoutlet.us.com/ or get http://www.michaelkorsoutletonline-sale.us.com/ up http://www.lululemon-australia.com.au/ reading http://www.tnf-jackets.us.com/ her http://www.louboutin.jp.net/ lashes http://monsterbeats.co-om.com/ beating, but http://www.longchamp-handbagsoutlet.us.com/ also http://northfaceoutlet.co-om.com/ scratching http://www.bottega-veneta.us.com/ her http://www.thenorthface.com.de/ itch, http://www.converse.net.co/ she http://www.michaelkors.co.nl/ will http://www.nike-schoenen.co.nl/ pretend http://www.abercrombieand-fitch.ca/ angry, http://www.swarovskijewelry.com.co/ but http://www.new-balance-schuhe.de/ also http://www.oakleys-sunglasses.us.com/ drum http://www.jimmy-chooshoes.com/ up http://www.swarovski-crystal.us.com/ toot http://www.insanity-workout.us.com/ mouth http://www.barbour-factory.com/ scare http://www.prada-shoes.com.co/ me. http://www.the-northface.com.co/ -- [[ZYF]] &new{2016-03-23 (水) 11:39:45};