using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
public partial class new_proj : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string proj_name = TextBox1.Text;
int work_id = int.Parse(TextBox11.Text);
int assigned_to = int.Parse(DropDownList2.SelectedItem.Text);
string desc = TextBox9.Text;
string priority = DropDownList1.SelectedItem.Text;
string start_date = DatePicker1.SelectedDate.ToShortDateString();
string end_date = DatePicker2.SelectedDate.ToShortDateString();
int assigned_by = int.Parse(Session["managerid"].ToString());
int no_line = int.Parse(TextBox10.Text);
string doc = TextBox12.Text;
logic log = new logic();
if (log.addProject(proj_name,work_id, assigned_to,start_date, desc, priority,end_date,assigned_by,no_line,doc) == true)
{
lblmsg.Text = "new work added";
}
else
{
lblmsg.Text = "error while creating a new work";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
logic log = new logic();
int to_id = int.Parse(DropDownList2.SelectedItem.Text);
string to_mail_id = log.get_mail_id(to_id);
string subj = "waiting for approval";
string a = string.Format("E:/vs2010/eoffice1/work_approval.aspx");
string msg = String.Format("click here to approve", a);
// string messg = "click here to" + " approve";
int by_id = int.Parse(Session["managerid"].ToString());
string by_mail_id = log.get_manager_mail_id(by_id);
if (log.user_approval_messg(to_mail_id, subj, msg, by_mail_id) == true)
{
//mail
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.gmail.com";
smtpClient.UseDefaultCredentials = false;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new NetworkCredential("deepikam1608@gmail.com", "deepschinnu");
smtpClient.Port = 25;
MailAddress fromAddress = new MailAddress("deepikam1608@gmail.com", "eoffice");
MailMessage message = new MailMessage();
message.From = fromAddress;
//message.BodyFormat = MailFormat.Html;
message.To.Add(new MailAddress(to_mail_id));
message.Subject = "waiting for approval";
message.IsBodyHtml = true;
string mesg = msg;
message.Body = mesg;
smtpClient.Send(message);
Label1.Text = "message and mail sent";
}
else
Label1.Text = "message unsent..";
}
}