using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;
using System.Configuration;
using System.Text;
using System.Drawing;
namespace VXUK2
{
public partial class booking_system : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// SQL Query For DropDownList1 (CIT Company)
SqlConnection con = new SqlConnection();
con.ConnectionString = ("Data Source=(LocalDB)////MSSQLLocalDB;AttachDbFilename=C:////****;Persist Security Info=True;User ID=***;Password=****;Connect Timeout=30");
con.Open();
SqlCommand cmd = new SqlCommand("Select CIT_ID, CIT_CompanyName from CIT_Details", con);
ddlCITCompany.DataSource = cmd.ExecuteReader();
ddlCITCompany.DataTextField ="CIT_CompanyName";
ddlCITCompany.DataValueField ="CIT_ID";
ddlCITCompany.DataBind();
// SQL Query for DropDownList2 (Site Details)
SqlConnection con2 = new SqlConnection();
con2.ConnectionString = ("Data Source=(LocalDB)////MSSQLLocalDB;AttachDbFilename=C:////***;Persist Security Info=True;User ID=***;Password=****;Connect Timeout=30");
con2.Open();
SqlCommand cmd2 = new SqlCommand("Select Site_ID, Site_Name from Site_Details", con2);
ddlVisitingCentre.DataSource = cmd2.ExecuteReader();
ddlVisitingCentre.DataTextField ="Site_Name";
ddlVisitingCentre.DataValueField ="Site_ID";
ddlVisitingCentre.DataBind();
}
protected void Submit2_Click(object sender, EventArgs e)
{
//LocalDB Connection & Execution String
SqlConnection con = new SqlConnection();
con.ConnectionString = ("Data Source=(LocalDB)////MSSQLLocalDB;AttachDbFilename=C:////***;Persist Security Info=True;User ID=***;Password=****;Connect Timeout=30");
con.Open();
String st ="INSERT INTO Booking_Data (Visiting_Centre, Expected_Arrival_Date, Expected_Arrival_Time, Actual_Arrival_Date, Actual_Arrival_Time, CIT_Company, Driver_Name, Vehicle_Registration, Supplied_Password, Delivery_In, Delivery_Out, Time_Booked_In, Time_Booked_Out) values (@Visiting_Centre, @Expected_Arrival_Date, @Expected_Arrival_Time, @Actual_Arrival_Date, @Actual_Arrival_Time, @CIT_Company, @Driver_Name, @Vehicle_Registration, @Supplied_Password, @Delivery_In, @Delivery_Out, @Time_Booked_In, @Time_Booked_Out)";
SqlCommand cmd = new SqlCommand(st, con);
cmd.Parameters.AddWithValue("@Visiting_Centre", ddlVisitingCentre.SelectedValue);
cmd.Parameters.AddWithValue("@Expected_Arrival_Date", txtExpectedArrivalDate.Text);
cmd.Parameters.AddWithValue("@Expected_Arrival_Time", txtExpectedArrivalTime.Text);
cmd.Parameters.AddWithValue("@Actual_Arrival_Date", txtActualArrivalDate.Text);
cmd.Parameters.AddWithValue("@Actual_Arrival_Time", txtActualArrivalTime.Text);
cmd.Parameters.AddWithValue("@CIT_Company", ddlCITCompany.SelectedValue);
cmd.Parameters.AddWithValue("@Driver_Name", txtDriverName.Text);
cmd.Parameters.AddWithValue("@Vehicle_Registration", txtVehicleRegistration.Text);
cmd.Parameters.AddWithValue("@Supplied_Password", txtSuppliedPassword.Text);
cmd.Parameters.AddWithValue("@Delivery_In", txtDeliveryIn.Text);
cmd.Parameters.AddWithValue("@Delivery_Out", txtDeliveryOut.Text);
cmd.Parameters.AddWithValue("@Time_Booked_In", txtTimeBookedIn.Text);
cmd.Parameters.AddWithValue("@Time_Booked_Out", txtTimeBookedOut.Text);
cmd.ExecuteNonQuery();
con.Close();