//add job rec assignments public void Insertjobmapping(int idjobs, int catid, int litermid, int empid) { // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "INSERT INTO jobtable(idjobs, catid, termid, empid) values (@idjobs ,@catid , @litermid ,@empid );"; com.Parameters.Add("@idjobs", MySqlDbType.Int32).Value = idjobs; com.Parameters.Add("@catid", MySqlDbType.Int32).Value = catid; com.Parameters.Add("@litermid", MySqlDbType.Int32).Value = litermid; com.Parameters.Add("@empid", MySqlDbType.Int32).Value = empid; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//this is to populate the selections after the editjobs //form has loaded... public ArrayList Getmultitexts(int jobid) { //store rec details var __arrayrec = new ArrayList(); var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand("select termid from jobtable where idJobs = '" + jobid + "' ; ", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { __arrayrec.Add(reader.GetString("termid")); } } reader.Close(); } return(__arrayrec); }
//aggregate block ///////////////////////////////////////////// //get job count public int Getcountjobs() { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand( "SELECT count(idjobs) FROM jobs where sjobenddate>= curdate();", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//user activation email public StringBuilder Emailactivateusr(string activationlink, string uusername) { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var sbr = new StringBuilder(); using (connreader) { var command = new MySqlCommand( "SELECT eheader, edescription , efooter from emailtemplates where etemplatechkid = 3;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { sbr.Append(reader.GetString(0)); sbr.Append(uusername); sbr.Append(reader.GetString(1)); sbr.Append(activationlink); sbr.Append(reader.GetString(2)); } } reader.Close(); } return(sbr); }
public int Checkrecruiter(int __jobid) { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var passhash = new ClPwdhash(); //string to hold data var __resultset = 0; using (connreader) { var command = new MySqlCommand("SELECT empid from jobtorecruiter where idjobs = @paramjobs limit 1;", connreader); command.Parameters.Add("@paramjobs", MySqlDbType.Int32).Value = __jobid; connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { __resultset = reader.GetInt32(0); } } reader.Close(); } return(__resultset); }
//register a new template, remove safely public void SaveemailTempl(string ebody, int etemplatechkid, string etemplatename, string ehead, string efoot) { //define vars here //int rEmailtype = 0; using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "INSERT INTO emailtemplates(eTemplateName, edescription, eTemplatechkid, eHeader, eFooter) values (@templatename, @eb1, @eb2, @ehead, @efoot)"; com.Parameters.Add("@eb1", MySqlDbType.Text).Value = ebody; com.Parameters.Add("@eb2", MySqlDbType.Int16).Value = etemplatechkid; com.Parameters.Add("@templatename", MySqlDbType.VarChar).Value = etemplatename; com.Parameters.Add("@ehead", MySqlDbType.Text).Value = ehead; com.Parameters.Add("@efoot", MySqlDbType.Text).Value = efoot; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//get recruiter details for jobemails subjects public StringBuilder Dbemailgenerator(int jobid) { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var sbr = new StringBuilder(); using (connreader) { var command = new MySqlCommand( "SELECT * from getsubjectemailapps where idjobs = " + jobid + "; ", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { sbr.Append(reader.GetString(1)); sbr.Append(" / "); sbr.Append(reader.GetString(2)); } } reader.Close(); } return(sbr); }
//get article id to update the logo public int Getarticleids(string uusername) { var arrayrec = 0; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand( "SELECT sarticleid from recruiters rec, recusermapper rmap, users usr where rec.empid = rmap.empid and rmap.idusers = usr.idusers and usr.uusername ='******' limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec = reader.GetInt32(0); } } reader.Close(); } return(arrayrec); }
//get recid via email/name public int Getrecid(string recname) { //store rec details var arrayrec = 0; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand("SELECT empid from recruiters where sRecruiterName ='" + recname + "' limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec = reader.GetInt32(0); } } reader.Close(); } return(arrayrec); }
//update recruiter table information public void Runrectableupdate(string add1, string add2, string add3, string town, string county, string postcode, string compname, string compwebsite, string companyintro, string businessdetail, string uusername) { // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "update recruiters rec, users usr, recusermapper rmap set rec.sRecruiterName =@compname , rec.sAddress1= @add1 , rec.sAddress2= @add2 , rec.sAddress3= @add3 , rec.sTown= @town , rec.sCounty= @county , rec.sPostcode= @postcode ,rec.sWebsite= @compwebsite ,rec.sDescription= @companyintro ,rec.sCompletedesc= @businessdetail where rec.empid = rmap.empid and rmap.idusers = usr.idusers and usr.uusername = @uusername and usr.uUserType = 1;"; com.Parameters.Add("@compname", MySqlDbType.VarChar).Value = compname; com.Parameters.Add("@add1", MySqlDbType.VarChar).Value = add1; com.Parameters.Add("@add2", MySqlDbType.VarChar).Value = add2; com.Parameters.Add("@add3", MySqlDbType.VarChar).Value = add3; com.Parameters.Add("@town", MySqlDbType.VarChar).Value = town; com.Parameters.Add("@county", MySqlDbType.VarChar).Value = county; com.Parameters.Add("@postcode", MySqlDbType.VarChar).Value = postcode; com.Parameters.Add("@compwebsite", MySqlDbType.VarChar).Value = compwebsite; com.Parameters.Add("@companyintro", MySqlDbType.VarChar).Value = companyintro; com.Parameters.Add("@businessdetail", MySqlDbType.VarChar).Value = businessdetail; com.Parameters.Add("@uusername", MySqlDbType.VarChar).Value = uusername; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//get contact person details page public string Contactperson(string jobid) { //store rec details var arrayrec = string.Empty; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand( "SELECT concat_ws(' ',uFirstname,' ',uLastName) from recusers where idjobs ='" + jobid + "' limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec = reader.GetString(0); } } reader.Close(); } return(arrayrec); }
//get results returned by the Query public int Getsearchcounts(string titles, string addedcrit) { //TimeSpan tspan = DateTime.Now.TimeOfDay; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand( @"SELECT count(idjobs)as idjobs from aggregatedmulti where match(sfreetext) against('" + titles + "') " + addedcrit + " ", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//get details page public string Getdetailspagecats(int jobid, int cats) { //store rec details var sbr = new StringBuilder(); var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand( "select sterm from getdetailspages where idJobs= " + jobid + " and catid = " + cats + " ;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { sbr.Append(reader.GetString(0)); sbr.Append("<br>"); } } reader.Close(); } return(sbr.ToString()); }
//fill in jobs form public string[] Filljobform(int jobid) { //store rec details var arrayrec = new string[10]; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand("select * from jobs where idJobs = " + jobid + " limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec[0] = reader.GetString("sTitle"); arrayrec[1] = reader.GetString("sShortDescription"); arrayrec[2] = reader.GetString("sJobstartdate"); arrayrec[3] = reader.GetString("sJobenddate"); arrayrec[4] = reader.GetString("sSalaryText"); arrayrec[5] = reader.GetString("sRef"); arrayrec[6] = reader.GetString("sDescription"); } } reader.Close(); } return(arrayrec); }
//get maximum document id public int Getmaxdocid() { var maxval = 0; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand("select max(documentid)+1 from documents limit 1;", connreader); connreader.Open(); MySqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { maxval = reader.GetInt32(0); //return maxval; } } else { return(0); } reader.Close(); } return(maxval); }
//this adds applications to apps table public void AddApplication(string firstname, string lastname, string dateofbirth, string profilesummary, int mxdocid, string aAppEmail) { using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "INSERT INTO Applications(dtEntered, aFirstName, aLastName, aDateofbirth, aProfileSummary, documentID, aApplicationEmail) values (@tdate, @firstname , @lastname , @dateofbirth, @profilesummary , @mxdocid , @aAppEmail);"; com.Parameters.Add("@tdate", MySqlDbType.DateTime).Value = DateTime.Now; com.Parameters.Add("@firstname", MySqlDbType.VarChar).Value = firstname; com.Parameters.Add("@lastname", MySqlDbType.VarChar).Value = lastname; com.Parameters.Add("@dateofbirth", MySqlDbType.Date).Value = dateofbirth; com.Parameters.Add("@profilesummary", MySqlDbType.VarChar).Value = profilesummary; com.Parameters.Add("@mxdocid", MySqlDbType.Int32).Value = mxdocid; com.Parameters.Add("@aAppEmail", MySqlDbType.VarChar).Value = aAppEmail; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//add to spam table for later review of jobs voilating rules public void Addspamrec(int spamid, string spamreason, string remaddr, string usragnt, int pageid) { // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "INSERT INTO tb_spamreport(spamindex, spamreason, dtentered, ipuser, useragents, jobid) values ( @spamid, @spamreason, @spamdates, @ipusr, @useragents, @pageid);"; com.Parameters.Add("@spamid", MySqlDbType.Int32).Value = spamid; com.Parameters.Add("@spamreason", MySqlDbType.VarChar).Value = spamreason; com.Parameters.Add("@spamdates", MySqlDbType.DateTime).Value = DateTime.Now; com.Parameters.Add("@ipusr", MySqlDbType.VarChar).Value = remaddr; com.Parameters.Add("@useragents", MySqlDbType.VarChar).Value = usragnt; com.Parameters.Add("@pageid", MySqlDbType.Int32).Value = pageid; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//activate accounts for users and recruitersm public void ActivateAcc(int uusertype, string uusername, string keytopass) { //define vars here //int rEmailtype = 0; using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "UPDATE USERS SET uActivation = null where uUsername = @username and uusertype = @usertype and uactivation = @keytopas"; com.Parameters.Add("@usertype", MySqlDbType.Int16).Value = uusertype; com.Parameters.Add("@username", MySqlDbType.VarChar).Value = uusername; com.Parameters.Add("@keytopas", MySqlDbType.VarChar).Value = keytopass; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//get maximum application id public int Getmaxappid() { var maxval = 0; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand("select max(idapplications)+1 from applications limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { maxval = reader.GetInt32(0); } } reader.Close(); } return(maxval); }
//jobseeker password or admin 2 public void Chgpwdjswkey(string keyval, string pwds) { //recalc password hash var clpdh = new ClPwdhash(); var hashedpwd = clpdh.GetMd5Hash(pwds); // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "UPDATE users set uPassword = '******' where uPasswordresetcode= '" + keyval + "' and uUserType = 2; "; com.Parameters.Add("@keyval", MySqlDbType.VarChar).Value = keyval; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//check the usertype for the main windows like is it recruiter of single user public int Checkusertype(string uusername, int uusertypes) { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var passhash = new ClPwdhash(); var plhash = 0; using (connreader) { var command = new MySqlCommand( "SELECT uusertype from users where uusername = '******'and uusertype=" + uusertypes + " ; ", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { plhash = reader.GetInt16(0); } } reader.Close(); } return(plhash); }
//edit jobs public void Updatejobs(int idjobs, string sTitle, string sShortDescription, string sDescription, string ssalarytext, int ssalarymin, int ssalarymax, string sref, string sdate, string edate) { // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "UPDATE jobs SET sTitle=@sTitle , sShortDescription = @sShortDescription ,sDescription = @sDescription , dtentereddate= @curdates , ssalarytext = @ssalarytext ,sminsal = @ssalarymin , smaxsal = @ssalarymax , sref = @sref , sfreetext= @sTitle , sjobstartdate = @sdate , sjobenddate= @edate where idjobs = @idjob;"; com.Parameters.Add("@sTitle", MySqlDbType.VarChar).Value = sTitle; com.Parameters.Add("@sShortDescription", MySqlDbType.VarChar).Value = sShortDescription; com.Parameters.Add("@sDescription", MySqlDbType.Text).Value = sDescription; com.Parameters.Add("@curdates", MySqlDbType.DateTime).Value = DateTime.Now; com.Parameters.Add("@ssalarytext", MySqlDbType.VarChar).Value = ssalarytext; com.Parameters.Add("@ssalarymin", MySqlDbType.Int32).Value = ssalarymin; com.Parameters.Add("@ssalarymax", MySqlDbType.Int32).Value = ssalarymax; com.Parameters.Add("@sref", MySqlDbType.VarChar).Value = sref; com.Parameters.Add("@sdate", MySqlDbType.Date).Value = sdate; com.Parameters.Add("@edate", MySqlDbType.Date).Value = edate; com.Parameters.Add("@idjob", MySqlDbType.Int32).Value = idjobs; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//get recruiters logo for profiles form public string Getrecformimage(int recsids) { //store rec details var arrayrec = string.Empty; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand( "SELECT article_data as Article_data from recruiters,Articles where recruiters.sArticleID=Articles.sArticleID and recruiters.empid = " + recsids + " limit 1; ", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec = reader.GetString(0); } } else { return(null); } reader.Close(); } return(arrayrec); }
//add users public void Insertusers(string rusername, string fname, int uisprimary, string lname, string rpassword, int rtype, int idUsers, string pwdhint, int ucandidateid, string uhash) { // using (var con = new MySqlConnection()) { con.ConnectionString = Dlconnect.Makeconn(); con.Open(); using (var com = con.CreateCommand()) { com.CommandType = CommandType.Text; com.CommandText = "INSERT INTO users(idusers, uusertype, uusername, upassword, upasswordhint, uFirstName, uLastName, uIsPrimary, uCandidateID, uActivation) values (@idUsers ,@rtype ,@rusername ,@rpassword ,@pwdhint ,@fname ,@lname ,1 , @ucandidateid, @uhash);"; com.Parameters.Add("@idUsers", MySqlDbType.Int32).Value = idUsers; com.Parameters.Add("@rtype", MySqlDbType.Int16).Value = rtype; com.Parameters.Add("@rusername", MySqlDbType.VarChar).Value = rusername; com.Parameters.Add("@rpassword", MySqlDbType.VarChar).Value = rpassword; com.Parameters.Add("@pwdhint", MySqlDbType.VarChar).Value = pwdhint; com.Parameters.Add("@fname", MySqlDbType.VarChar).Value = fname; com.Parameters.Add("@lname", MySqlDbType.VarChar).Value = lname; com.Parameters.Add("@ucandidateid", MySqlDbType.Int32).Value = ucandidateid; com.Parameters.Add("@uhash", MySqlDbType.VarChar).Value = uhash; int reslt = com.ExecuteNonQuery(); } con.Close(); } }
//get advertizing rec count public int Getcountrecswadvert() { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand( "SELECT count(empid) FROM getallrec;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//max candidate id public int Maxcandidateid() { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand("SELECT max(idCandidates)+1 FROM candidates;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//gets max recruiters public int RecHasRows() { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand( "SELECT max(Empid) FROM recruiters;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//get recruiterid by name public int RecName(string usrname) { var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; var ct = 0; using (connreader) { var command = new MySqlCommand( "select rec.EmpID from recruiters rec, recusermapper rmap, users usr where rec.EmpID = rmap.EmpID and rmap.idUsers = usr.idUsers and usr.uUsername = '******' limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ct = reader.GetInt32(0); } } reader.Close(); } return(ct); }
//getrecruiterdetails public string[] RecDetails(string usrname) { //store rec details var arrayrec = new string[16]; var connreader = new MySqlConnection { ConnectionString = Dlconnect.Makeconn() }; using (connreader) { var command = new MySqlCommand( "select rec.*,usr.* from recruiters rec, recusermapper rmap, users usr where rec.EmpID = rmap.EmpID and rmap.idUsers = usr.idUsers and usr.uUsername = '******' limit 1;", connreader); connreader.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { arrayrec[0] = reader.GetString("uFirstName"); arrayrec[1] = reader.GetString("uLastName"); arrayrec[2] = reader.GetString("sRecruiterName"); arrayrec[3] = reader.GetString("sAddress1"); arrayrec[4] = reader.GetString("sAddress2"); arrayrec[5] = reader.GetString("sAddress3"); arrayrec[6] = reader.GetString("sTown"); arrayrec[7] = reader.GetString("sCounty"); arrayrec[8] = reader.GetString("sCountry"); arrayrec[9] = reader.GetString("sPostcode"); arrayrec[10] = "XXXXXXXXXX"; arrayrec[11] = reader.GetString("uPasswordHint"); arrayrec[12] = reader.GetString("sEmailAddress"); arrayrec[13] = reader.GetString("sWebsite"); arrayrec[14] = reader.GetString("sdescription"); arrayrec[15] = reader.GetString("scompletedesc"); } } reader.Close(); } return(arrayrec); }
//this adds detail page views public void Addview(int empid, string dtentered) { var conn = new MySqlConnection(); var cmd = new MySqlCommand(); var myquerystring = "INSERT INTO jobviews(Empid, dtentered) values (" + empid + ", '" + dtentered + "')"; conn.ConnectionString = Dlconnect.Makeconn(); conn.Open(); cmd.Connection = conn; cmd.CommandText = myquerystring; cmd.ExecuteNonQuery(); conn.Close(); }