protected void Page_Load(object sender, EventArgs e) { // DateTime dt1 = DateTime.Now.ToString("MM/dd/yyyy"); // string dte =DateTime.Now.ToShortDateString; // string date= Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy"); // // string ConString = WebConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; ///* string ConString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;DATABASE=employees;UID=root;PASSWORD=glspl123;port=3306;charset=UTF8";*/ // // string ConString = "Server=localhost;Database=Employees;user id=root;password=glspl123"; // // string ConString = "Driver={MySQL ODBC 5.1 Driver};" + "Server=209.200.117.22;" + "Database=Employees;" + "user id=nitish;" + "password=nitish;" + "Port=3306"; // OdbcConnection connection = new OdbcConnection("DSN=sptm"); // // OdbcConnection connection = new OdbcConnection(ConString); // string sSQL = "select * from emp_details"; // OdbcDataAdapter ODA = new OdbcDataAdapter(sSQL,connection); // //OdbcDataAdapter oDataAdapter = new OdbcDataAdapter(sSQL, connection); // DataTable dt = new DataTable(); // ODA.Fill(dt); // GRDMYSQL.DataSource = dt; // GRDMYSQL.DataBind(); CentraliseEmail objsendmail = new CentraliseEmail(); objsendmail.SendMail(); }
protected void Page_Load(object sender, EventArgs e) { CentraliseEmail cem = new CentraliseEmail(); Response.Write(cem.SendMail()); }
public spmresult Task(string subject, string mainsubject, string action, string tby, DateTime pdcdate, string details, System.Collections.Generic.List<string> info,string tasktype) { spmresult spmr; int taskid = 0; initiatedby = tby; globalcurrenttime = pdcdate; OdbcCommand cmd = new OdbcCommand(); OdbcConnection con = new OdbcConnection(connectionstring); DateTime dt1 = DateTime.Now; //DateTime dt = DateTime.Now.ToShortDateString; //string curdate = String.Format("{0:yyyy/M/d }", dt); con.Open(); cmd.Connection = con; cmd.CommandText = "INSERT INTO ntask(tdtoi,subject,mainsubject,action,tby,status,pdc,task_type,detail) VALUES(?,?,?,?,?,?,?,?,?)"; cmd.CommandType = CommandType.Text; // Parameters Pass cmd.Parameters.Add("@tdtoi", OdbcType.DateTime).Value = dttime; cmd.Parameters.Add("@subject", OdbcType.VarChar, 50).Value = subject; cmd.Parameters.Add("@mainsubject", OdbcType.VarChar, 30).Value = mainsubject; cmd.Parameters.Add("@action", OdbcType.VarChar, 22).Value = action; cmd.Parameters.Add("@tby", OdbcType.VarChar, 22).Value = tby; cmd.Parameters.Add("@status", OdbcType.VarChar, 9).Value = status; cmd.Parameters.Add("@pdc", OdbcType.DateTime).Value = String.Format("{0:yyyy/M/d }", pdcdate); cmd.Parameters.Add("@task_type", OdbcType.VarChar, 20).Value = tasktype; cmd.Parameters.Add("@detail", OdbcType.VarChar, 500).Value = details; try { // cmd.Connection.Open(); int result = cmd.ExecuteNonQuery(); if (result > 0) { spmr=new spmresult(1, " Successfully inserted "); // return spmr; //Alert.Show(" Successfully inserted "); } else { spmr = new spmresult(0, " Error in insert of task... "); return spmr; } // cmd.Connection.Close(); // open connectiion for taskid cmd.Connection = con; cmd.CommandText = "select taskid from ntask where tdtoi='" + dttime + "' and tby='" + tby + "'"; cmd.CommandType = CommandType.Text; //cmd.Connection.Open(); OdbcDataReader reader; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { taskid = (int)reader["taskid"]; } } reader.Close(); // cmd.Connection.Close(); //check listbox // System.Collections.Generic.List<string> selectionList = new System.Collections.Generic.List<string>(); for (int i = 0; i < info.Count;i++ ) { string information= info[i]; OdbcCommand cmd1 = new OdbcCommand(); cmd1.Connection = con; cmd1.CommandText = "insert into ntaskinfo(infoto,taskid) values(?,?)"; cmd1.Parameters.Add("@infoto", information); cmd1.Parameters.Add("@taskid", taskid); cmd1.CommandType = CommandType.Text; int j = cmd1.ExecuteNonQuery(); } } catch (OdbcException ee) { string errormessage ="Info Add Method Error :"+ ee.Message; spmr = new spmresult(0, errormessage); // return spmr; } catch (Exception ee) { string errormessage = "Info Adding Method Error :" + ee.Message; spmr = new spmresult(0, errormessage); return spmr; } finally { con.Close(); } spmr = inserttopdc(taskid); if (spmr.success > 0) { CentraliseEmail cem = new CentraliseEmail(); string toemailid = User_.getEmailId(action); if (toemailid.Length > 0) { DateTime dt = Convert.ToDateTime(DateTime.Now); string ems = "Task " + mainsubject; cem.AddEmail(toemailid,ems, true,dt, subject); } } return spmr; }