protected void cmdAdd_Click(object sender, EventArgs e) { clsVehicle DB = new clsVehicle(); try { if (txtmake.Text == null) { lblResults.Text = "Please enter the make of the vehicle (eg. Toyota,Nissan)"; return; } if (txttype.Text == null) { lblResults.Text = "Please select the type of vehicle"; return; } if (txtchassesno.Text == null) { lblResults.Text = "Please enter the chassis number of the vehicle"; return; } if (txtregno.Text == null) { lblResults.Text = "Please enter the registration number of the vehicle"; return; } if (txtWheelSize.Text == null) { lblResults.Text = "Please enter the wheel size of the vehicle"; return; } if (txtRimSize.Text == null) { lblResults.Text = "Please enter the rim size of the vehicle"; return; } if (txtweightofvehicle.Text == null) { lblResults.Text = "Please enter the weight of the vehicle"; return; } if (dtRWdateofIssue.GetType() != typeof(DateTime)) { lblResults.Text = "Please enter a valid issue date of the road worthy cetificate"; return; } if (txtRWplaceofissue.Text == null) { lblResults.Text = "Please enter a valid issue place of the road worthy cetificate"; return; } if (cboRWvalidity.Text == null) { lblResults.Text = "Please enter a valid validity of the road worthy cetificate(eg.YES,NO)"; return; } if (dtINdateofissue.GetType() != typeof(DateTime)) { lblResults.Text = "Please enter a valid issue date of the insurance cetificate"; return; } if (txtINplaceofissue.Text == null) { lblResults.Text = "Please enter a valid issue place of the insurance cetificate"; return; } if (cboINvalidity.Text == null) { lblResults.Text = "Please enter a valid validity of the insurance cetificate(eg.YES,NO)"; return; } if (DTRegDate.GetType() != typeof(DateTime)) { lblResults.Text = "Please enter a valid registration date of the vehicle"; return; } if (DTpurchDate.GetType() != typeof(DateTime)) { lblResults.Text = "Please enter a valid purchase date of the vehicle"; return; } if (txtDepartment.Text == null) { lblResults.Text = "Please select a valid department"; return; } if (txtEngineCapacity.Text == null) { lblResults.Text = "Please select a valid Engine Capacity"; return; } if (dtfirstservicedate.GetType() != typeof(DateTime)) { lblResults.Text = "Please enter the first service date of the vehicle"; return; } dtnextservicedate.Text = DateTime.Now.AddYears(1).ToString(); if (cbolocation.Text == null) { lblResults.Text = "Please select a valid Engine Capacity"; return; } int reccount = 0; reccount = DB.FindRecKount(txtchassesno.Text); if (reccount > 0) { lblResults.Text = "Record already exists!!!"; return; } DB.Add_rec(txtmake.Text, txttype.Text, txtchassesno.Text, txtregno.Text, txtWheelSize.Text, txtRimSize.Text, txtweightofvehicle.Text, DateTime.Parse(dtRWdateofIssue.Text), txtRWplaceofissue.Text, cboRWvalidity.Text, DateTime.Parse(dtINdateofissue.Text), txtINplaceofissue.Text, cboINvalidity.Text, DateTime.Parse(DTRegDate.Text), DateTime.Parse(DTpurchDate.Text), txtDepartment.Text, txtEngineCapacity.Text, DateTime.Parse(dtfirstservicedate.Text), DateTime.Parse(dtnextservicedate.Text), cbolocation.Text, txtPicturePath.ToString()); //string selectSQL = "SELECT * FROM tb_Customer ORDER BY convert(int,customerno)"; //SqlConnection con = new SqlConnection(connectionString); //SqlCommand cmd = new SqlCommand(selectSQL, con); //SqlDataAdapter adapter = new SqlDataAdapter(cmd); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; txtmake.Text = ""; txttype.Text = ""; txtchassesno.Text = ""; txtregno.Text = ""; txtWheelSize.Text = ""; txtRimSize.Text = ""; txtweightofvehicle.Text = ""; txtRWplaceofissue.Text = ""; cboRWvalidity.Text = ""; txtINplaceofissue.Text = ""; cboINvalidity.Text = ""; txtDepartment.Text = ""; txtEngineCapacity.Text = ""; cbolocation.Text = ""; txtPicturePath = null; return; } catch (Exception err) { EventLog log = new EventLog(); log.Source = "Milorry Frontend"; log.WriteEntry(err.Message, EventLogEntryType.Error); return; } finally { //con.Close(); } }