Horocsope Application

how can i use 2 calenders in asp.net application to determine the star of a user ( determining the star by the range of dates selected by the user from the 2 calenders )........then how can i show him his star prediction on any current date he selects ( prediction , based on his star )................please can sum1 help me out !!!!!!!!!!!  THANKS !!!
LVL 1
DahaRAsked:
Who is Participating?
 
TransBindConnect With a Mentor Commented:
I meant to say add as a control, i think i need coffee ...
0
 
TransBindCommented:
I think you only need one calendar to determine the sign of the person. The individual will select his birth date and server side code will determine what sign he/she was born under.  Second calendar will be used only for star predictions on any current date selected. Is this what you want to accomplish in your code? If yes please give me more detailed answer. Some C# code that might help you to accomplish your task:

//this will assign the current selected date on a calendar to SelectedDate
string SelectedDate;
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
   SelectedDate = Calendar1.SelectedDate.ToShortDateString();
}


//this will assign only month and date only to lblOne <-- (label id)
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
            {
                  if((Calendar1.SelectedDate.ToShortDateString()).Length == 10)
                  {
                        lblOne.Text = (Calendar1.SelectedDate.ToShortDateString()).Substring(0,6);
                  }
                  else if((Calendar1.SelectedDate.ToShortDateString()).Length == 9)
                  {
                        lblOne.Text = (Calendar1.SelectedDate.ToShortDateString()).Substring(0,5);
                  }
                  else if ((Calendar1.SelectedDate.ToShortDateString()).Length == 8)
                  {
                        lblOne.Text = (Calendar1.SelectedDate.ToShortDateString()).Substring(0,4);
                  }

                  calOneYear = Calendar1.SelectedDate.Year.ToString();
            }


//this will return the current year selected from a calendar
string calTwoYear;
calTwoYear = Calendar2.SelectedDate.Year.ToString();

//this will just compare strings
if ((String.Compare("3/21/","3/21/")==0) && (String.Compare("4/19/","4/19/")== 0))
                  {
                        if((String.Compare("1979","1979")==0))
                        {
                              lblOutput.Text = "You are Aries";
                        }
                  }
0
 
DahaRAuthor Commented:
yeh hi ....sorry for the delay ...had sum problems..........THANKS for the sample code , ............yeh !!!  u right , i also want the star predictions on any selected date ( yeh we can use a 2nd calender )........can u also plz explain me a little the function    

  private void Calendar1_SelectionChanged(object sender, System.EventArgs e)


i am confused with the "Length" thing and the "SubString"  thing.................and how r we comparing strings at the end of the code............In simple can u just explain me a bit of what is going on .......i'll be grateful...........THANKS !!! already ...........
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
DahaRAuthor Commented:
hi again ..... another thing i wanted 2 ask is that......what to do after we have some value in the strings............how will i compare ???

suppose if i select  23rd of Dec from 1st calender and  22th of Jan from the 2nd calender ( two calenders will be used here ....for the range ).......so if i select a value , lets say 26th dec on a calender...........can we do sumthing like checking if the selected date lies between a related star ( sagittarius...in this case )............plz see both of my previous posting.......!!!!!

THANKS !!!!!!!!!!!
0
 
TransBindCommented:
I would like to clear something out. I am not really sure about what kind of functionality you want to implement. What is the need for the Range and two calendars? Personally I think you can only use one calendar for everything.
Picture this

------------------        ----------------------------          -------------------------
|                    |       | My Zodiac Sign button |        |                              |
|                    |       -----------------------------        |    Display Field        |  
|   Calendar    |        -----------------------------        |                             |
|                    |       |   Horoscope for today   |        ------------------------
|                    |        -----------------------------
------------------

I will explain to you what functionality i would personally implement and you tell me what you think of it. On a calendar user will select his date of birth and then click
"My Zodiac Sign button" his zodiac sign will be displayed in Display Field we can also display brief description/characterstics and range such as March 03 - April 19 for Aries. I assume that user is Aries. Then a user can click on "Horoscope for today" button which will tell user his Horoscope for today. "Horoscope for today" will work like this if user after application loads will click on it, it will display a message stating "please choose your date of birth" we need to determine what horoscope sign user is before displaying his horoscope for today.

Displaying horoscope for today is not really a good idea though. Because there 360 or so days in a year and 12 zodiac signs every zodiac sign has a different description for every day if u want to store those description in a database thats (360*12=4320) entries. I would suggest displaying Horoscope description for a month. I think on such web sites such as www.horoscope.com where u can read your horoscope description for today they simply update a description for every zodiac sign everyday. 12 signs 12 descriptions just update it everyday. A question is it a web aplication or windows based aplication?

You asked me to explain to you Length and Substring methods. Small examples:
Length counts characters in a string and returns the total number of characters.

string Aries = "zodiac";
Aries.Length will return 6 there are 6 letters/characters in "zodiac" word

Substring method works like this
(Aries).Substring(0,3);  will return "zodi"
first parameter of Substing method indicates start and second where to end
I used it in my code to chop a string because year is irrelevant to us.
When we select a date on a calendar it returns this 3/12/2003
we need only a month and a date from this 3/12/   to determine what sign user is March 12th a user is Aries. We can determine what zodiac sign a user is in a variety of ways for example:

When a user will pick a date on a calendar we can first find out what month a user chose. If month is equal to March then a user can be either Aries or Fish. Aries starts on March 21st. I would this
if(month == 3)  <--- meaning march then we will do this
{
  if(dateOfMonth =>21)
  { Aries }
  else
  { Fish }
}

12 if statements since there are 12 months in a year. The important thing is to resolve the unclearness why do u need 2 calendars? if u can use one just like i descrived above and what do u think of my way approaching this problem?
0
 
DahaRAuthor Commented:
hi !!!!........i have done it !!!!!!!!!!!!! yeh !!!!!! ..........yur latest code confirmed the logic i had made in my mind .THANKS !!!!! ........u were right , it can work by using a single calender only ..!!!     i have used this logic....tell me if u agree or not ....

// for PISCES

if((Calendar1.SelectedDate.Month == 2 ) && (Calendar1.SelectedDate.Day >=20))      
                {
                      lblOutput.Text = "PISCES";
                 }
else if ((Calendar1.SelectedDate.Month == 3 ) && (Calendar1.SelectedDate.Day <= 21))
      {
            lblOutput.Text = "PISCES";
      }


is it ok or not !!!!....................

yeh it is a web application...........now only 1 thing is left....i hope u will help me in this too.....its related..............now i wanna display the STAR ( string ).......under the DATE in the calender.....like this ..........                  
                                                                           24
                                                                         STAR

i hope u get , what i mean......i am also workin on it.........!!!!!   BIG THANKS !!!!!!!!!!
0
 
TransBindCommented:
Your logic is correct. Why don't you want to place a star into a label instead of placing it inside a cell? In any event I can help you with your current question regarding placing a string in the cell however I think I already answered your question and helped you enough for the number of points and now you are going into programming/syntax details therefore please increase points and I will gladly help you with it. :)
0
 
DahaRAuthor Commented:
hey .......points are increased on yur humble request
0
 
TransBindCommented:
Thank you very much. If you want to write a string under the Calendar date this is what you have to do:

step 1) edit your project html code where you have asp tag for your calendar it will look like this
<asp:calendar id="Calendar1"
at the end of this tag add this code
OnDayRender="CalendarDRender"  so it looks like this

<asp:calendar id="Calendar1" runat="server" OnDayRender="CalendarDRender"></asp:calendar>

OnDayRender="CalendarDRender"  <--- this means we will call function CalendarDRender when we Render a calendar

step2)
edit your c# code and add this string
string sign;   //it should be added outside of any function this way we make a global string accessible by all functions

after that add this function to your code

protected void CalendarDRender(object  sender, System.Web.UI.WebControls.DayRenderEventArgs  e)
{
  if (e.Day.IsSelected)
  {
      e.Cell.BackColor = System.Drawing.Color.Khaki;
      e.Cell.Text = "<br>" + sign;
      e.Cell.Width = 12;  //adjust this to your needs
      e.Cell.Height = 12;  //adjust this to your needs
  }
}

preatty much this function does this it sets or renders a selected cell in our case it will set the background color and width height and pass some text to a cell

the important part is (sign)
we will assign string to a sign in your logic where you determine what sign user is

so for example after you select some kind of date on a calendar and click button
(My Zodiac Sign) a method will be called inside that method you will have something like that

// for PISCES

if((Calendar1.SelectedDate.Month == 2 ) && (Calendar1.SelectedDate.Day >=20))    
                {
                     lblOutput.Text = "PISCES";
                     sign = "PISCES";


                 }
else if ((Calendar1.SelectedDate.Month == 3 ) && (Calendar1.SelectedDate.Day <= 21))
     {
          lblOutput.Text = "PISCES";
          sign = "PISCES";
     }

a string will be assigned to 'sign string' in your logic.


0
 
TransBindCommented:
I just noticed a small mistake in my code
replace this code
if (e.Day.IsSelected)
  {
      e.Cell.BackColor = System.Drawing.Color.Khaki;
      e.Cell.Text = "<br>" + sign;
      e.Cell.Width = 12;  //adjust this to your needs
      e.Cell.Height = 12;  //adjust this to your needs
  }

with this code

if (e.Day.IsSelected)
{
  e.Cell.BackColor = System.Drawing.Color.Khaki;
  labelSign.Text = "<br>" + sign;
  e.Cell.Controls.Add(labelSign);
  e.Cell.Width = 12;
  e.Cell.Height = 12;
}  

and outside of the function next 'sign string' declare this label
Label labelSign = new Label();
this label should be global declared outside of the function
0
 
TransBindCommented:
we need to do that and text as a Control otherwise it will shade the date that is displayed
0
 
DahaRAuthor Commented:
thanks for that !!!!!!!!!!!!!  u were a real help........!!!!!!!!!! .....my application is now fully operational now................ i wud have gone bizerk if hadnt been u at the right time...................hopw we will continue the same communication i future also...............
THANKS ONCE AGAIN !!!!!!!!!!!!!!!!

shehryar.....................
0
 
TransBindCommented:
Thank you as well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.