public bool SaveData(AddClientAppLayer user) { try { using (SqlConnection con = new SqlConnection(ConnectSql.GetConnectionString())) { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO AddHospital (HospitalName,Location,Type,AmbulanceNo) Values (@HospitalName,@Location,@Type,@AmbulanceNo)", con); cmd.Parameters.AddWithValue("@HospitalName", user.HospitalName); cmd.Parameters.AddWithValue("@Location", user.Location); cmd.Parameters.AddWithValue("@Type", user.Type); cmd.Parameters.AddWithValue("@AmbulanceNo", user.AmbulanceNo); cmd.ExecuteNonQuery(); con.Close(); } return(true); } catch (Exception ex) { Log(ex.Message); return(false); } }
public bool UserVerifyUserDetails(AddClientAppLayer user) { if (user.AmbulanceNo.Length > 4) { AddClientDomainLayer domain = new AddClientDomainLayer(); bool response = domain.SavetoDatabase(user); return(response); } else { return(false); } }
private void btnAddHospital_Click(object sender, EventArgs e) { AddClientAppLayer user = new AddClientAppLayer { HospitalName = txtHospitalName.Text, Location = txtLocation.Text, Type = txtType.Text, AmbulanceNo = txtAmbulanceNo.Text, }; bool Response = user.ImplementBusinessLogics(user); if (Response) { MessageBox.Show("Data saved sucessfully"); } else { MessageBox.Show("Failed to save data"); } }
public bool SavetoDatabase(AddClientAppLayer user) { AddClientDataLayer data2 = new AddClientDataLayer(); return(data2.SaveData(user)); }