public ActionResult AddUpdateCountry(int id = 0) { clsCountry country = new clsCountry(); if (id > 0) { country = (from c in db.tblCountries where c.CountryId == id select new clsCountry { CountryId = c.CountryId, CountryName = c.CountryName }).FirstOrDefault(); } else { country = new clsCountry { CountryId = 0, CountryName = "" }; } return(PartialView(country)); }
public ActionResult DeleteCountry(int id) { string message = ""; bool status = false; clsCountry st = new clsCountry(); st.CountryId = id; string returnId = InsertUpdateCountryDb(st, "Delete"); if (returnId == "Success") { ModelState.Clear(); status = true; message = "User Type Successfully Deleted"; } else { ModelState.Clear(); status = false; message = returnId; } return(new JsonResult { Data = new { status = status, message = message } }); }
private string InsertUpdateCountryDb(clsCountry st, string insertUpdateStatus) { string returnId = "0"; string connection = System.Configuration.ConfigurationManager.ConnectionStrings["ADO"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { try { con.Open(); using (SqlCommand cmd = new SqlCommand("spInsertUpdateCountry", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@CountryId", SqlDbType.Int).Value = st.CountryId; cmd.Parameters.Add("@CountryName", SqlDbType.NVarChar).Value = st.CountryName; cmd.Parameters.Add("@InsertUpdateStatus", SqlDbType.NVarChar).Value = insertUpdateStatus; cmd.Parameters.Add("@CheckReturn", SqlDbType.NVarChar, 300).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); returnId = cmd.Parameters["@CheckReturn"].Value.ToString(); cmd.Dispose(); } con.Close(); con.Dispose(); } catch (Exception ex) { returnId = ex.Message.ToString(); } } return(returnId); }
public List <clsCountry> GetCountry() { clsCountry countryClass = new clsCountry(); List <clsCountry> countryNameList = new List <clsCountry>(); countryNameList = countryClass.getCountries(); return(countryNameList); }
public ActionResult AddUpdateCountry(clsCountry country) { string message = ""; bool status = false; try { string returnId = "0"; string insertUpdateStatus = ""; if (country.CountryId > 0) { insertUpdateStatus = "Update"; } else { insertUpdateStatus = "Save"; } returnId = InsertUpdateCountryDb(country, insertUpdateStatus); if (returnId == "Success") { status = true; message = "User Type Successfully Updated"; } else { status = false; message = returnId; } } catch (Exception ex) { status = false; message = ex.Message.ToString(); } return(new JsonResult { Data = new { status = status, message = message } }); }
private void lblLoadMatchDate_Click(object sender, EventArgs e) { //Create match and the databse string path = ""; saveFileDialog1.FileName = txtMatchName.Text + ".sdf"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { path = saveFileDialog1.FileName; } else { return; } if (!rbTeam1FirstBatting.Checked && !rbTeam2FirstBatting.Checked) { clsMessages.showMessage(clsMessages.msgType.exclamation, "Please select the first batting team to continue."); return; } //show infor txtInfo.Text = "Save path: " + path + "\n\n"; //Import data //Get the two team names. string team1Name = "", team2Name = ""; OleDbCommand comAc = new OleDbCommand("SELECT Teams.CountryID, Countries.Name, Teams.ID FROM Countries INNER JOIN Teams ON Countries.ID = Teams.CountryID", conACCESS); OleDbDataAdapter adACC = new OleDbDataAdapter(comAc); DataSet dsAC = new DataSet("countries"); adACC.Fill(dsAC, "countries"); team1Name = dsAC.Tables["countries"].Rows[0][1].ToString(); team2Name = dsAC.Tables["countries"].Rows[1][1].ToString(); int team1RefID = Convert.ToInt32(dsAC.Tables["countries"].Rows[0][2].ToString()); int team2RefID = Convert.ToInt32(dsAC.Tables["countries"].Rows[1][2].ToString()); //Indormation for creating a match int matchId = clsMatch.getNextMatchId(); string matchName = txtMatchName.Text; DateTime matchDate = dateTimePicker1.Value; clsMatchTypes matchType = new clsMatchTypes(clsMatchTypes.getMatchTypeID(cmbMatchType.SelectedItem.ToString()), cmbMatchType.SelectedItem.ToString()); comAc = new OleDbCommand("SELECT Countries.Name FROM Countries INNER JOIN Venues ON Countries.ID = Venues.CountryID", conACCESS); string countryNamePlayed = ""; try { countryNamePlayed = comAc.ExecuteScalar().ToString(); } catch (Exception ex) { clsMessages.showMessage(clsMessages.msgType.error, ex.Message); } clsCountry countryPlayed = new clsCountry(clsCountry.getCountryCode(countryNamePlayed), countryNamePlayed); comAc = new OleDbCommand("SELECT [Name] FROM Venues", conACCESS); string venueName = comAc.ExecuteScalar().ToString(); //Check if venue is in database if (clsGround.getGroundCode(venueName) <= 0) { int venueCode = clsGround.getNextGroundCode(); int endId = clsEnds.getNextEndID(); clsGround.addGround(new clsGround(venueCode, venueName, 30000, countryPlayed.countryId, new clsEnds(endId, "Scoreboard End", venueCode), new clsEnds(endId + 1, "Pavillion End", venueCode))); } clsGround groundPlayed = clsGround.getGround(venueName); //Show info txtInfo.Text += "Ground played in: " + groundPlayed.stadiumName + "\n\n"; txtInfo.Text += "Venue played: " + venueName + "\n\n"; txtInfo.Text += "Match name: " + matchName + "\n\n"; txtInfo.Text += "Team 1: " + team1Name + "\n\n"; txtInfo.Text += "Team 1: " + team2Name + "\n\n"; txtInfo.Text += "-----------------------\n\n"; //Get team 1 and 2 string playerFName = "", platerLName = ""; List <clsPlayer> team1 = new List <clsPlayer>(); List <clsPlayer> team2 = new List <clsPlayer>(); comAc = new OleDbCommand("SELECT CurrentTeamID, FirstName, LastName FROM Players", conACCESS); adACC = new OleDbDataAdapter(comAc); dsAC = new DataSet("Players"); adACC.Fill(dsAC, "Players"); //Show info txtInfo.Text += "Players added..." + "\n\n"; foreach (DataRow rAC in dsAC.Tables["Players"].Rows) { int currentTeamID = Convert.ToInt32(rAC[0].ToString()); string currentTeam = ""; OleDbCommand comCurrentTeam = new OleDbCommand("SELECT [Name] FROM Teams WHERE ID=@p1", conACCESS); comCurrentTeam.Parameters.AddWithValue("@p1", currentTeamID); currentTeam = comCurrentTeam.ExecuteScalar().ToString(); playerFName = rAC[1].ToString(); platerLName = rAC[2].ToString(); if (currentTeam == team1Name) { team1.Add(clsPlayer.getPlayer(clsPlayer.getPlayerId(playerFName, platerLName, clsCountry.getCountryCode(team1Name)))); } else { team2.Add(clsPlayer.getPlayer(clsPlayer.getPlayerId(playerFName, platerLName, clsCountry.getCountryCode(team2Name)))); } //Display the data added. txtInfo.Text += playerFName + " " + platerLName + "\n\n"; } OleDbCommand comCaptain1 = new OleDbCommand("SELECT CaptainID FROM MatchTeams WHERE TeamID=@p1", conACCESS); comCaptain1.Parameters.AddWithValue("@p1", team1RefID); OleDbCommand comCaptain2 = new OleDbCommand("SELECT CaptainID FROM MatchTeams WHERE TeamID=@p1", conACCESS); comCaptain2.Parameters.AddWithValue("@p1", team2RefID); int captain1Id = 0; int captain2Id = 0; try { captain1Id = clsImportBallbyBall.mapPlayer(Convert.ToInt32(comCaptain1.ExecuteScalar().ToString()), conACCESS); captain2Id = clsImportBallbyBall.mapPlayer(Convert.ToInt32(comCaptain2.ExecuteScalar().ToString()), conACCESS); } catch (Exception ex) { clsMessages.showMessage(clsMessages.msgType.error, "Error retrieving team capain IDs\n\n" + ex.Message); } List <clsTeams> squard = new List <clsTeams>(); squard.Add(new clsTeams(clsCountry.getCountry(team1Name), team1, captain1Id, 0, 0)); squard.Add(new clsTeams(clsCountry.getCountry(team2Name), team2, captain2Id, 0, 0)); string firstBatting = ""; if (rbTeam1FirstBatting.Checked) { firstBatting = cmbTeam1.SelectedItem.ToString(); } else if (rbTeam2FirstBatting.Checked) { firstBatting = cmbTema2.SelectedItem.ToString(); } new clsMatch(matchId, matchName, matchType, matchDate, path, countryPlayed, groundPlayed, squard, cmbTeam1.SelectedItem.ToString(), firstBatting); SqlCeConnection conSQL = connection.creatDatabase(path, true); //Create tables in the match database clsCreateTables.createTables(conSQL); //connection.CON_WORKING = conSQL; //Creates the match in the main database clsMatch.creatMatch(); if (chkMatchWon.Checked) { clsMatch.setWinningTeam(matchId, squard[0].country.countryId, ""); } else { clsMatch.setWinningTeam(matchId, squard[1].country.countryId, ""); } clsCreateTables.AddTeam(clsMatch.currentMatch.team1.players, clsMatch.currentMatch.matchID); clsCreateTables.AddTeam(clsMatch.currentMatch.team2.players, clsMatch.currentMatch.matchID); lblLoadMatchDate.Enabled = false; btnBallByBall.Enabled = true; clsMessages.showMessage(clsMessages.msgType.information, "Match data was Imported successfully"); }