public int returnelectionId(string election) { string[] parts = election.Split(','); string election_info = parts[0].Trim(); string startdate = parts[1].Trim(); string enddate = parts[2].Trim(); MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "select_election_id"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_INFO", election_info); cmd.Parameters["@LOC_ELECTION_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_STARTING_DATE", startdate); cmd.Parameters["@LOC_ELECTION_STARTING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_ENDING_DATE", enddate); cmd.Parameters["@LOC_ELECTION_ENDING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", SqlDbType.Int); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int election_id = (int)cmd.Parameters["@LOC_ELECTION_ID"].Value; MySQLDB.Disconnect(); return(election_id); }
protected void BtnAdd_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string tc = this.TextBoxTc.Text; //STORED PROCEDURE ÇALIŞTIRILCAK cmd.CommandText = "add_cityofficial"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", tc); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@IS_PERSON", SqlDbType.Int); cmd.Parameters["@IS_PERSON"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int error = (int)cmd.Parameters["@IS_PERSON"].Value; if (error == 0) { LabelResult.Text = "City Official was added succesfully."; } else if (error == 1) { LabelResult.Text = "Person you tried to add is dead."; } else if (error == 2) { LabelResult.Text = "Person you tried to add do not exist."; } MySQLDB.Disconnect(); }
protected void BtnDeleteCandidate_Click(object sender, EventArgs e) { string candidate_info = Request.Form[DropDownListCandidate.UniqueID]; string election = Request.Form[DropDownListElection.UniqueID]; int election_id = returnelectionId(election); MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "delete_candidate"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", election_id); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_INFO", candidate_info); cmd.Parameters["@LOC_CANDIDATE_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@CONTROL", MySqlDbType.Bit); cmd.Parameters["@CONTROL"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@CONTROL"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "Candidate deleted from election successfully."; } else { LabelResult.Text = "No such candidate."; } MySQLDB.Disconnect(); }
protected void BtnDeleteCityOfficial_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string tc = this.TextBoxTc.Text; //STORED PROCEDURE ÇALIŞTIRILCAK cmd.CommandText = "delete_cityofficial"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", tc); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@IS_CO", SqlDbType.Bit); cmd.Parameters["@IS_CO"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@IS_CO"].Value.ToString(); if (error.Equals("0")) { LabelResult.Text = "City Official was deleted succesfully."; } else if (error.Equals("1")) { LabelResult.Text = "Person you tried to add doesnt exist."; } MySQLDB.Disconnect(); }
protected void BtnDeleteGeneralOfficial_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string TC = this.TextBoxTc.Text; cmd.CommandText = "delete_person"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", TC); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_IS_PERSON", SqlDbType.Bit); cmd.Parameters["@LOC_IS_PERSON"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@LOC_IS_PERSON"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "Death information was updated succesfully."; } else if (error.Equals("0")) { LabelResult.Text = "No such person."; } MySQLDB.Disconnect(); }
protected void BtnAddElection_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string secimAdi = this.TextBoxSecimAdi.Text; string baslangicTarihi = this.BaslangicTarihi.Text; baslangicTarihi += " 08:00:00"; DateTime baslangicTarihidt = DateTime.ParseExact(baslangicTarihi, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); string bitisTarihi = this.BitisTarihi.Text; bitisTarihi += " 17:00:00"; DateTime bitisTarihidt = DateTime.ParseExact(bitisTarihi, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); cmd.CommandText = "add_election"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_INFO", secimAdi); cmd.Parameters["@LOC_ELECTION_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_STARTING_DATE", baslangicTarihidt); cmd.Parameters["@LOC_ELECTION_STARTING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_ENDING_DATE", bitisTarihidt); cmd.Parameters["@LOC_ELECTION_ENDING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", SqlDbType.Int); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@LOC_CONTROL_ADDING", SqlDbType.Int); cmd.Parameters["@LOC_CONTROL_ADDING"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int error = (int)cmd.Parameters["@LOC_CONTROL_ADDING"].Value; if (error == 0) { LabelResult.Text = "Election is added."; } else if (error == 1) { LabelResult.Text = "Starting date already passed."; } else if (error == 2) { LabelResult.Text = "Starting date is after ending date."; } else if (error == 3) { LabelResult.Text = "Election already exists in database."; } MySQLDB.Disconnect(); }
protected void BtnShow_Click(object sender, EventArgs e) { string tc = TextBoxTc.Text; MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "select_person"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", tc); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@LOC_PERSON_INFO", MySqlDbType.VarChar, 500); cmd.Parameters["@LOC_PERSON_INFO"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@IS_PERSON", MySqlDbType.Bit); cmd.Parameters["@IS_PERSON"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@IS_PERSON"].Value.ToString(); if (error.Equals("0")) { LabelResult.Text = "There is no registered person with that TC identity number."; } else { string person_info = cmd.Parameters["@LOC_PERSON_INFO"].Value.ToString(); string[] parts = person_info.Split('&'); string person_name = parts[0].Trim(); string person_surname = parts[1].Trim(); string person_bp = parts[2].Trim(); string person_bd = parts[3].Trim(); string person_city = parts[4].Trim(); string person_district = parts[5].Trim(); string person_neigborhood = parts[6].Trim(); string[] bd_parts = person_bd.Split('-'); string bd_year = bd_parts[0]; string bd_month = bd_parts[1]; string bd_day = bd_parts[2]; person_bd = bd_day + "." + bd_month + "." + bd_year; TextBoxName.Text = person_name; TextBoxSurname.Text = person_surname; TextBoxBirthPlace.Text = person_bp; } MySQLDB.Disconnect(); }
protected void BtnChangePassword_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string userName = Session["userName"].ToString(); string passwordold = this.TextBoxPasswordOld.Text; string passwordnew = this.TextBoxPasswordNew.Text; string passwordnew2 = this.TextBoxPasswordNew2.Text; cmd.CommandText = "update_city_official_password"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", userName); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_OLD_PASS", passwordold); cmd.Parameters["@LOC_OLD_PASS"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_NEW_PASS", passwordnew); cmd.Parameters["@LOC_NEW_PASS"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_NEW_PASS_AGAIN", passwordnew2); cmd.Parameters["@LOC_NEW_PASS_AGAIN"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@OLD_PASS_CORRECT", MySqlDbType.Bit); cmd.Parameters["@OLD_PASS_CORRECT"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@PASSES_CORRECT", MySqlDbType.Bit); cmd.Parameters["@PASSES_CORRECT"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String old_pass_correct = cmd.Parameters["@OLD_PASS_CORRECT"].Value.ToString(); String passes_correct = cmd.Parameters["@PASSES_CORRECT"].Value.ToString(); if (old_pass_correct.Equals("0")) { LabelResult.Text = "Wrong password."; } else if (old_pass_correct.Equals("1") && passes_correct.Equals("0")) { LabelResult.Text = "The values you entered do not match."; } else { LabelResult.Text = "Your password was updated successfully."; } MySQLDB.Disconnect(); }
protected void BtnUpdatePoll_Click(object sender, EventArgs e) { string city = Request.Form[DropDownListCity.UniqueID]; string district = Request.Form[DropDownListDistrict.UniqueID]; string neighborhood = Request.Form[DropDownListNeighborhood.UniqueID]; string oldschoolname = Request.Form[DropDownListPolls.UniqueID]; string poll = TextBoxNewSchool.Text; //poolun ıdsini dödüren queryi çalıştırılıp //UpdatePoll fonksiyonu çalıştırılcak MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "update_poll"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_OLD_POLL_NAME", oldschoolname); cmd.Parameters["@LOC_OLD_POLL_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_NAME", poll); cmd.Parameters["@LOC_POLL_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_CITY", city); cmd.Parameters["@LOC_POLL_CITY"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_DISTRICT", district); cmd.Parameters["@LOC_POLL_DISTRICT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_NEIGHBORHOOD", neighborhood); cmd.Parameters["@LOC_POLL_NEIGHBORHOOD"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CONTROL_UPDATE", MySqlDbType.Bit); cmd.Parameters["@LOC_CONTROL_UPDATE"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@LOC_CONTROL_UPDATE"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "Poll updated successfully."; } else { LabelResult.Text = "No such poll."; } MySQLDB.Disconnect(); }
protected void BtnUpdateElection_Click(object sender, EventArgs e) { string election = Request.Form[DropDownListElection.UniqueID]; int election_id = returnelectionId(election); MySqlCommand cmd = MySQLDB.Connect(); string election_info = TextBoxElectionName.Text; string startdate = BaslangicTarihi.Text; string enddate = BitisTarihi.Text; cmd.CommandText = "update_election"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", election_id); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_INFO", election_info); cmd.Parameters["@LOC_ELECTION_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_STARTING_DATE", startdate); cmd.Parameters["@LOC_ELECTION_STARTING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ELECTION_ENDING_DATE", enddate); cmd.Parameters["@LOC_ELECTION_ENDING_DATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CONTROL_UPDATE", SqlDbType.Int); cmd.Parameters["@LOC_CONTROL_UPDATE"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int error = (int)cmd.Parameters["@LOC_CONTROL_UPDATE"].Value; if (error == 0) { LabelResult.Text = "Election updated successfully."; } else if (error == 1) { LabelResult.Text = "Election starting date already passed."; } else if (error == 2) { LabelResult.Text = "Election ending date is before electıon starting date."; } MySQLDB.Disconnect(); }
private string getCipherText(string serial, string username, int electionid) { string cipherText = ""; MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "show_vote"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", electionid); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", username); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_SERIALNUMBER", serial); cmd.Parameters["@LOC_SERIALNUMBER"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@LOC_CIPHERTEXT", MySqlDbType.VarChar); cmd.Parameters["@LOC_CIPHERTEXT"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@CONTROL", SqlDbType.Int); cmd.Parameters["@CONTROL"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int error = (int)cmd.Parameters["@CONTROL"].Value; if (error == 0) { cipherText = cmd.Parameters["@LOC_CIPHERTEXT"].Value.ToString(); //Diğer işlemler //LabelResult.Text = cipherText; } else if (error == 1) { LabelResult.Text = "You did not vote for selected election."; } else if (error == 2) { LabelResult.Text = "No matching serial number."; } MySQLDB.Disconnect(); return(cipherText); }
protected void BtnAddPoll_Click(object sender, EventArgs e) { string schoolName = TextBoxSchoolName.Text; string city = Request.Form[DropDownListCity.UniqueID]; string district = Request.Form[DropDownListDistrict.UniqueID]; string neighborhood = Request.Form[DropDownListNeighborhood.UniqueID]; MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "add_poll"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_POLL_NAME", schoolName); cmd.Parameters["@LOC_POLL_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_CITY", city); cmd.Parameters["@LOC_POLL_CITY"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_DISTRICT", district); cmd.Parameters["@LOC_POLL_DISTRICT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_NEIGHBORHOOD", neighborhood); cmd.Parameters["@LOC_POLL_NEIGHBORHOOD"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_IS_POLL", MySqlDbType.Bit); cmd.Parameters["@LOC_IS_POLL"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@LOC_IS_POLL"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "School added successfully."; } else { LabelResult.Text = "The school is already exist."; } MySQLDB.Disconnect(); }
private void addVote(string election_id, string username, string candidate_id, string ciphertext, string serialtext) { MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "add_vote"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", election_id); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", username); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_ID", candidate_id); cmd.Parameters["@LOC_CANDIDATE_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@CIPHERTEXT", ciphertext); cmd.Parameters["@CIPHERTEXT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@SERIALNUMBER", serialtext); cmd.Parameters["@SERIALNUMBER"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CONTROL_ADDING", MySqlDbType.Bit); cmd.Parameters["@LOC_CONTROL_ADDING"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@LOC_CONTROL_ADDING"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "You voted successfully. Please keep your serial number. Thank you for voting :)"; } else { LabelResult.ForeColor = System.Drawing.Color.Red; LabelResult.Text = "You've already voted this election! "; } MySQLDB.Disconnect(); }
protected void BtnUpdateCandidate_Click(object sender, EventArgs e) { var candidate_id = ""; string candidateinfo = Request.Form[DropDownListCandidate.UniqueID]; String myConnectionString; myConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; MySqlConnection conn = new MySqlConnection(myConnectionString); MySqlCommand cmd = conn.CreateCommand(); cmd.Parameters.AddWithValue("?candidateinfo", candidateinfo); string query = "SELECT CANDIDATE_ID FROM CANDIDATE WHERE CANDIDATE_INFO = ?candidateinfo; "; cmd.CommandText = query; conn.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { candidate_id = reader["CANDIDATE_ID"].ToString(); } conn.Close(); string picturePath=""; string newCandidateInfo = TextBoxCandidateInfo.Text; cmd = MySQLDB.Connect(); cmd.CommandText = "update_candidate"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_ID", candidate_id); cmd.Parameters["@LOC_CANDIDATE_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_INFO", newCandidateInfo); cmd.Parameters["@LOC_CANDIDATE_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_IMAGE", picturePath); cmd.Parameters["@LOC_CANDIDATE_IMAGE"].Direction = ParameterDirection.Input; MySqlDataReader dr = cmd.ExecuteReader(); MySQLDB.Disconnect(); }
protected void BtnDeletePoll_Click(object sender, EventArgs e) { string city = Request.Form[DropDownListCity.UniqueID]; string district = Request.Form[DropDownListDistrict.UniqueID]; string neighborhood = Request.Form[DropDownListNeighborhood.UniqueID]; string poll = Request.Form[DropDownListPolls.UniqueID]; MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "delete_poll"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_POLL_NAME", poll); cmd.Parameters["@LOC_POLL_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_CITY", city); cmd.Parameters["@LOC_POLL_CITY"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_DISTRICT", district); cmd.Parameters["@LOC_POLL_DISTRICT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_POLL_NEIGHBORHOOD", neighborhood); cmd.Parameters["@LOC_POLL_NEIGHBORHOOD"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@CONTROL", MySqlDbType.Bit); cmd.Parameters["@CONTROL"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@CONTROL"].Value.ToString(); if (error.Equals("1")) { LabelResult.Text = "Poll deleted successfully."; } else { LabelResult.Text = "No poll such that."; } }
protected void BtnAddCandidate_Click(object sender, EventArgs e) { MySqlCommand cmd = MySQLDB.Connect(); string election = Request.Form[DropDownListElection.UniqueID]; string candidate_info = Request.Form[DropDownListCandidate.UniqueID]; int election_id = returnelectionId(election); cmd.CommandText = "add_candidate_election"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_ELECTION_ID", election_id); cmd.Parameters["@LOC_ELECTION_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_INFO", candidate_info); cmd.Parameters["@LOC_CANDIDATE_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CONTROL", SqlDbType.Int); cmd.Parameters["@LOC_CONTROL"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); int error = (int)cmd.Parameters["@LOC_CONTROL"].Value; if (error == 0) { LabelResult.Text = "No such candidate."; } else if (error == 1) { LabelResult.Text = "Candidate added election successfully."; } else if (error == 2) { LabelResult.Text = "This candidate already in that election candidate."; } MySQLDB.Disconnect(); }
protected void BtnAdd_Click(object sender, EventArgs e) { string candidateInfo = TextBoxCandidateInfo.Text; string picturePath = ""; MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "add_candidate"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_INFO", candidateInfo); cmd.Parameters["@LOC_CANDIDATE_INFO"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_CANDIDATE_IMAGE", picturePath); cmd.Parameters["@LOC_CANDIDATE_IMAGE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_IS_CANDIDATE", MySqlDbType.Bit); cmd.Parameters["@LOC_IS_CANDIDATE"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@LOC_IS_CANDIDATE"].Value.ToString(); if (error.Equals("0")) { LabelResult.Text = "That candidate is already in database."; } else { LabelResult.Text = "Candidate added successfully."; } MySQLDB.Disconnect(); }
protected void BtnUpdateUser_Click(object sender, EventArgs e) { string city = Request.Form[DropDownListDistrict.UniqueID]; string district = Request.Form[DropDownListDistrict.UniqueID]; string neighborhood = Request.Form[DropDownListNeighborhood.UniqueID]; string tc = TextBoxTc.Text; string name = TextBoxName.Text; string surname = TextBoxSurname.Text; string birthplace = TextBoxBirthPlace.Text; string birthdate = TextBoxBirthDate.Text; DateTime birthdatedatetime = DateTime.ParseExact(birthdate, "yyyy-MM-dd", CultureInfo.InvariantCulture); //procedure çalıştırılcak//diğer hata mesejları için labelresultı kullan //yaşını 18 yaşından küçük olacak şekilde güncelleyemez if ((DateTime.Now.Year) - (birthdatedatetime.Year + 1) < 18) { LabelResult1.Text = "You cant add a person whose age is smaller than 18."; } else { MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "update_person"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", tc); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_NAME", name); cmd.Parameters["@LOC_PERSON_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_SURNAME", surname); cmd.Parameters["@LOC_PERSON_SURNAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_BIRTHPLACE", birthplace); cmd.Parameters["@LOC_PERSON_BIRTHPLACE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_BIRTHDATE", birthdate); cmd.Parameters.AddWithValue("@IS_PERSON", MySqlDbType.Bit); cmd.Parameters["@IS_PERSON"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@IS_PERSON"].Value.ToString(); cmd = MySQLDB.Connect(); cmd.CommandText = "update_person_address"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", tc); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_CITY", city); cmd.Parameters["@LOC_ADDRESS_CITY"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_DISTRICT", district); cmd.Parameters["@LOC_ADDRESS_DISTRICT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_NEIGBORHOOD", neighborhood); cmd.Parameters["@LOC_ADDRESS_NEIGBORHOOD"].Direction = ParameterDirection.Input; dr = cmd.ExecuteReader(); if (error.Equals("1")) { LabelResult.Text = "Person updated successfully."; } else { LabelResult.Text = "The person you tried to add is already registered."; } MySQLDB.Disconnect(); } }
protected void BtnAddUser_Click(object sender, EventArgs e) { string city = Request.Form[DropDownListCity.UniqueID]; string district = Request.Form[DropDownListDistrict.UniqueID]; string neighborhood = Request.Form[DropDownListNeighborhood.UniqueID]; string TC = TextBoxTc.Text; string name = TextBoxName.Text; string surname = TextBoxSurname.Text; string bp = TextBoxBirthPlace.Text; string s_bd = TextBoxBirthDate.Text; string file_number = TextBoxFileId.Text; string fingerprint = "";//Değişecek DateTime bd = DateTime.ParseExact(s_bd, "yyyy-MM-dd", CultureInfo.InvariantCulture); if ((DateTime.Now.Year) - (bd.Year + 1) < 18) { LabelResult1.Text = "You cant add a person whose age is smaller than 18."; } else { MySqlCommand cmd = MySQLDB.Connect(); cmd.CommandText = "add_person_address"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LOC_PERSON_ID", TC); cmd.Parameters["@LOC_PERSON_ID"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_NAME", name); cmd.Parameters["@LOC_PERSON_NAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_SURNAME", surname); cmd.Parameters["@LOC_PERSON_SURNAME"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_BIRTHPLACE", bp); cmd.Parameters["@LOC_PERSON_BIRTHPLACE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_PERSON_BIRTHDATE", bd); cmd.Parameters["@LOC_PERSON_BIRTHDATE"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_FINGER_PRINT", fingerprint); cmd.Parameters["@LOC_FINGER_PRINT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_CITY", city); cmd.Parameters["@LOC_ADDRESS_CITY"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_DISTRICT", district); cmd.Parameters["@LOC_ADDRESS_DISTRICT"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_ADDRESS_NEIGBORHOOD", neighborhood); cmd.Parameters["@LOC_ADDRESS_NEIGBORHOOD"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@LOC_FILE_NUMBER", file_number); cmd.Parameters["@LOC_FILE_NUMBER"].Direction = ParameterDirection.Input; cmd.Parameters.AddWithValue("@IS_PERSON", MySqlDbType.Bit); cmd.Parameters["@IS_PERSON"].Direction = ParameterDirection.Output; MySqlDataReader dr = cmd.ExecuteReader(); String error = cmd.Parameters["@IS_PERSON"].Value.ToString(); if (error.Equals("0")) { LabelResult.Text = "Person added successfully."; } else { LabelResult.Text = "The person already exist."; } MySQLDB.Disconnect(); } }