protected void closefri_Click(object sender, ImageClickEventArgs e) { try { urlpath = Request.UrlReferrer.ToString(); con.Open(); //this code deletes the friend requests for both alumni cmdfri = new MySqlCommand("delete from user_friends where (req_to_id=@toid or req_from_id=@toid) and (req_to_id=@fromid or req_from_id=@fromid)", con); cmdfri.Parameters.AddWithValue("toid", toid); cmdfri.Parameters.AddWithValue("fromid", fromid); cmdfri.ExecuteNonQuery(); //this code deletes all the messages sent/received from/to alumni if (Session["loginname"]!=null) { cmdfri = new MySqlCommand("delete from message where (msg_from=@p1 or msg_to=@p1) and (msg_from=@p2 or msg_to=@p2)", con); cmdfri.Parameters.AddWithValue("p1", userdet); cmdfri.Parameters.AddWithValue("p2", Session["loginname"].ToString()); cmdfri.ExecuteNonQuery(); } con.Close(); closefri.Visible = false; friimg.Visible = false; sndmsg.Visible = true; imgadd.Visible = true; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Closefri method of AlumniProfileHome page for " + Session["loginname"] + ": " + ex.Message); } Response.Redirect(urlpath); }
protected void Page_Load(object sender, EventArgs e) { string uname, code; uname = decodepwd(Request.QueryString["uid"]); code = Request.QueryString["aucode"]; try { con.Open(); cmdmail = new MySqlCommand("update alumnireg set valid_mail=1 where username='******' and auth_code='" + code + "'", con); cmdmail.ExecuteNonQuery(); cmdentry = new MySqlCommand("update login set logentry=2 where username='******'", con); cmdentry.ExecuteNonQuery(); cmdfr = new MySqlCommand("update forum_users set group_id=4 where username='******'", con); cmdfr.ExecuteNonQuery(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("Logs/Errorlog"), "Page_Load method of VerifyMail page :" + ex.Message); } finally { con.Close(); } }
protected void add_annon_Click(object sender, EventArgs e) { DateTime regdate = System.DateTime.Now, origin = new DateTime(2000, 1, 1, 0, 0, 0, 0); TimeSpan stamp = regdate - origin; int aid = stamp.Days + stamp.Seconds; try { con.Open(); cmd = new MySqlCommand("insert into annon(msg_id,msg,msg_date) values(@inp1,@inp2,@inp3)", con); cmd.Parameters.AddWithValue("inp1", aid); cmd.Parameters.AddWithValue("inp2", anntext.Value); cmd.Parameters.AddWithValue("inp3", anndate.Text); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Add_annon method of Admin_Misc Page for " + Session["loginname"] + ":" + ex.Message); } finally { succmsg.Text = "Announcement added successfully"; anndate.Text = ""; anntext.Value = ""; } }
public void approverecord(ArrayList ar) { try { con.Open(); foreach (object i in ar) { MySqlCommand cmd = new MySqlCommand("update alumnireg set valid_mail=1 where regid=" + i, con); cmd.ExecuteNonQuery(); cmd = new MySqlCommand("update login set logentry=2 where regid=" + i, con); cmd.ExecuteNonQuery(); cmd = new MySqlCommand("update forum_users set group_id=4 where regid=" + i, con); cmd.ExecuteNonQuery(); sendmail(i); cmd = new MySqlCommand("update alumnireg set incorrect='Success' where regid=" + i, con); cmd.ExecuteNonQuery(); } con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Approve Record method of Admin_users page for " + Session["loginname"] + ": " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { string name; try { con.Open(); name = Session["loginname"].ToString(); cmdadd = new MySqlCommand("select branch from forum_users where username='******'", con); dr = cmdadd.ExecuteReader(); dr.Read(); mybranch = dr.GetString("branch"); dr.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of Stud_add page for " + Session["loginname"] + ":" + ex.Message); } if (Page.IsPostBack) { if (!(String.IsNullOrEmpty(pass.Text.Trim()))) { pass.Attributes["value"] = pass.Text; } pass.Text = pass.Attributes["value"]; } }
protected void Page_Load(object sender, EventArgs e) { nid = Request.QueryString["news_id"]; try { con.Open(); cmd = new MySqlCommand("select * from news where newsid='" + nid + "'", con); dr = cmd.ExecuteReader(); if (dr.Read()) { article.Text = "<h1 style='font-size:25px'>" + dr.GetString("headline").Substring(0, 1).ToUpper() + dr.GetString("headline").Substring(1).ToLower() + "</h1><br/><br/><img alt='' src='../images/tag.png' /> Alumni News<br/><br/>"; article.Text += " <p style='text-align: justify;'>" + dr.GetString("story") + "</p>"; article.Text += "<p style='text-align: justify;'><a href='http://alumni.ssn.edu.in/alumni-stories.php'>http://alumni.ssn.edu.in/alumni-stories.php</a></p>"; dr.Close(); con.Close(); } else { rerr.Visible = true; } } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page load method of NewsRead page for " + Session["loginname"] + ":" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.Count == 0) { evtid = "2"; } else { evtid = Request.QueryString["eventid"]; } try { con.Open(); cmddispevt = new MySqlCommand("select name,detail,img1path,img2path,img3path from events where rowid=" + evtid, con); drdispevt = cmddispevt.ExecuteReader(); drdispevt.Read(); EventHead = drdispevt.GetString("name"); EventStory = drdispevt.GetString("detail"); img1.Src = "../" + drdispevt.GetString("img1path") + "thumbs/img1.jpg"; img2.Src = "../" + drdispevt.GetString("img2path") + "thumbs/img2.jpg"; img3.Src = "../" + drdispevt.GetString("img3path") + "thumbs/img3.jpg"; aimg1.HRef = "../" + drdispevt.GetString("img1path") + "slides/img1.jpg"; aimg2.HRef = "../" + drdispevt.GetString("img2path") + "slides/img2.jpg"; aimg3.HRef = "../" + drdispevt.GetString("img3path") + "slides/img3.jpg"; drdispevt.Close(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load of AboutSSNAA Page for " + Session["loginname"] + ":" + ex.Message); } }
protected void Submit_prof_Click(object sender, EventArgs e) { try { con.Open(); cmdper = new MySqlCommand("update alumnireg set role=@urole, fname=@firname,lname=@lstname,gender=@gen,dob=@birth,email=@mail,batch=@bat,degree=@deg,branch=@bran,city=@ucity,state=@ustate,country=@cntry,address=@add1,number=@num where username='******'", con); cmdper.Parameters.AddWithValue("@urole", alu_role.Text); cmdper.Parameters.AddWithValue("@firname", alu_fname.Text); cmdper.Parameters.AddWithValue("@lstname", alu_lname.Text); cmdper.Parameters.AddWithValue("@gen", alu_gender.SelectedItem.Value); cmdper.Parameters.AddWithValue("@birth", alu_dob.Text); cmdper.Parameters.AddWithValue("@mail", alu_email.Text); cmdper.Parameters.AddWithValue("@bran", alu_branch.SelectedItem.Value); cmdper.Parameters.AddWithValue("@deg", alu_degree.SelectedItem.Value); cmdper.Parameters.AddWithValue("@bat", alu_batch.SelectedItem.Value); cmdper.Parameters.AddWithValue("@ucity", alu_city.Text); cmdper.Parameters.AddWithValue("@ustate", alu_state.Text); cmdper.Parameters.AddWithValue("@cntry", alu_country.SelectedItem.Value); cmdper.Parameters.AddWithValue("@add1", alu_addr.Text); cmdper.Parameters.AddWithValue("@num", alu_number.Text); cmdper.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit Prof of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void closefri_Click(object sender, ImageClickEventArgs e) { try { con.Open(); //this code deletes the friend requests for both alumni cmdfri = new MySqlCommand("delete from user_friends where (req_to_id=@toid or req_from_id=@toid) and (req_to_id=@fromid or req_from_id=@fromid)", con); cmdfri.Parameters.AddWithValue("toid", toid); cmdfri.Parameters.AddWithValue("fromid", fromid); cmdfri.ExecuteNonQuery(); //this code deletes all the messages sent/received from/to alumni if (Session["loginname"] != null) { cmdfri = new MySqlCommand("delete from message where (msg_from=@p1 or msg_to=@p1) and (msg_from=@p2 or msg_to=@p2)", con); cmdfri.Parameters.AddWithValue("p1", userdet); cmdfri.Parameters.AddWithValue("p2", Session["loginname"].ToString()); cmdfri.ExecuteNonQuery(); } con.Close(); closefri.Visible = false; friimg.Visible = false; sndmsg.Visible = false; imgadd.Visible = true; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Closefri method of AlumniProfileHome page for " + Session["loginname"] + ": " + ex.Message); } }
protected void Submit_edu_Click(object sender, EventArgs e) { string instname = alu_inst.Text + "/" + alu_inst1.Text + "/" + alu_inst2.Text + "/" + alu_inst3.Text; string instloc = alu_iloc.Text + "/" + alu_iloc1.Text + "/" + alu_iloc2.Text + "/" + alu_iloc3.Text; string instcourse = ((alu_course.SelectedIndex == 0) ? "" : alu_course.SelectedItem.Value) + "/" + ((alu_course1.SelectedIndex == 0) ? "" : alu_course1.SelectedItem.Value) + "/" + ((alu_course2.SelectedIndex == 0) ? "" : alu_course2.SelectedItem.Value) + "/" + ((alu_course3.SelectedIndex == 0) ? "" : alu_course3.SelectedItem.Value); string instyr = alu_passyr.Text + "/" + alu_passyr1.Text + "/" + alu_passyr2.Text + "/" + alu_passyr3.Text; try { con.Open(); cmdedu = new MySqlCommand("update alumnireg set inst_name=@iname,inst_course=@sub,inst_loc=@loca,inst_passyr=@yr where username='******'", con); cmdedu.Parameters.AddWithValue("@iname", instname); cmdedu.Parameters.AddWithValue("@sub", instcourse); cmdedu.Parameters.AddWithValue("@loca", instloc); cmdedu.Parameters.AddWithValue("@yr", instyr); cmdedu.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit education method of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.Count==0) { evtid = "2"; } else { evtid = Request.QueryString["eventid"]; } try { con.Open(); cmddispevt = new MySqlCommand("select name,detail,img1path,img2path,img3path from events where rowid=" + evtid, con); drdispevt = cmddispevt.ExecuteReader(); drdispevt.Read(); EventHead = drdispevt.GetString("name"); EventStory = drdispevt.GetString("detail"); img1.Src = "../"+drdispevt.GetString("img1path") + "thumbs/img1.jpg"; img2.Src = "../" + drdispevt.GetString("img2path") + "thumbs/img2.jpg"; img3.Src = "../" + drdispevt.GetString("img3path") + "thumbs/img3.jpg"; aimg1.HRef = "../" + drdispevt.GetString("img1path") + "slides/img1.jpg"; aimg2.HRef = "../" + drdispevt.GetString("img2path") + "slides/img2.jpg"; aimg3.HRef = "../" + drdispevt.GetString("img3path") + "slides/img3.jpg"; drdispevt.Close(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load of AboutSSNAA Page for " + Session["loginname"] + ":" + ex.Message); } }
protected void editimage_Click(object sender, EventArgs e) { string filename = "", path, qry = "", type = Path.GetExtension(FileUpload1.PostedFile.FileName); HttpPostedFile imgfile = FileUpload1.PostedFile; if (type == "") { photo.Text = "<font color='red'>Please Upload an Image..</font>"; } else if (imgfile.ContentLength > 1048576) //file size must be less than 1mb { photo.Text = "<font color='red'>Image size must be less than 1 mb..</font>"; } else { try { con.Open(); cmduser = new MySqlCommand("select imgpath from alumnireg where regid=" + urowid, con); druser = cmduser.ExecuteReader(); druser.Read(); if (druser.IsDBNull(0) || string.IsNullOrEmpty(druser.GetString("imgpath"))) { qry = "update alumnireg set imgpath='Alumni_Images/" + rid + ".png' where regid=" + urowid; filename = "Alumni_Images/" + rid + ".png"; path = Server.MapPath("../" + filename); } else { filename = druser.GetString("imgpath"); path = Server.MapPath("../" + filename); qry = "update alumnireg set imgpath='" + filename + "' where regid=" + urowid; } GenerateThumbnails(FileUpload1.PostedFile.InputStream, path); //FileUpload1.PostedFile.SaveAs(path); druser.Close(); if (qry != "") { cmduser = new MySqlCommand(qry, con); cmduser.ExecuteNonQuery(); } con.Close(); userimg.Src = filename; Response.Redirect("AlumniProfHome.aspx"); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Edit Image method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "OnLoad", "showme();", true); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row; row = GridView1.Rows[e.RowIndex]; TextBox t; t = (TextBox)row.Cells[3].Controls[0]; string nename = t.Text; t = (TextBox)row.Cells[4].Controls[0]; string eid = t.Text; int eno = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); MySqlCommand cmd = new MySqlCommand("update forum_users set username='******',password=password('" + eid + "') where id=" + eno, con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); GridView1.EditIndex = -1; binddata(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "GridView RowUpdating method of Stud_EditDel page for " + Session["loginname"] + ":" + ex.Message); } }
protected void submit_Click(object sender, EventArgs e) { if (opt1.Text == "" || opt2.Text == "" || opt3.Text == "" || opt4.Text == "") { success.Text = "Please fill in all the Option values"; } else { success.Text = ""; try { con.Open(); cmd = new MySqlCommand("insert into poll(pollquest,opt1,opt2,opt3,opt4,activate,polldate) values(@quest,@opt1,@opt2,@opt3,@opt4,@act,@date)", con); cmd.Parameters.AddWithValue("quest", pollquest.Value.Trim()); cmd.Parameters.AddWithValue("opt1", opt1.Text.Trim()); cmd.Parameters.AddWithValue("opt2", opt2.Text.Trim()); cmd.Parameters.AddWithValue("opt3", opt3.Text.Trim()); cmd.Parameters.AddWithValue("opt4", opt4.Text.Trim()); cmd.Parameters.AddWithValue("activate", pollactivate.SelectedItem.Value); cmd.Parameters.AddWithValue("polldate", System.DateTime.Now.Date); cmd.ExecuteNonQuery(); con.Close(); success.Text = "Poll Question has been successfully Posted"; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Poll submit method of admin poll for " + Session["loginname"] + ":" + ex.Message); } } }
protected void gridview1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row; row = gridview1.Rows[e.RowIndex]; //this is to get the values from textboxes in edit mode TextBox t1, t2, t3; t1 = (TextBox)row.Cells[3].Controls[0]; t2 = (TextBox)row.Cells[4].Controls[0]; t3 = (TextBox)row.Cells[5].Controls[0]; int eno = Convert.ToInt32(gridview1.DataKeys[e.RowIndex].Value); MySqlCommand cmd = new MySqlCommand("update alumnireg set fname='" + t1.Text + "',lname='" + t2.Text + "',dob='" + t3.Text + "' where regid=" + eno, con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "GridView1_RowUpdating method of Admin_users page for " + Session["loginname"] + ":" + ex.Message); } gridview1.EditIndex = -1; bind_invalid(); }
protected void Page_Load(object sender, EventArgs e) { string uname,code; uname=decodepwd( Request.QueryString["uid"]); code=Request.QueryString["aucode"]; try { con.Open(); cmdmail = new MySqlCommand("update alumnireg set valid_mail=1 where username='******' and auth_code='" + code + "'", con); cmdmail.ExecuteNonQuery(); cmdentry = new MySqlCommand("update login set logentry=2 where username='******'", con); cmdentry.ExecuteNonQuery(); cmdfr = new MySqlCommand("update forum_users set group_id=4 where username='******'", con); cmdfr.ExecuteNonQuery(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("Logs/Errorlog"), "Page_Load method of VerifyMail page :" + ex.Message); } finally { con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { try { con.Open(); cmduser = new MySqlCommand("select login_prev,login_curr from login_hist where login_name='" + Session["loginname"].ToString()+"'" , con); druser = cmduser.ExecuteReader(); druser.Read(); if (druser.IsDBNull(0)) { logdate.Text = druser.GetDateTime("login_curr").ToShortDateString(); logtime.Text = druser.GetDateTime("login_curr").ToShortTimeString(); } else { logdate.Text = druser.GetDateTime("login_prev").ToShortDateString(); logtime.Text = druser.GetDateTime("login_prev").ToShortTimeString(); } druser.Close(); } catch (Exception ex) { CreateLogFile log1 = new CreateLogFile(); log1.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of Admin_Index for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); } }
protected void PollGridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row; row = PollGridView1.Rows[e.RowIndex]; TextBox t, t1, t2, t3, t4, t5; t = (TextBox)row.Cells[2].Controls[0]; t1 = (TextBox)row.Cells[3].Controls[0]; t2 = (TextBox)row.Cells[4].Controls[0]; t3 = (TextBox)row.Cells[5].Controls[0]; t4 = (TextBox)row.Cells[6].Controls[0]; t5 = (TextBox)row.Cells[7].Controls[0]; int eno = Convert.ToInt32(PollGridView1.DataKeys[e.RowIndex].Value); MySqlCommand cmd = new MySqlCommand("update poll set pollquest='" + t.Text + "',opt1='" + t1.Text + "',opt2='" + t2.Text + "',opt3='" + t3.Text + "',opt4='" + t4.Text + "',activate='" + t5.Text + "' where rowid=" + eno, con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "PollGridView RowUpdate method of admin Poll for " + Session["loginname"] + ":" + ex.Message); } PollGridView1.EditIndex = -1; bindpolldata(); }
protected void Page_Load(object sender, EventArgs e) { try { con.Open(); cmduser = new MySqlCommand("select login_prev,login_curr from login_hist where login_name='" + Session["loginname"].ToString() + "'", con); druser = cmduser.ExecuteReader(); druser.Read(); if (druser.IsDBNull(0)) { logdate.Text = druser.GetDateTime("login_curr").ToShortDateString(); logtime.Text = druser.GetDateTime("login_curr").ToShortTimeString(); } else { logdate.Text = druser.GetDateTime("login_prev").ToShortDateString(); logtime.Text = druser.GetDateTime("login_prev").ToShortTimeString(); } druser.Close(); } catch (Exception ex) { CreateLogFile log1 = new CreateLogFile(); log1.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of Admin_Index for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); } }
public void deleterecord(ArrayList ar) { try { con.Open(); foreach (object i in ar) { string str = "delete from alumnireg where regid=" + i + ""; MySqlCommand cmd = new MySqlCommand(str, con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); cmd = new MySqlCommand("delete from login where regid=" + i + "", con); cmd.ExecuteNonQuery(); cmd = new MySqlCommand("delete from forum_users where regid=" + i + "", con); cmd.ExecuteNonQuery(); } con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Delete Record method of Admin_users page for " + Session["loginname"] + ": " + ex.Message); } }
protected void vote_Click1(object sender, EventArgs e) { MySqlCommand cmdvtupdt; int optselect = pollopt.SelectedIndex; if (optselect < 0) { MessageBox.Show("Please select an option..!"); votediv.Style.Add("display", "block"); progbar.Style.Add("display", "none"); } else { try { con.Open(); switch (optselect) { case 0: cmdvtupdt = new MySqlCommand("update poll set res1=res1+1 where pollquest='" + pollquest.Text + "'", con); cmdvtupdt.ExecuteNonQuery(); break; case 1: cmdvtupdt = new MySqlCommand("update poll set res2=res2+1 where pollquest='" + pollquest.Text + "'", con); cmdvtupdt.ExecuteNonQuery(); break; case 2: cmdvtupdt = new MySqlCommand("update poll set res3=res3+1 where pollquest='" + pollquest.Text + "'", con); cmdvtupdt.ExecuteNonQuery(); break; case 3: cmdvtupdt = new MySqlCommand("update poll set res4=res4+1 where pollquest='" + pollquest.Text + "'", con); cmdvtupdt.ExecuteNonQuery(); break; } } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "vote method of Admin_master page for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); pollopt.ClearSelection(); votediv.Style.Add("display", "none"); pollresult(pollquest.Text); } } }
protected void send_Click(object sender, EventArgs e) { MailMessage invite = new MailMessage(); string[] namelist = fri_name.Text.Split(';'); string[] maillist = fri_mail.Text.Split(';'); if (namelist.Length > 5) { errmsg.Text = "Max 5 Names only allowed"; fri_name.Focus(); } else if (maillist.Length > 5) { errmsg.Text = "Max 5 Email ID only allowed"; fri_mail.Focus(); } else { errmsg.Text = ""; try { for (int cnt = 0; cnt < 5; cnt++) { invite.From = new MailAddress(mailfrom, dispname); invite.To.Add(maillist[cnt].Trim()); invite.Subject = "Invite From Friend"; invite.Body = "Dear " + namelist[cnt].Trim() + "," + "<br/>"; invite.Body += "I just wanted to inform you that SSN has come up with an Alumni site.<br/> Thought it would be a good idea if you could look it up."; invite.Body += "<br/>" + "<a href='http://ssnunite.com/index.aspx'>Click here to visit the SSN alumni site</a>" + "<br/><br/><br/>"; invite.Body += "Warm Regards" + "<br/><br/>" + dispname; invite.IsBodyHtml = true; if (!Page.IsPostBack) { SmtpClient mailsend = new SmtpClient(); mailsend.Host = "smtp.gmail.com"; mailsend.Port = 25; mailsend.Credentials = new System.Net.NetworkCredential(mid, mpwd); mailsend.EnableSsl = true; mailsend.Send(invite); } } } catch (SmtpException sx) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "DoSomething('Due to some server problem mail has not been delivered successfully. Please try after sometime. Thank You!!!');</script>", true); CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Send method of Alumni Master for " + Session["loginname"] + ":" + sx.Message); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Send method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } } }
protected void add_adminuser_Click(object sender, EventArgs e) { DateTime regdate = System.DateTime.Now, origin = new DateTime(2000, 1, 1, 0, 0, 0, 0); string time_stamp, ipaddr; TimeSpan stamp; stamp = regdate - origin; time_stamp = stamp.Days.ToString() + stamp.Milliseconds.ToString(); ipaddr = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddr == null) //may be the HTTP_X_FORWARDED_FOR is null { ipaddr = Request.ServerVariables["REMOTE_ADDR"]; //we can use REMOTE_ADDR } try { con.Open(); cmd = new MySqlCommand("insert into forum_users(regid,username,password,email,registration_ip,registered,group_id,title,location) values(@aluid,@name1,password('@pass2'),@mail1,@ip,@reg,@gid,@tile,@loc)", con); cmd.Parameters.AddWithValue("aluid", int.Parse(time_stamp)); if (utype.SelectedIndex == 2) { cmd.Parameters.AddWithValue("name1", "stud_" + admin_name.Text.Trim()); } else { cmd.Parameters.AddWithValue("name1", admin_name.Text.Trim()); } cmd.Parameters.AddWithValue("pass2", admin_pass1.Text.Trim()); cmd.Parameters.AddWithValue("mail1", admin_email.Text.Trim()); cmd.Parameters.AddWithValue("ip", ipaddr); cmd.Parameters.AddWithValue("reg", regdate); cmd.Parameters.AddWithValue("gid", logtype.SelectedItem.Value); if (utype.SelectedIndex == 1) { cmd.Parameters.AddWithValue("tile", cmpname.Text.Trim()); cmd.Parameters.AddWithValue("loc", cmploc.Text.Trim()); } else { cmd.Parameters.AddWithValue("tile", null); cmd.Parameters.AddWithValue("loc", null); } cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "add_adminuser method of Admin_users page for " + Session["loginname"] + ": " + ex.Message); } finally { Response.Redirect("Admin_Users.aspx?sh=view3&t=1#div1"); } }
protected void NewsAdd_Click(object sender, EventArgs e) { string path = "", temp; string[] id; int chk; try { con.Open(); cmd = new MySqlCommand("select max(newsid) from news", con); dr = cmd.ExecuteReader(); dr.Read(); id = dr.GetString("max(newsid)").Split('_'); chk = int.Parse(id[1]) + 1; dr.Close(); if (chk < 10) { temp = "n_0" + chk.ToString(); } else { temp = "n_" + chk.ToString(); } cmd = new MySqlCommand("insert into news(headline,story,name,email,attachpath,newsid) values(@head,@stry,@name,@mail,@path,@nid)", con); cmd.Parameters.AddWithValue("nid", temp); cmd.Parameters.AddWithValue("head", newshead.Text.Trim()); cmd.Parameters.AddWithValue("stry", newsdetail.Value.Trim()); cmd.Parameters.AddWithValue("name", newsname.Text.Trim()); cmd.Parameters.AddWithValue("mail", newsemail.Text.Trim()); if (newsattach.HasFile == false) { path = ""; } else { path = "News/Files/" + newsattach.PostedFile.FileName; } cmd.Parameters.AddWithValue("path", path); cmd.ExecuteNonQuery(); con.Close(); clearbox(); success1.Text = "News has been successfully Posted"; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "News add method of admin news for " + Session["loginname"] + ":" + ex.Message); } }
//this method is to display all the messages for a particular user when logged in protected void showmsg() { string msg_date = ""; DateTime d; int len = 0; try { con.Open(); cmdnews = new MySqlCommand("select msg_from,msg,msg_date from message where msg_from='" + usrname + "' and msg_date >= (select login_prev from login_hist where login_name='" + usrname + "') order by rowid desc", con); drnews = cmdnews.ExecuteReader(); if (drnews.HasRows) { while (drnews.Read()) { len = drnews.GetString("msg").Length; d = Convert.ToDateTime(drnews.GetString("msg_date")); msg_date = GetPrettyDate(d); if (len <= 40) { detboxmsg.Controls.Add(new LiteralControl(" <div id=\"main-feed\" class=\"cfix\"><section id=\"sec\">" + "<div class=\"mini-feed\"><ul><li>" + "<img src=\"../Alumni_images/4.png\" class=\"tweet-avatar\" title=\"mattaussaguel\" height=\"48\" width=\"48\">" + "<span><b style=\"color:#f24c15\">" + drnews.GetString("msg_from") + "</b>: " + drnews.GetString("msg") + "</span><span class=\"tweet-time\">" + msg_date + "</span>" + "</li></ul></div></section></div><br/><br/>")); //detboxmsg.Controls.Add(new LiteralControl("<div class='divmsg'><img src='../images/msgpic.png' alt=''/> <b>" + drnews.GetString("msg_from") + ":</b> " + drnews.GetString("msg") + "<br/>about 1 day ago</div><br />")); } else { detboxmsg.Controls.Add(new LiteralControl(" <div id=\"main-feed\" class=\"cfix\"><section id=\"sec\">" + "<div class=\"mini-feed\"><ul><li>" + "<img src=\"../Alumni_images/4.png\" class=\"tweet-avatar\" title=\"mattaussaguel\" height=\"48\" width=\"48\">" + "<span><b style=\"color:#f24c15\">" + drnews.GetString("msg_from") + "</b>: " + drnews.GetString("msg").Substring(0, 40) + "<br/>" + drnews.GetString("msg").Substring(41) + "</span><span class=\"tweet-time\">" + msg_date + "</span></li></ul></div></section></div><br/><br/>")); //detboxmsg.Controls.Add(new LiteralControl("<div class='divmsg'><img src='../images/msgpic.png' alt=''/> <b>" + drnews.GetString("msg_from") + ":</b> " + drnews.GetString("msg") + "<br/>about 1 day ago</div><br />")); } } } else { detboxmsg.Controls.Add(new LiteralControl("No Messages")); } drnews.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Showmsg method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { evtid = Request.QueryString["eventid"]; if (evtid == null) { evtid = "2"; } try { con.Open(); /* * cmdevents = new MySqlCommand("select rowid,name from events where rowid > 1 order by rowid", con); * drevents = cmdevents.ExecuteReader(); * while (drevents.Read()) * { * HtmlGenericControl li = new HtmlGenericControl("li"); * if (evtid == drevents.GetInt32("rowid").ToString()) * { * li.InnerHtml += "<li class='current1'><a href='AboutSSNAlumni.aspx?eventid=" + drevents.GetInt32("rowid") + "#events'>" + drevents.GetString("name") + "</a></li>"; * } * else * { * li.InnerHtml += "<li><a href='AboutSSNAlumni.aspx?eventid=" + drevents.GetInt32("rowid").ToString() + "#events'>" + drevents.GetString("name") + "</a></li>"; * } * eventlinks.Controls.Add(li); * } * drevents.Close(); */ cmddispevt = new MySqlCommand("select name,detail,img1path,img2path,img3path from events where rowid=" + evtid, con); drdispevt = cmddispevt.ExecuteReader(); drdispevt.Read(); EventHead = drdispevt.GetString("name"); EventStory = drdispevt.GetString("detail"); img1.Src = drdispevt.GetString("img1path") + "thumbs/img1.jpg"; img2.Src = drdispevt.GetString("img2path") + "thumbs/img2.jpg"; img3.Src = drdispevt.GetString("img3path") + "thumbs/img3.jpg"; aimg1.HRef = drdispevt.GetString("img1path") + "slides/img1.jpg"; aimg2.HRef = drdispevt.GetString("img2path") + "slides/img2.jpg"; aimg3.HRef = drdispevt.GetString("img3path") + "slides/img3.jpg"; drdispevt.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("Logs/Errorlog"), "Page Load of Index Master Page:" + ex.Message); } finally { con.Close(); } }
protected void showlist_Click(object sender, EventArgs e) { GridView1.Columns.Clear(); string col = ""; for (int i = 0; i < ListBox2.Items.Count; i++) { BoundField field1 = new BoundField(); field1.DataField = ListBox2.Items[i].Value; if (ListBox2.Items[i].Value == "dob") { field1.DataFormatString = "{0:yyyy-MM-dd}"; } field1.HeaderText = ListBox2.Items[i].Value.Substring(0, 1).ToUpper() + ListBox2.Items[i].Value.Substring(1); field1.SortExpression = ListBox2.Items[i].Value; GridView1.Columns.Add(field1); col += ListBox2.Items[i].Value + ","; } if (!string.IsNullOrEmpty(col)) { exporterr.Visible = false; col = col.Remove(col.Length - 1); try { con.Open(); tquery = "select " + col + " from alumnireg"; MySqlDataAdapter da = new MySqlDataAdapter("select " + col + " from alumnireg", con); //gds = new DataSet(); DataTable dt = new DataTable("table1"); //da.Fill(gds, "alumnireg"); da.Fill(dt); GridView1.DataSource = dt;// gds; GridView1.DataBind(); Cache["table"] = dt; con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "ShowList method of Admin_Misc page for " + Session["loginname"] + ": " + ex.Message); } } else { exporterr.Visible = true; exporterr.Text = "No Records to display"; } }
protected void dgrCongViec_RowCommand(object source, GridViewCommandEventArgs e) { if (e.CommandName == "delete") { try { int id = ConvertUtility.ToInt32(e.CommandArgument); QuanLyCongViecKTXVaPSInfo info = QuanLyCongViecKTXVaPSController.GetInfo(id); if (info == null) { cmdEmpty_Click(null, null); return; } QuanLyCongViecKTXVaPSController.Delete(id, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); int ParentID = ConvertUtility.ToInt32(dropCongViecKPI.SelectedValue); if (ParentID > 0) { UpdateTyTrongCongViecCha(ParentID, info.IsKPI); string oldData = GetObjectInfo(info); #region Log Action LogFileInfo logFileInfo = new LogFileInfo(); logFileInfo.Log_Action = "Delete"; logFileInfo.Log_Type_Object = "QuanLyCongViecKPI"; logFileInfo.Item_CatID = "Cong Viec Thuong Xuyen"; logFileInfo.Item_ID = info.ID.ToString(); logFileInfo.Item_Name = info.Ten; logFileInfo.Description_Before = "Old Data: " + oldData; logFileInfo.Description_After = "Delete KPI with info: <br />" + GetObjectInfo(info); logFileInfo.UserName = CurrentUser.Username; logFileInfo.UserID = CurrentUser.UserID; CreateLogFile.LogAction(logFileInfo); #endregion UpdateCapDoCongViec(); } lblStatusUpdate.Text = MiscUtility.MSG_UPDATE_SUCCESS; } catch (Exception ex) { lblStatusUpdate.Text = ex.Message; } } Session["Nav"] = "1"; }
protected void SendMessage_Click(object sender, EventArgs e) { string frm = Session["loginname"].ToString(); MailMessage mail = new MailMessage(); SmtpClient smtp = new SmtpClient(); try { con.Open(); cmd = new MySqlCommand("insert into message(msg_from,msg_to,msg,msg_date) values(@m1,@m2,@m3,@m4)", con); cmd.Parameters.AddWithValue("m1", frm); cmd.Parameters.AddWithValue("m2", userdet); cmd.Parameters.AddWithValue("m3", string.IsNullOrEmpty(alumsg.Value) ? "No Message" : alumsg.Value); cmd.Parameters.AddWithValue("m4", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); cmd.ExecuteNonQuery(); cmd = new MySqlCommand("select email from forum_users where username='******'", con); dr = cmd.ExecuteReader(); dr.Read(); msg_to = dr.GetString(0); dr.Close(); con.Close(); //To send Notification to the receipent for the message send mail.From = new MailAddress(mid, "Alumni Admin"); mail.To.Add("*****@*****.**");//msg_to); mail.Subject = "Message from " + frm; mail.Body = alumsg.Value + "<br/> To reply please follow this link <a href=\"ssnunite.com/LoginPage.aspx\" target=\"_blank\">www.ssnunite.com</a>"; mail.IsBodyHtml = true; if (!Page.IsPostBack) { smtp.Host = "smtp.gmail.com"; smtp.Port = 25; smtp.Credentials = new System.Net.NetworkCredential(mid, mpwd); smtp.EnableSsl = true; smtp.Send(mail); } } catch (SmtpException sf) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "DoSomething('Your Mail has not been sent.');</script>", true); CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "SendMessage method of AlumniProfileHome page for " + Session["loginname"] + ": " + sf.Message); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "SendMessage method of AlumniProfileHome page for " + Session["loginname"] + ": " + ex.Message); } }
protected void btnCapNhatCVHomTruoc_Click(object sender, EventArgs e) { DateTime dtTime = new DateTime(ConvertUtility.ToInt32(dropYearCopy.SelectedValue), ConvertUtility.ToInt32(dropMonthCopy.SelectedValue), ConvertUtility.ToInt32(dropDayCopy.SelectedValue)); DateTime dtTimeNow = new DateTime(ConvertUtility.ToInt32(dropYear.SelectedValue), ConvertUtility.ToInt32(dropMonth.SelectedValue), ConvertUtility.ToInt32(dropDay.SelectedValue)); DataTable dt = QuanLyCongViecBaoCaoNgayController.GetAllByUserID(ConvertUtility.ToInt32(dropTrungTam.SelectedValue), 0, dtTime, ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue), CurrentUser.UserID); foreach (DataRow item in dt.Rows) { QuanLyCongViecBaoCaoNgayInfo info = new QuanLyCongViecBaoCaoNgayInfo(); info.IDCongViecKPI = ConvertUtility.ToInt32(item["IDCongViecKPI"]); info.Ten = item["Ten"].ToString(); info.KeHoach = item["KeHoach"].ToString(); info.ParentID = item["ParentID"].ToString(); info.TyTrong = ConvertUtility.ToDouble(item["TyTrong"].ToString()); info.KetQua = item["KetQua"].ToString(); info.TyLeHoanThanh = item["TyLeHoanThanh"].ToString(); info.IDTrungTam = ConvertUtility.ToInt32(item["IDTrungTam"].ToString()); info.IDPhongBan = ConvertUtility.ToInt32(item["IDPhongBan"].ToString()); info.IDDotDanhGia = ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue); info.SoGio = ConvertUtility.ToDouble(item["SoGio"].ToString()); info.CreateBy = CurrentUser.UserID; info.LyDo = item["LyDo"].ToString(); info.DeXuat = item["DeXuat"].ToString(); info.CreatedOn = dtTimeNow; try { QuanLyCongViecBaoCaoNgayController.Insert(info); #region Log Action LogFileInfo logFileInfo = new LogFileInfo(); logFileInfo.Log_Action = "Add"; logFileInfo.Log_Type_Object = "QuanLyCongViecKPITheoNgay"; logFileInfo.Item_CatID = "Cong Viec Thuong Xuyen"; logFileInfo.Item_ID = info.ID.ToString(); logFileInfo.Item_Name = info.Ten; logFileInfo.Description_Before = "Old Data: "; logFileInfo.Description_After = "Add KPI with info: <br />" + GetObjectInfo(info); logFileInfo.UserName = CurrentUser.Username; logFileInfo.UserID = CurrentUser.UserID; CreateLogFile.LogAction(logFileInfo); #endregion } catch (Exception ex) { lblStatusUpdate.Text = ex.Message; } } }
protected void cmdDel_Click(object sender, EventArgs e) { try { QuanLyCongViecKTXVaPSInfo info = QuanLyCongViecKTXVaPSController.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info == null) { cmdEmpty_Click(null, null); return; } QuanLyCongViecKTXVaPSController.Delete(ConvertUtility.ToInt32(txtID.Text), ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue)); int ParentID = ConvertUtility.ToInt32(dropCongViecKPI.SelectedValue); if (ParentID > 0) { //UpdateTyTrongCongViecCha(ParentID, info.IsKPI); string oldData = GetObjectInfo(info); #region Log Action LogFileInfo logFileInfo = new LogFileInfo(); logFileInfo.Log_Action = "Delete"; logFileInfo.Log_Type_Object = "QuanLyCongViecKPI"; logFileInfo.Item_CatID = "Cong Viec Phat Sinh"; logFileInfo.Item_ID = info.ID.ToString(); logFileInfo.Item_Name = info.Ten; logFileInfo.Description_Before = "Old Data: " + oldData; logFileInfo.Description_After = "Delete KPI with info: <br />" + GetObjectInfo(info); logFileInfo.UserName = CurrentUser.Username; logFileInfo.UserID = CurrentUser.UserID; CreateLogFile.LogAction(logFileInfo); #endregion UpdateCapDoCongViec(); } lblStatusUpdate.Text = MiscUtility.MSG_UPDATE_SUCCESS; } catch (Exception ex) { lblStatusUpdate.Text = ex.Message; } Session["Nav"] = "3"; }
protected void Page_Load(object sender, EventArgs e) { int cnt = 1; try { event_id = Request.QueryString["evtid"]; con.Open(); cmd = new MySqlCommand("select name,img1path from events where evt_id='" + event_id + "'", con); dr = cmd.ExecuteReader(); if (dr.Read()) { imgpath = "../" + dr.GetString("img1path"); HiddenField1.Value = imgpath; header1.Text = dr.GetString("name").Substring(0, 1).ToUpper() + dr.GetString("name").Substring(1).ToLower(); DirectoryInfo files = new DirectoryInfo(Server.MapPath(imgpath + "thumbs/")); FileInfo[] f = files.GetFiles(); foreach (FileInfo temp in f) { LiteralControl imgfile = new LiteralControl("<!-- start entry-->" + "<div class='thumbnailimage'><div class='thumb_container'><div class='large_thumb'>" + "<img src='" + imgpath + "slides/" + temp.Name + "' class='large_thumb_image' alt='thumb' />" + "<img src='" + imgpath + "slides/" + temp.Name + "' class='large_image' rel='Image-" + cnt++ + "' />" + "<div class='large_thumb_border'></div><div class='large_thumb_shine'></div></div></div></div>" + "<!--end entry-->"); showimgs.Controls.Add(imgfile); } } else { everr.Visible = true; } dr.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "page load method of Eventlist page for " + Session["loginname"] + ":" + ex.Message); } }
protected void sendmail(object temp) { MySqlCommand cmdmail; MySqlDataReader drmail; MailMessage mail = new MailMessage(); string msgbody, encodeuser; try { cmdmail = new MySqlCommand("select email,username from alumnireg where regid=" + temp, con); drmail = cmdmail.ExecuteReader(); drmail.Read(); mail.From = new MailAddress("*****@*****.**", "Alumni Admin"); mail.To.Add(drmail.GetString("email")); mail.Subject = "Registration Details Approved"; encodeuser = drmail.GetString("username"); msgbody = "Dear Alumni," + "<br/><br/>Your registeration details have being verified and approved by the alumni officer successfully. You can now login into the site by clicking the link below.<br/><br/>Your Username is : " + encodeuser; msgbody += "<br/><br/><a href='http://ssnunite.com/LoginPage.aspx' target='_blank'>Click this link to Login into the site</a>" + "<br/><br/>Thank you"; mail.Body = msgbody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); if (!Page.IsPostBack) { smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Port = 25; smtp.Credentials = new System.Net.NetworkCredential(mid, mpwd); smtp.EnableSsl = true; smtp.Send(mail); } drmail.Close(); } catch (SmtpException sx) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Send Mail method of Admin_users page for " + Session["loginname"] + ":" + sx.Message); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Send Mail method of Admin_users page for " + Session["loginname"] + ": " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { int cnt=1; try { event_id = Request.QueryString["evtid"]; con.Open(); cmd = new MySqlCommand("select name,img1path from events where evt_id='" + event_id + "'", con); dr = cmd.ExecuteReader(); if (dr.Read()) { imgpath = "../" + dr.GetString("img1path"); HiddenField1.Value = imgpath; header1.Text = dr.GetString("name").Substring(0, 1).ToUpper() + dr.GetString("name").Substring(1).ToLower(); DirectoryInfo files = new DirectoryInfo(Server.MapPath(imgpath + "thumbs/")); FileInfo[] f = files.GetFiles(); foreach (FileInfo temp in f) { LiteralControl imgfile =new LiteralControl("<!-- start entry-->" +"<div class='thumbnailimage'><div class='thumb_container'><div class='large_thumb'>" +"<img src='"+ imgpath + "slides/" + temp.Name +"' class='large_thumb_image' alt='thumb' />" +"<img src='"+ imgpath + "slides/" + temp.Name +"' class='large_image' rel='Image-"+cnt+++"' />" +"<div class='large_thumb_border'></div><div class='large_thumb_shine'></div></div></div></div>" +"<!--end entry-->"); showimgs.Controls.Add(imgfile); } } else { everr.Visible = true; } dr.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "page load method of Eventlist page for " + Session["loginname"] + ":" + ex.Message); } }
protected void pollresult(string quest) { MySqlCommand cmdpollres; MySqlDataReader drpollres; try { progbar.Style.Add("display", "block"); con.Open(); if (quest == null) { cmdpollres = new MySqlCommand("select opt1,opt2,opt3,opt4,res1,res2,res3,res4,pollquest from poll order by rowid desc LIMIT 1", con); } else { cmdpollres = new MySqlCommand("select opt1,opt2,opt3,opt4,res1,res2,res3,res4,pollquest from poll where pollquest='" + quest + "'", con); } drpollres = cmdpollres.ExecuteReader(); drpollres.Read(); per1 = drpollres.GetInt32("res1").ToString() + "%"; per2 = drpollres.GetInt32("res2").ToString() + "%"; per3 = drpollres.GetInt32("res3").ToString() + "%"; per4 = drpollres.GetInt32("res4").ToString() + "%"; percent1.Style.Add("width", drpollres.GetInt32("res1") + "%"); percent2.Style.Add("width", drpollres.GetInt32("res2") + "%"); percent3.Style.Add("width", drpollres.GetInt32("res3") + "%"); percent4.Style.Add("width", drpollres.GetInt32("res4") + "%"); ans1 = drpollres.GetString("opt1"); ans2 = drpollres.GetString("opt2"); ans3 = drpollres.GetString("opt3"); ans4 = drpollres.GetString("opt4"); drpollres.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Poll Result method of Admin_master page for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); } }
protected void changePassword_Click(object sender, EventArgs e) { try { con.Open(); cmd = new MySqlCommand("update forum_users set password=password(@pass) where username='******'", con); cmd.Parameters.AddWithValue("pass", confpass.Text.Trim()); cmd.ExecuteNonQuery(); con.Close(); Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "DoSomething('Password has been changed successfully.');</script>", true); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Change Password method of Changepassword page for " + Session["loginname"] + ":"+ex.Message); } }
protected void advanceopt_Click(object sender, EventArgs e) { string vis = ""; vis = (num_visi.SelectedIndex == 0) ? "1" + ((addr_visi.SelectedIndex == 0) ? "1" : "2") : "2" + ((addr_visi.SelectedIndex == 0) ? "1" : "2"); MySqlCommand cmd = new MySqlCommand("update alumnireg set visibility='"+vis+"' where username='******'", con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "advanceopt method of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", "showadv();", true); }
protected void Page_Load(object sender, EventArgs e) { List<string> list = new List<string>(); if (!Page.IsPostBack) { try { con.Open(); cmd = new MySqlCommand("select headline,story,name,newsid from news", con); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { string lt; string newsstry = (dr.GetString("story").Length > 50) ? dr.GetString("story").Substring(0, 100) : dr.GetString("story").Substring(0, 10); lt = "<h2 style='font-size:23px' 'title'><a title='" + dr.GetString("headline").Substring(0, 1).ToUpper() + dr.GetString("headline").Substring(1).ToLower() + "' href='#'>" + dr.GetString("headline").Substring(0, 1).ToUpper() + dr.GetString("headline").Substring(1).ToLower() + "</a></h2>"; lt += "<p style='text-align: justify;'>" + newsstry + "..</p>"; lt += "<img src='../images/read_more.png'/><a href='NewsRead.aspx?news_id=" + dr.GetString("newsid") + "'>Read more</a><br/><br/><hr class='dash'/>"; list.Add(lt); } dr.Close(); con.Close(); Repeater1.DataSource = list; Repeater1.DataBind(); } else { nerr.Visible = true; } } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page load method of News page for " + Session["loginname"] + ":" + ex.Message); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ver_id = string.IsNullOrEmpty(Request.QueryString["tst_id"])?0:int.Parse(Request.QueryString["tst_id"]); try { //this code is to change the image path according to forum id for a user con.Open(); cmdsent = new MySqlCommand("select id from forum_users where regid=" + ver_id, con); dr = cmdsent.ExecuteReader(); dr.Read(); oldpath = "Alumni_Images/" + ver_id + ".png"; if (File.Exists(Server.MapPath(oldpath))) { newpath = "Alumni_Images/" + dr.GetInt32("id") + ".png"; File.Copy(Server.MapPath(oldpath), Server.MapPath(newpath)); File.Delete(Server.MapPath(oldpath)); } else { newpath = ""; } dr.Close(); cmdsent = new MySqlCommand("update alumnireg set imgpath='" + newpath + "' where regid=" + ver_id, con); cmdsent.ExecuteNonQuery(); con.Close(); if (ver_id != 0) { verify_details(); } } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("Logs/Errorlog"), "Page Load method of RegisterSuccess page for " +ver_id+":"+ ex.Message); } } }
protected string decodepwd(string depas) { try { System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); System.Text.Decoder utf8Decode = encoder.GetDecoder(); byte[] todecode_byte = Convert.FromBase64String(depas); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); string result = new String(decoded_char); return result; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("Logs/Errorlog"), "Decode method of VerifyMail page :" + ex.Message); return "conversion error"; } }
protected void Page_Load(object sender, EventArgs e) { List<string> list=new List<string>(); if (!Page.IsPostBack) { try { con.Open(); cmd = new MySqlCommand("select img1path,name,evt_id from events where rowid not in (2)", con); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { string lt; lt = "<img src='../" + dr.GetString("img1path") + "slides/img1.jpg' height='150' width='220'/><br/>"; lt += "<a href='EventList.aspx?evtid=" + dr.GetString("evt_id") + "'>" + dr.GetString("name") + "</a>"; list.Add(lt); } dr.Close(); con.Close(); eventslist.DataSource = list; eventslist.DataBind(); } else { err.Visible = true; } } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of Event Gallery page for " + Session["loginname"] + ":" + ex.Message); } } }
protected void Add_Stud_Click(object sender, EventArgs e) { string date; if (sday.SelectedIndex == 0 || smon.SelectedIndex == 0 || syr.SelectedIndex == 0) { doberr.Visible = true; doberr.Text = "Please select correct Date Format"; } else { date=syr.SelectedItem.Value+"-"+smon.SelectedItem.Value+"-"+sday.SelectedItem.Value; doberr.Text = ""; try { con.Open(); cmdadd = new MySqlCommand("insert into forum_users(group_id,username,password,registered,doj,branch) values(@gid,@uname,password('@pass'),@regdate,@join,@bat)", con); cmdadd.Parameters.AddWithValue("@gid", 3); cmdadd.Parameters.AddWithValue("@uname", name.Text.Trim()); cmdadd.Parameters.AddWithValue("@pass", pass.Text.Trim()); cmdadd.Parameters.AddWithValue("@regdate", System.DateTime.Now); cmdadd.Parameters.AddWithValue("@join", date); cmdadd.Parameters.AddWithValue("@bat", mybranch); cmdadd.ExecuteNonQuery(); con.Close(); msg.Text = "Student added Successfully"; } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"),"Add Stud method of Stud_add Page for " + Session["loginname"] + ":"+ex.Message); } } }
protected void Page_Load(object sender, EventArgs e) { string name; try { name=Session["loginname"].ToString(); con.Open(); cmduser = new MySqlCommand("select login_date,login_time from login_hist where rowid=(select max(rowid)-1 from login_hist where login_name='" + name + "')", con); druser = cmduser.ExecuteReader(); if (druser.Read()) { logdate.Text = druser.GetDateTime("login_date").ToShortDateString(); logtime.Text = druser.GetString("login_time"); } else { logdate.Text = "0000-00-00"; logtime.Text = "00:00:00"; } druser.Close(); //to count the number of student registered cmduser = new MySqlCommand("select count(username) from forum_users where branch=(select branch from forum_users where username='******'))",con); druser = cmduser.ExecuteReader(); druser.Read(); studcnt.Text = string.IsNullOrEmpty(druser.GetInt32(0).ToString()) ? "0" : druser.GetInt32(0).ToString(); druser.Close(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load of HeaderFooter Page for " + Session["loginname"] + ":" + ex.Message); } }
//this is for displaying batchmate list protected void showbatchmate(int batyear) { row = 0; temp = 0; names.Clear(); nameid.Clear(); //batchyear.SelectedValue =batyear.ToString(); try { con.Open(); cmdbatch = new MySqlCommand("select f.username,f.id from forum_users f,alumnireg n where n.batch=" + batyear + " and f.username=n.username and n.branch='"+ubranch+"' and f.username NOT IN ('" + usrname + "')", con); drbatch = cmdbatch.ExecuteReader(); if (drbatch.HasRows) { //read all the name's and id's of that batch while (drbatch.Read()) { names.Add(drbatch.GetString("username")); nameid.Add(drbatch.GetInt32("id")); } //generate photo of those names who are in the batch while (temp < names.Count) { tr = new HtmlTableRow(); for (int col = 0; col < 4; col++) { td = new HtmlTableCell(); if (!File.Exists(Server.MapPath(imgpath + nameid[row] + ".png"))) { td.Controls.Add(new LiteralControl("<figure><a title='"+names[row]+"' href='AlumniProfHome.aspx?vid=" +encodepwd(names[row]) + "&myid=" + nameid[row] + "&toid=" + rid + "'><img src='../images/nophoto.jpg' height='30' width='25' /></a></figure>")); } else { td.Controls.Add(new LiteralControl("<figure><a title='" + names[row] + "' href='AlumniProfHome.aspx?vid=" + encodepwd(names[row]) + "&myid=" + nameid[row] + "&toid=" + rid + "'><img src='../Alumni_Images/" + nameid[row] + ".png' height='30' width='25' /></a></figure>")); } tr.Controls.Add(td); row++; if (row > names.Count - 1) { break; } } temp = row; batchmate.Rows.Add(tr); } batchmsg.Visible = false; sectiontab1.Style.Add("display", "block"); } else { batchmsg.Visible = true; sectiontab1.Style.Add("display", "none"); } drbatch.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Show Batchmate method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } }
protected void editimage_Click(object sender, EventArgs e) { string filename = "", path, qry = "", type = Path.GetExtension(FileUpload1.PostedFile.FileName); HttpPostedFile imgfile = FileUpload1.PostedFile; if (type == "") { photo.Text = "<font color='red'>Please Upload an Image..</font>"; } else if (imgfile.ContentLength > 1048576)//file size must be less than 1mb { photo.Text = "<font color='red'>Image size must be less than 1 mb..</font>"; } else { try { con.Open(); cmduser = new MySqlCommand("select imgpath from alumnireg where regid=" + urowid, con); druser = cmduser.ExecuteReader(); druser.Read(); if (druser.IsDBNull(0) || string.IsNullOrEmpty(druser.GetString("imgpath"))) { qry = "update alumnireg set imgpath='Alumni_Images/" + rid + ".png' where regid=" + urowid; filename = "Alumni_Images/" + rid + ".png"; path = Server.MapPath("../"+filename); } else { filename = druser.GetString("imgpath"); path = Server.MapPath("../" + filename); qry = "update alumnireg set imgpath='" + filename + "' where regid=" + urowid; } GenerateThumbnails(FileUpload1.PostedFile.InputStream, path); //FileUpload1.PostedFile.SaveAs(path); druser.Close(); if (qry != "") { cmduser = new MySqlCommand(qry, con); cmduser.ExecuteNonQuery(); } con.Close(); userimg.Src = filename; Response.Redirect("AlumniProfHome.aspx"); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Edit Image method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "OnLoad", "showme();", true); }
protected void SendMail_Click(object sender, EventArgs e) { string path = "", mid = ConfigurationManager.AppSettings["mailid"], mpwd = ConfigurationManager.AppSettings["mailpwd"]; MailMessage mail = new MailMessage(); mail.From = new MailAddress(mailfrom, maildispname+"- SSN Alumni"); mail.ReplyToList.Add(new MailAddress(mailfrom)); // to add multiple To email id's if (msgto.Text.Contains(";")) { string[] str = msgto.Text.Split(';'); for (int i = 0; i < str.Length; i++) if (str[i] != String.Empty) mail.To.Add(str[i]); } else { mail.To.Add(msgto.Text.Trim()); } // mail subject mail.Subject = msgsub.Text.Trim(); // to add multiple BCC email id's if (msgbcc.Text != "") { if (msgbcc.Text.Contains(";")) { string[] str = msgbcc.Text.Split(';'); for (int i = 0; i < str.Length; i++) if (str[i] != String.Empty) mail.Bcc.Add(str[i]); } else { mail.Bcc.Add(msgbcc.Text.Trim()); } } // to add multiple CC email id's if (msgcc.Text != "") { if (msgcc.Text.Contains(";")) { string[] str1 = msgcc.Text.Split(';'); for (int i = 0; i < str1.Length; i++) if (str1[i] != String.Empty) mail.CC.Add(str1[i]); } else { mail.CC.Add(msgcc.Text.Trim()); } } mail.IsBodyHtml = true; // mail body if (msgbody.Text != "") { mail.Body = "Hai," + "<br/> " + msgbody.Text.Trim(); } //file attachments to mail HttpFileCollection uploads = HttpContext.Current.Request.Files; if (uploads.Count > 0) { for (int i = 0; i < uploads.Count; i++) { HttpPostedFile upload = uploads[i]; if (uploads[i].ContentLength > 0) { string c = Path.GetFileName(upload.FileName); path = Server.MapPath("MailUploadedFiles/") + c; upload.SaveAs(path); mail.Attachments.Add(new Attachment(path)); } } } // mail.IsBodyHtml = true; try { SmtpClient smtp = new SmtpClient(); if (!Page.IsPostBack) { smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Port = 25; smtp.Credentials = new System.Net.NetworkCredential(mid, mpwd); smtp.EnableSsl = true; smtp.Send(mail); } Response.Redirect("AlumniProfHome.aspx"); } catch (Exception sx) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Send Mail of Email Page for " + Session["loginname"] + ":" + sx.Message); } }
protected void Submit_prof_Click(object sender, EventArgs e) { try { con.Open(); cmdper = new MySqlCommand("update alumnireg set role=@urole, fname=@firname,lname=@lstname,gender=@gen,dob=@birth,email=@mail,batch=@bat,degree=@deg,branch=@bran,city=@ucity,state=@ustate,country=@cntry,address=@add1,number=@num where username='******'",con); cmdper.Parameters.AddWithValue("@urole",alu_role.Text); cmdper.Parameters.AddWithValue("@firname", alu_fname.Text); cmdper.Parameters.AddWithValue("@lstname", alu_lname.Text); cmdper.Parameters.AddWithValue("@gen", alu_gender.SelectedItem.Value); cmdper.Parameters.AddWithValue("@birth", alu_dob.Text); cmdper.Parameters.AddWithValue("@mail", alu_email.Text); cmdper.Parameters.AddWithValue("@bran", alu_branch.SelectedItem.Value); cmdper.Parameters.AddWithValue("@deg", alu_degree.SelectedItem.Value); cmdper.Parameters.AddWithValue("@bat", alu_batch.SelectedItem.Value); cmdper.Parameters.AddWithValue("@ucity", alu_city.Text); cmdper.Parameters.AddWithValue("@ustate", alu_state.Text); cmdper.Parameters.AddWithValue("@cntry", alu_country.SelectedItem.Value); cmdper.Parameters.AddWithValue("@add1", alu_addr.Text); cmdper.Parameters.AddWithValue("@num", alu_number.Text); cmdper.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit Prof of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void Submit_other_Click(object sender, EventArgs e) { try { con.Open(); cmdother=new MySqlCommand("update alumnireg set aboutme=@me,ssnmoment=@mnt,hobby=@hob,music=@mus,movies=@mov where username='******'",con); cmdother.Parameters.AddWithValue("@me",other_myself.Text); cmdother.Parameters.AddWithValue("@mnt",other_moment.Text); cmdother.Parameters.AddWithValue("@hob",other_hobby.Text); cmdother.Parameters.AddWithValue("@mus",other_music.Text); cmdother.Parameters.AddWithValue("@mov",other_movie.Text); cmdother.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit other of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void Submit_edu_Click(object sender, EventArgs e) { string instname = alu_inst.Text + "/" + alu_inst1.Text + "/" + alu_inst2.Text + "/" + alu_inst3.Text; string instloc = alu_iloc.Text + "/" + alu_iloc1.Text + "/" + alu_iloc2.Text + "/" + alu_iloc3.Text; string instcourse = ((alu_course.SelectedIndex == 0) ? "" : alu_course.SelectedItem.Value) + "/" + ((alu_course1.SelectedIndex == 0) ? "" : alu_course1.SelectedItem.Value) + "/" + ((alu_course2.SelectedIndex == 0) ? "" : alu_course2.SelectedItem.Value) + "/" + ((alu_course3.SelectedIndex == 0) ? "" : alu_course3.SelectedItem.Value); string instyr = alu_passyr.Text + "/" + alu_passyr1.Text + "/" + alu_passyr2.Text + "/" + alu_passyr3.Text; try { con.Open(); cmdedu = new MySqlCommand("update alumnireg set inst_name=@iname,inst_course=@sub,inst_loc=@loca,inst_passyr=@yr where username='******'", con); cmdedu.Parameters.AddWithValue("@iname",instname); cmdedu.Parameters.AddWithValue("@sub", instcourse); cmdedu.Parameters.AddWithValue("@loca", instloc); cmdedu.Parameters.AddWithValue("@yr", instyr); cmdedu.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit education method of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { user = Session["loginname"].ToString(); if (!Page.IsPostBack) { //to show months and years in worktab showmon(); showyr(); con.Open(); cmdprof = new MySqlCommand("select * from alumnireg where username='******'", con); drprof = cmdprof.ExecuteReader(); drprof.Read(); num_visi.SelectedIndex = drprof.GetString("visibility").Substring(0, 1) == "1" ? 0 : 1; addr_visi.SelectedIndex = drprof.GetString("visibility").Substring(1, 1) == "1" ? 0 : 1; alu_role.Text = drprof.GetString("role"); alu_fname.Text = drprof.GetString("fname"); alu_lname.Text = drprof.GetString("lname"); alu_gender.Text = drprof.GetString("gender"); alu_email.Text = drprof.GetString("email"); DateTime dt = Convert.ToDateTime(drprof.GetString("dob")); alu_dob.Text = dt.ToString("yyyy-MM-dd"); alu_batch.Text = drprof.GetInt32("batch").ToString(); alu_degree.Text = drprof.GetString("degree"); alu_branch.Text = drprof.GetString("branch"); alu_country.Text = drprof.GetString("country"); alu_state.Text = drprof.GetString("state"); alu_city.Text = drprof.GetString("city"); alu_number.Text = drprof.GetString("number"); alu_addr.Text = drprof.GetString("address"); other_hobby.Text = string.IsNullOrEmpty(drprof["hobby"].ToString()) ? "-" : drprof.GetString("hobby"); other_moment.Text = string.IsNullOrEmpty(drprof["ssnmoment"].ToString()) ? "-" : drprof.GetString("ssnmoment"); other_movie.Text = string.IsNullOrEmpty(drprof["movies"].ToString()) ? "-" : drprof.GetString("movies"); other_music.Text = string.IsNullOrEmpty(drprof["music"].ToString()) ? "-" : drprof.GetString("music"); other_myself.Text = string.IsNullOrEmpty(drprof["aboutme"].ToString()) ? "-" : drprof.GetString("aboutme"); string[] instname = string.IsNullOrEmpty(drprof["inst_name"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("inst_name").Split('/'); string[] instloc = string.IsNullOrEmpty(drprof["inst_loc"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("inst_loc").Split('/'); string[] instcourse = string.IsNullOrEmpty(drprof["inst_course"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("inst_course").Split('/'); string[] instyr = string.IsNullOrEmpty(drprof["inst_passyr"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("inst_passyr").Split('/'); alu_inst.Text = instname[0]; alu_inst1.Text = instname[1]; alu_inst2.Text = instname[2]; alu_inst3.Text = instname[3]; alu_iloc.Text = instloc[0]; alu_iloc1.Text = instloc[1]; alu_iloc2.Text = instloc[2]; alu_iloc3.Text = instloc[3]; alu_course.Text = instcourse[0]; alu_course1.Text = instcourse[1]; alu_course2.Text = instcourse[2]; alu_course3.Text = instcourse[3]; alu_passyr.Text = instyr[0]; alu_passyr1.Text = instyr[1]; alu_passyr2.Text = instyr[2]; alu_passyr3.Text = instyr[3]; string[] cmname = string.IsNullOrEmpty(drprof["org"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("org").Split('/'); string[] cmdesig = string.IsNullOrEmpty(drprof["desig"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("desig").Split('/'); string[] cmloc = string.IsNullOrEmpty(drprof["cmploc"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("cmploc").Split('/'); cyears= string.IsNullOrEmpty(drprof["expyrs"].ToString()) ? new string[] { "-", "-", "-", "-" } : drprof.GetString("expyrs").Split('/'); cmp1.Text = cmname[0]; cmp2.Text = cmname[1]; cmp3.Text = cmname[2]; cmp4.Text = cmname[3]; desig1.Text = cmdesig[0]; desig2.Text = cmdesig[1]; desig3.Text = cmdesig[2]; desig4.Text = cmdesig[3]; loc1.Text = cmloc[0]; loc2.Text = cmloc[1]; loc3.Text = cmloc[2]; loc4.Text = cmloc[3]; drprof.Close(); } } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of AlumniProfile for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); } }
protected void Loginbutton_Click(object sender, EventArgs e) { string loginhist_name = ""; try { user = loginid.Text; //opening the connection con.Open(); //to get group_id and differentiate user login -> alumni / student / admin cmd1 = new MySqlCommand("select f.group_id from forum_users f where username='******' or f.email='"+user+"'",con); drpass1 = cmd1.ExecuteReader(); if (!drpass1.Read()) { loginerr.Text = "<font color='red'>Invalid User/Password..Please Sign Up</font>"; loginid.Text = ""; loginpwd.Text = ""; loginid.Focus(); } else { getid = drpass1.GetInt32("group_id"); } drpass1.Close(); //this code gets executed when user is alumni only if (getid==4) { //to check whether loginame is an usrname or email cmd = new MySqlCommand("select l.logentry,f.password,f.username from login l,forum_users f where (f.username='******' or f.email='" + user + "') and l.username=f.username and l.role='Alumni' and f.group_id=4 and f.password=password('" + loginpwd.Text.Trim() + "')", con); drpass = cmd.ExecuteReader(); //if user not registered then error is displayed if (!drpass.Read()) { loginerr.Text = "<font color='red'>Invalid User/Password..Please Sign Up</font>"; loginid.Text = ""; loginpwd.Text = ""; loginid.Focus(); } else {//if login is successfull redirect to correct url loginerr.Text = ""; Session["loginname"] = loginhist_name = drpass.GetString("username"); entrypass = drpass.GetInt32("logentry"); string urlid = Request.QueryString["urlid"]; switch (urlid) { case "sh": url = "Search Alumni/SearchAlumni.aspx"; break; case "fm": url = "http://ssnunite.com/PeopleTalk"; break; case "jb": url = "http://ssnunite.com/job"; break; case "pf": url = "AlumniPages/AlumniProfHome.aspx?vid=" + Request.QueryString["visitid"] + "&myid=" + Request.QueryString["myid"]; break; default: url = "AlumniPages/AlumniHome.aspx"; break; } drpass.Close(); //if alumni has permission to enter into site if (entrypass == 2) { cmd1 = new MySqlCommand("select * from login_hist where login_name='" + loginhist_name + "'",con); drpass2 = cmd1.ExecuteReader(); if (drpass2.HasRows) { //to update login history table for a user cmnd="update login_hist set login_prev=login_curr,login_curr=@logcur where login_name=@logname"; } else { //to insert the login date and time for a particular user to maintain login history cmnd="insert into login_hist(login_name,login_curr) values(@logname,@logcur)"; } drpass2.Close(); cmdloghist=new MySqlCommand(cmnd,con); cmdloghist.Parameters.AddWithValue("@logname", loginhist_name); cmdloghist.Parameters.AddWithValue("@logcur",DateTime.Now.Date+ DateTime.Now.TimeOfDay); cmdloghist.ExecuteNonQuery(); con.Close(); if (!string.IsNullOrEmpty(url)) { Response.Redirect(url); } } //if no validate by admin then redirect to invalid login page else { Response.Redirect("InvalidLogin.aspx?prevpage=" + Request.UrlReferrer); } /*entrypass condition finishes here*/ } } //this code gets executed when user is admin / power admin else if (getid == 1) { cmd = new MySqlCommand("select f.password from forum_users f where f.username='******' and f.group_id=1 and f.password=password('" + loginpwd.Text.Trim() + "')", con); drpass = cmd.ExecuteReader(); //if user not registered then error is displayed if (!drpass.Read()) { loginerr.Text = "<font color='red'>Invalid Admin / Password.</font>"; loginid.Text = ""; loginpwd.Text = ""; loginid.Focus(); } else { Session["loginname"] = user; drpass.Close(); cmd = new MySqlCommand("select * from login_hist where login_name=@name", con); cmd.Parameters.AddWithValue("@name", user); drpass = cmd.ExecuteReader(); if (drpass.HasRows) { cmnd = "update login_hist set login_prev=login_curr,login_curr=@logcur where login_name=@logname"; } else { //to insert the login date and time for a particular user to maintain login history cmdloghist = new MySqlCommand("insert into login_hist(login_name,login_curr) values(@logname,@logcur)", con); } drpass.Close(); cmdloghist = new MySqlCommand(cmnd, con); cmdloghist.Parameters.AddWithValue("@logname",user); cmdloghist.Parameters.AddWithValue("@logcur", DateTime.Now.Date + DateTime.Now.TimeOfDay); cmdloghist.ExecuteNonQuery(); Response.Redirect("Admin_Pages/Admin_index.aspx"); } } //this code gets executed when user is guest else if (getid == 3) { loginerr.Text = "<font color='red'>Invalid Login. Guest Login not available.</font>"; loginid.Text = ""; loginpwd.Text = ""; loginid.Focus(); } con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("Logs/Errorlog"), "Login method of Login Page:" + ex.Message); } }
//this method is to display all the messages for a particular user when logged in protected void showmsg() { string msg_date=""; DateTime d; int len = 0; try { con.Open(); cmdnews = new MySqlCommand("select msg_from,msg,msg_date from message where msg_from='" + usrname + "' and msg_date >= (select login_prev from login_hist where login_name='"+usrname+"') order by rowid desc", con); drnews = cmdnews.ExecuteReader(); if (drnews.HasRows) { while (drnews.Read()) { len = drnews.GetString("msg").Length; d=Convert.ToDateTime(drnews.GetString("msg_date")); msg_date =GetPrettyDate(d); if (len <= 40) { detboxmsg.Controls.Add(new LiteralControl(" <div id=\"main-feed\" class=\"cfix\"><section id=\"sec\">" + "<div class=\"mini-feed\"><ul><li>" + "<img src=\"../Alumni_images/4.png\" class=\"tweet-avatar\" title=\"mattaussaguel\" height=\"48\" width=\"48\">" + "<span><b style=\"color:#f24c15\">" + drnews.GetString("msg_from") + "</b>: " + drnews.GetString("msg") + "</span><span class=\"tweet-time\">"+msg_date+"</span>" +"</li></ul></div></section></div><br/><br/>")); //detboxmsg.Controls.Add(new LiteralControl("<div class='divmsg'><img src='../images/msgpic.png' alt=''/> <b>" + drnews.GetString("msg_from") + ":</b> " + drnews.GetString("msg") + "<br/>about 1 day ago</div><br />")); } else { detboxmsg.Controls.Add(new LiteralControl(" <div id=\"main-feed\" class=\"cfix\"><section id=\"sec\">" + "<div class=\"mini-feed\"><ul><li>" + "<img src=\"../Alumni_images/4.png\" class=\"tweet-avatar\" title=\"mattaussaguel\" height=\"48\" width=\"48\">" + "<span><b style=\"color:#f24c15\">" + drnews.GetString("msg_from") + "</b>: " + drnews.GetString("msg").Substring(0,40) +"<br/>" + drnews.GetString("msg").Substring(41) + "</span><span class=\"tweet-time\">"+msg_date+"</span></li></ul></div></section></div><br/><br/>")); //detboxmsg.Controls.Add(new LiteralControl("<div class='divmsg'><img src='../images/msgpic.png' alt=''/> <b>" + drnews.GetString("msg_from") + ":</b> " + drnews.GetString("msg") + "<br/>about 1 day ago</div><br />")); } } } else { detboxmsg.Controls.Add(new LiteralControl("No Messages")); } drnews.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Showmsg method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } }
protected void Submit_work_Click(object sender, EventArgs e) { string cmpname = cmp1.Text + "/" + cmp2.Text + "/" + cmp3.Text + "/" + cmp4.Text ; string cmpdsg = desig1.Text + "/" + desig2.Text + "/" + desig3.Text + "/" + desig4.Text; string cmploc = loc1.Text + "/" + loc2.Text + "/" + loc3.Text + "/" + loc4.Text; string cmpyrs =""; string[] cyears=new string[] { "-", "-", "-", "-" }; DateTime dt1, dt2; TimeSpan ts; try { if (fmon1.SelectedIndex == 0 || fyear1.SelectedIndex == 0 || tmon1.SelectedIndex == 0 || tyear1.SelectedIndex == 0 || string.Compare(fyear1.SelectedItem.Value, tyear1.SelectedItem.Value) > 0) { cmpyrs = cyears[0] + "/" + cyears[1] + "/" + cyears[2] + "/" + cyears[3]; } else { dt1 = Convert.ToDateTime(fyear1.SelectedItem.Value + "-" + fmon1.SelectedItem.Value); dt2 = Convert.ToDateTime(tyear1.SelectedItem.Value + "-" + tmon1.SelectedItem.Value); ts = dt2 - dt1; cyears[0] = Math.Round(Convert.ToDecimal(Math.Abs(ts.Days)) / 30, 0).ToString(); } if (fmon2.SelectedIndex == 0 || fyear2.SelectedIndex == 0 || tmon2.SelectedIndex == 0 || tyear2.SelectedIndex == 0 || string.Compare(fyear2.SelectedItem.Value, tyear2.SelectedItem.Value) > 0) { cmpyrs = cyears[0] + "/" + cyears[1] + "/" + cyears[2] + "/" + cyears[3]; } else { dt1 = Convert.ToDateTime(fyear2.SelectedItem.Value + "-" + fmon2.SelectedItem.Value); dt2 = Convert.ToDateTime(tyear2.SelectedItem.Value + "-" + tmon2.SelectedItem.Value); ts = dt2 - dt1; cyears[1] = Math.Round(Convert.ToDecimal(Math.Abs(ts.Days)) / 30, 0).ToString(); } if (fmon3.SelectedIndex == 0 || fyear3.SelectedIndex == 0 || tmon3.SelectedIndex == 0 || tyear3.SelectedIndex == 0 || string.Compare(fyear3.SelectedItem.Value, tyear3.SelectedItem.Value) > 0) { cmpyrs = cyears[0] + "/" + cyears[1] + "/" + cyears[2] + "/" + cyears[3]; } else { dt1 = Convert.ToDateTime(fyear3.SelectedItem.Value + "-" + fmon3.SelectedItem.Value); dt2 = Convert.ToDateTime(tyear3.SelectedItem.Value + "-" + tmon3.SelectedItem.Value); ts = dt2 - dt1; cyears[2] = Math.Round(Convert.ToDecimal(Math.Abs(ts.Days)) / 30, 0).ToString(); } if (fmon4.SelectedIndex == 0 || fyear4.SelectedIndex == 0 || tmon4.SelectedIndex == 0 | tyear4.SelectedIndex == 0 || string.Compare(fyear4.SelectedItem.Value, tyear4.SelectedItem.Value) > 0) { cmpyrs = cyears[0] + "/" + cyears[1] + "/" + cyears[2] + "/" + cyears[3]; } else { dt1 = Convert.ToDateTime(fyear4.SelectedItem.Value + "-" + fmon4.SelectedItem.Value); dt2 = Convert.ToDateTime(tyear4.SelectedItem.Value + "-" + tmon4.SelectedItem.Value); ts = dt2 - dt1; cyears[3] = Math.Round(Convert.ToDecimal(Math.Abs(ts.Days)) / 30, 0).ToString(); } cmpyrs = cyears[0] + "/" + cyears[1] + "/" + cyears[2] + "/" + cyears[3]; con.Open(); cmdwork = new MySqlCommand("update alumnireg set org=@cname,desig=@deg,expyrs=@yrs,cmploc=@loc where username='******'", con); cmdwork.Parameters.AddWithValue("@cname", cmpname); cmdwork.Parameters.AddWithValue("@deg", cmpdsg); cmdwork.Parameters.AddWithValue("@yrs", cmpyrs); cmdwork.Parameters.AddWithValue("@loc", cmploc); cmdwork.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Submit work of Alumni Profile for " + Session["loginname"] + ":" + ex.Message); } }
protected void showlist() { row1 = 0; temp1 = 0; names.Clear(); nameid.Clear(); MySqlCommand cmdfribat; //this is for displaying friend list try { con.Open(); cmdfribat = new MySqlCommand("select req_to,req_to_id from user_friends where req_from='" + usrname + "' and req_from_id=" + rid + " and accept=1 and req_to not in ('" + usrname + "')", con); drbatch = cmdfribat.ExecuteReader(); //generate friend list of the user who logged in. if (drbatch.HasRows) { while (drbatch.Read()) { names.Add(drbatch.GetString("req_to")); nameid.Add(drbatch.GetInt32("req_to_id")); } while (temp1 < names.Count) { tr = new HtmlTableRow(); for (int col = 0; col < 4; col++) { td = new HtmlTableCell(); if (!File.Exists(Server.MapPath(imgpath + nameid[row1] + ".png"))) { td.Controls.Add(new LiteralControl("<figure><a title='" + names[row1] + "' href='AlumniProfHome.aspx?vid=" + encodepwd(names[row1]) + "&myid=" + nameid[row1] + "&toid=" + rid + "'><img src='../images/nophoto.jpg' height='30' width='25' /></a></figure>")); } else { td.Controls.Add(new LiteralControl("<figure><a title='" + names[row1] + "' href='AlumniProfHome.aspx?vid=" + encodepwd(names[row1]) + "&myid=" + nameid[row1] + "&toid=" + rid + "'><img src='../Alumni_Images/" + nameid[row1] + ".png' height='30' width='25' /></a></figure>")); } tr.Controls.Add(td); row1++; if (row1 > names.Count - 1) { break; } } temp1 = row1; fri_list.Rows.Add(tr); } buddymsg.Visible = false; sectiontab.Style.Add("display", "block"); } else { buddymsg.Visible = true; sectiontab.Style.Add("display", "none"); } drbatch.Close(); con.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Show List method of Alumni Master for " + Session["loginname"] + ":" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { msgto.Focus(); } if (Session["loginname"] == null) { reurl.Value = "3"; Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "DoSomething('Your Current Session Expired..Please Login again!!!');</script>", true); } else { try { loginuser = Session["loginname"].ToString(); con.Open(); cmdmail = new MySqlCommand("select email,fname,lname,batch from alumnireg where username='******'", con); drmail = cmdmail.ExecuteReader(); drmail.Read(); maildispname = drmail.GetString("fname"); if (drmail.GetString("lname").Length > 0) { maildispname += " " + drmail.GetString("lname"); } maildispname += " [" + drmail.GetInt32("batch").ToString() + "]"; mailfrom = drmail.GetString("email"); drmail.Close(); } catch (Exception ex) { CreateLogFile log = new CreateLogFile(); log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page load of Email Page for " + Session["loginname"] + ":" + ex.Message); } finally { con.Close(); } } }
protected void Submit_Click(object sender, EventArgs e) { MailMessage mail = new MailMessage(); SmtpClient smtp = new SmtpClient(); int check; string strNewPassword = GeneratePassword(); //This is where you'd call the new password string. if (string.IsNullOrEmpty(emailid.Text)) { emailerr.Text = "Please enter an Email Id"; alertdiv.Style.Add("display", "block"); emailid.Text = ""; emailid.Focus(); } else { alertdiv.Style.Add("display", "none"); try { con.Open(); //updating password for the given mailid in forum_users table cmd = new MySqlCommand("update forum_users set password=password('" + strNewPassword + "') where email='" + emailid.Text.Trim() + "'", con); int num = cmd.ExecuteNonQuery(); if (num == 0) { alertdiv.Style.Add("display", "block"); emailerr.Text = "Not a Registered Mail-Id. Please enter a Registered Mail-Id"; emailid.Focus(); } else { alertdiv.Style.Add("display", "none"); emailerr.Text = ""; //validating emailid access to the site cmd1 = new MySqlCommand("select l.username,l.logentry from login l,forum_users f where l.emailid='" + emailid.Text.Trim() + "' and f.email='" + emailid.Text.Trim() + "'", con); dr = cmd1.ExecuteReader(); dr.Read(); check = dr.GetInt32("logentry"); if (check == 1) { msg = "<h1>The following email was sent to you by Alumni Administrator.</h1><br />"; msg += "<p>Apparently, you don't have the protocol to login into the site. <br />"; msg += "<br/>Your still not verified as <b>Valid Alumni</b> by Site Admin.<br/>"; msg += "Please contact Alumni Officer ([email protected]) for any queries or problems in acessing the site.</p><br/>"; msg += "<br/>Please do not reply to this mail.<br/><br/> Thank you!"; } else { msg = "<h1>The following email was sent to you by Alumni Administrator.</h1><br />"; msg += "<p>Apparently, you needed your password reset - So here it is: <br />"; msg += "<br/>Username :<b>" + dr.GetString("username") + "</b></p>"; msg += "New Password : <b>" + strNewPassword + "</b></p><br />"; msg += "<br/><a href='http://ssnunite.com/LoginPage.aspx'>Click here to login and verify your new password</a><br/>"; msg += "<br/>Please do not reply to this mail.Any queries please write to [email protected].<br/><br/> Thank you!"; } con.Close(); mail.From = new MailAddress(mid, "noreply"); mail.To.Add(emailid.Text.Trim()); mail.Subject = "SSN Alumni - Forgot Password"; mail.IsBodyHtml = true; mail.Body = msg; try { if (!Page.IsPostBack) { smtp.Host = "smtp.gmail.com"; smtp.Port = 25; smtp.Credentials = new System.Net.NetworkCredential(mid, mpwd); smtp.EnableSsl = true; smtp.Send(mail); } alertdiv.Style.Add("display", "block"); emailerr.Text = "Password has been sent to your mail. Please check it. Thank you."; } catch (SmtpException se) { alertdiv.Style.Add("display", "block"); emailerr.Text = "<b>Mail has not been sent to you.One of the following errors may have occured:-</b><br/>1.The connection to the SMTP server failed.<br/>2.The operation timed out.<br/>3.The message could not be delivered to one or more of the recipients in MailMessage.To, MailMessage.CC, or MailMessage.Bcc."; } } } catch (Exception ex) { CreateLogFile errlog = new CreateLogFile(); errlog.ErrorLog(Server.MapPath("Logs/Errorlog"), "Submit method of ForgotPassword Page :" + ex.Message); //alertdiv.Style.Add("display", "block"); //emailerr.Text = ex.Message; } } }