Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a Gym application and i have a offer for buy if you buy 3 month the amount will be 200 $ (example) what i looking for is how to remind the user before the 3 months end i have a column in my table with the start date i want to remind him 10 days before the end date
and i have a note that the offer my be changing like it will be 1 month , 5 month whatever ,,,,

What I have tried:

C#
DateTime nextMonth = date.AddDays(1).AddMonths(1).AddDays(-1);


bout it didn't help me
i want to change the AddMonths(1) with a textbox have the number for me it is the (offer).
Posted
Updated 11-Mar-19 23:21pm
v3
Comments
CHill60 12-Mar-19 2:34am    
Replace the one with the value of the text box (or other control). What's the problem?
el_tot93 12-Mar-19 2:35am    
how it will be like plz

Take the date of last renewal and add the number of months to the next renewal (1, 3, 5 etc.). Subtract 10 from the days. Compare that to today's date to see whether the reminder should be sent.
 
Share this answer
 
Comments
el_tot93 12-Mar-19 5:23am    
yes that i looking for but how can i do that i'm new in this idea i didn't do something like that before
Richard MacCutchan 12-Mar-19 5:36am    
Go to DateTime Struct (System) | Microsoft Docs[^] where you will find examples.
Instead of a TextBox you should really use a numericUpDown control[^] (I'm assuming WinForms here but there are equivalents in ASP.NET and WPF)

But for now .. (untested)
C#
int i;
DateTime nextMonth;
if(int.TryParse(txtBox.Text, out i) 
{
    nextMonth = date.AddDays(1).AddMonths(i).AddDays(-1);
}
 
Share this answer
 
v2
Comments
el_tot93 12-Mar-19 5:15am    
i get me error in if(int.TryParse(txtBox.Text, i) red line under I
CHill60 12-Mar-19 7:54am    
I did say it was untested. It would have been quicker for you to look up the documentation Int32.TryParse Method (System) | Microsoft Docs[^]
I've updated my solution correcting the typing error, but if you are going to downvote solutions without giving posters a chance to respond you're not going to win many friends
Are you really asking for c# - Get integer from Textbox - Stack Overflow[^] ?
 
Share this answer
 
Comments
el_tot93 12-Mar-19 4:44am    
i want to replace the one with the value of the textbox
CPallini 12-Mar-19 7:02am    
The linked page shows you how to get the integer value, then you have only to plug such a value into the addMonths call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900