Solved

Horocsope Application

Posted on 2003-12-06
13
615 Views
Last Modified: 2007-12-19
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 !!!
0
Comment
Question by:DahaR
  • 8
  • 5
13 Comments
 
LVL 7

Expert Comment

by:TransBind
ID: 9891104
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
 
LVL 1

Author Comment

by:DahaR
ID: 9900416
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
 
LVL 1

Author Comment

by:DahaR
ID: 9901200
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 7

Expert Comment

by:TransBind
ID: 9901550
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
 
LVL 1

Author Comment

by:DahaR
ID: 9908541
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
 
LVL 7

Expert Comment

by:TransBind
ID: 9909983
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
 
LVL 1

Author Comment

by:DahaR
ID: 9915204
hey .......points are increased on yur humble request
0
 
LVL 7

Expert Comment

by:TransBind
ID: 9917844
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
 
LVL 7

Expert Comment

by:TransBind
ID: 9917932
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
 
LVL 7

Expert Comment

by:TransBind
ID: 9917935
we need to do that and text as a Control otherwise it will shade the date that is displayed
0
 
LVL 7

Accepted Solution

by:
TransBind earned 225 total points
ID: 9917942
I meant to say add as a control, i think i need coffee ...
0
 
LVL 1

Author Comment

by:DahaR
ID: 9922247
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
 
LVL 7

Expert Comment

by:TransBind
ID: 9922679
Thank you as well.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question