private void Btn_Enter_Click(object sender, EventArgs e) //checks if textbox id null/blank { if (string.IsNullOrEmpty(tb_TM.Text) || string.IsNullOrWhiteSpace(tb_TM.Text)) { MessageBox.Show("Please ensure all information is provided"); } else { db.closeConnection(); // close db connection for new method SqlCommand cmd = db.createService(); // this function will add to the DB cmd.Parameters.Add("@Vehicle_Make", cb_VehicleMake.Text); cmd.Parameters.Add("@Vehicle_Model", tb_Model.Text); cmd.Parameters.Add("@Number_Plate", cb_NP.Text); cmd.Parameters.Add("@Total_Milage", tb_TM.Text); cmd.Parameters.Add("@Date", DTP.Value.Date); cmd.Parameters.Add("@Vehicle_ID", Vehicle_ID); cmd.ExecuteNonQuery(); // initiate the save to db // clear textboxs tb_Model.ResetText(); tb_TM.ResetText(); DTP.ResetText(); db.closeConnection(); db.ChangeV_Incident(Vehicle_ID.ToString()); } }
private void AddTimeBTN_Click(object sender, EventArgs e) { string Date = DTP.Value.ToString("dd/MM/yyyy"); string Time = textBox1.Text; DateTime DT = DateTime.ParseExact((Date + " " + Time), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); if (!checkdoubletimes((Int32)NumHall.Value, DT, Duration)) { AD.CreateDateTime(DT, Title, (Int32)NumHall.Value); DTP.ResetText(); textBox1.Clear(); NumHall.ResetText(); } else { DTP.ResetText(); textBox1.Clear(); NumHall.ResetText(); MessageBox.Show("The given hall is already in use at the given time. Please try again", "Invalid date", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// insure there is no blank inputs when submit button in entered private void Btn_Enter_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cb_SelectV.Text) || string.IsNullOrWhiteSpace(cb_SelectV.Text) || string.IsNullOrEmpty(DTP.Text) || string.IsNullOrWhiteSpace(DTP.Text)) { MessageBox.Show("Please ensure all information is provided"); } else { db.closeConnection(); // input into db for incident SqlCommand cmd = db.createIncService(); cmd.Parameters.Add("@Vehicle_Make", tb_Make.Text); cmd.Parameters.Add("@Vehicle_Model", tb_Model.Text); cmd.Parameters.Add("@Number_Plate", tb_NP.Text); cmd.Parameters.Add("@Problem", RTB_Problem.Text); cmd.Parameters.Add("@Date", DTP.Value.Date); cmd.Parameters.Add("@Vehicle_ID", Vehicle_ID); cmd.ExecuteNonQuery(); // reset textbox tb_Make.ResetText(); tb_Model.ResetText(); tb_NP.ResetText(); RTB_Problem.ResetText(); DTP.ResetText(); db.closeConnection(); db.ChangeV_Incident(ServiceID); db.closeConnection(); db.ChangeIncStatus(Vehicle_ID.ToString()); } }