Count No of hores

Sep 2 2017 3:19 AM
Hello sir i want to calculate no oh houres like per day 4 houre and implement on calculattor like i will entre total no of houre is 44  and  i will chose date 01/01/2017 then calculate end date is 11/01/2014 on calender how can do that plz help me....
 
protected void txt_startDate_TextChanged(object sender, EventArgs e)
{
String dateInString = txtnohr.Text;
DateTime r, r1;
string s = "", s1 = "";
DateTime startDate = DateTime.Parse(txt_startDate.Text);
int totalnoofhr, oneday = 4;
totalnoofhr = Convert.ToInt32(dateInString);
int count = 0;
for (int j = 0; j <= totalnoofhr; j++)
{
if (totalnoofhr != 0)
{
if (count == j)
{
s = startDate.AddDays(j).ToShortDateString();
totalnoofhr = totalnoofhr - oneday;
count = count + 1;
}
}
}
s1 = s;
lbl_show.Text = s1;
r1 = Convert.ToDateTime(s1);
s1 = r1.AddDays(1).ToShortDateString();
String myString = s1; // get value from text field
r = Convert.ToDateTime(myString);
String myString_new = r.ToString("yyyy-MM-dd"); // add myString_new to oracle
lbl_show.Text = myString_new;
}
 

Attachment: Calculate.rar

Answers (18)