I am creating a online car booking system, where a user is able to rent a car by per hour or all day. Below is the form i have created using formview:
[IMG]http://i697.photobucket.com/albums/vv333/POLO_GTI_6N2/booking.jpg[/IMG]
And here is the C# code i have created so far to transfer the data to the database. What i want to do is:
1) For AllDay checkbox when checked then PerHour checkbox cannot be checked, and vise versa. Also the depending on what checkbox has been checked then "All Day" or "Per Hour" is saved under the "Rent_type" column in database.
2) If checkbox for All Day is checked then the textbox for entering hours into Per Hour is disabled. If checkbox for Per Hour is checked then the textbox for entering number of days is disabled.
3) If i put in a calender called "Calendar1" for the "Date" field how can i make the selected date on the calendar appear in the "Date" textbox.
Coding in C#:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class User_Booking1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void InsertButton_Click(object sender, EventArgs e)
{
DropDownList _CarID = FormView1.FindControl("CarDropDown") as DropDownList;
TextBox _Firstname = FormView1.FindControl("FirstnameTextBox") as TextBox;
TextBox _Surname = FormView1.FindControl("SurnameTextBox") as TextBox;
TextBox _Contact_number = FormView1.FindControl("Contact_numberTextBox") as TextBox;
TextBox _Rent_type = FormView1.FindControl("Rent_typeTextBox") as TextBox;
TextBox _Date = FormView1.FindControl("DateTextBox") as TextBox;
TextBox _Total_hours = FormView1.FindControl("Total_hoursTextBox") as TextBox;
TextBox _Total_days = FormView1.FindControl("Total_daysTextBox") as TextBox;
TextBox _Time = FormView1.FindControl("TimeTextBox") as TextBox;
SqlDataSource1.InsertParameters["CarID"].DefaultValue = _CarID.SelectedValue;
SqlDataSource1.InsertParameters["Firstname"].DefaultValue = _Firstname.Text;
SqlDataSource1.InsertParameters["Surname"].DefaultValue = _Surname.Text;
SqlDataSource1.InsertParameters["Contact_number"].DefaultValue = _Contact_number.Text;
SqlDataSource1.InsertParameters["Rent_type"].DefaultValue = _Rent_type.Text;
SqlDataSource1.InsertParameters["Date"].DefaultValue = _Date.Text;
SqlDataSource1.InsertParameters["Total_hours"].DefaultValue = _Total_hours.Text;
SqlDataSource1.InsertParameters["Total_days"].DefaultValue = _Total_days.Text;
SqlDataSource1.InsertParameters["Time"].DefaultValue = _Time.Text;
SqlDataSource1.Insert();
Response.Redirect("Booking2.aspx");
}
protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
{
}
protected void AllDayCheckBox_CheckedChanged(object sender, EventArgs e)
{
}
protected void PerHourCheckBox_CheckedChanged(object sender, EventArgs e)
{
}
}