public Addfac() { fac = new Faculty(); acc = new Account(); ass = new Assignment(); stumng = new Studmng(); facmng = new Facmng(); accmng = new Accmng(); images = new Images(); InitializeComponent(); cmbxgen.DataSource = facmng.gender(); cmbxqua.DataSource = facmng.qualification(); if (accmng.readkey() != null) { fac = facmng.get(Convert.ToInt32(accmng.readkey())); if (fac == null) { throw new Exception("Access Denied"); } else { facmng.Email(Convert.ToInt32(accmng.readkey())); string[] a = accmng.annoucements().Split('\n'); foreach (string s in a) { listBox2.Items.Add(s); } panel6.Visible = false; phome.Visible = true; acc = accmng.getfacpass(Convert.ToInt32(accmng.readkey())); FillForm(fac, acc); comboBox1.DataSource = facmng.studentids(Convert.ToInt32(accmng.readkey())); dataGridView1.DataSource = facmng.getAll(Convert.ToInt32(accmng.readkey())); dtmarks.DataSource = facmng.getmarks(Convert.ToInt32(accmng.readkey())); dtmarks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dtmarks.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; ass = facmng.getassign(Convert.ToInt32(accmng.readkey())); if (ass != null) { lblnote.Text = "Assignment Uploaded"; btnsubmit.Enabled = false; btndelete.Enabled = true; Fillexistassign(ass); } else if (ass == null) { lblnote.Text = "Assignment Not Uploaded"; btnsubmit.Enabled = true; btnbrowse.Enabled = true; } } } }
private void btnlogin_Click(object sender, EventArgs e) { acc = new Account(); try { acc.Fac_id = Convert.ToInt32(txtidmain.Text); acc.Password = txtpassmain.Text; accmng.verifyfac(acc.Fac_id, acc.Password); string[] a = accmng.annoucements().Split('\n'); foreach (string s in a) { listBox2.Items.Add(s); } panel6.Visible = false; phome.Visible = true; accmng.createkey(acc.Fac_id); facmng.Email(Convert.ToInt32(accmng.readkey())); fac = facmng.get(Convert.ToInt32(accmng.readkey())); FillForm(fac, acc); lblmsg.Text = ""; txtidmain.Text = ""; txtpassmain.Text = ""; comboBox1.DataSource = facmng.studentids(Convert.ToInt32(accmng.readkey())); dataGridView1.DataSource = facmng.getAll(Convert.ToInt32(accmng.readkey())); dtmarks.DataSource = facmng.getmarks(Convert.ToInt32(accmng.readkey())); dtmarks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dtmarks.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; ass = facmng.getassign(Convert.ToInt32(accmng.readkey())); if (ass != null) { lblnote.Text = "Assignment has been Uploaded"; btnsubmit.Enabled = false; btnupdate.Enabled = false; btndelete.Enabled = true; Fillexistassign(ass); } else if (ass == null) { lblnote.Text = "Assignment Not Uploaded"; btnsubmit.Enabled = true; btnbrowse.Enabled = true; } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
public void email() { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); foreach (var list in facmng.Email(Convert.ToInt32(readkey()))) { mail.To.Add(list); } mail.Subject = "alert"; mail.Body = "Assignment has been Uploaded"; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "yourpassword"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); MessageBox.Show("Mail sent", "Success", MessageBoxButtons.OK); }