-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebForm3.aspx.cs
97 lines (88 loc) · 3.77 KB
/
WebForm3.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.Odbc;
using Oracle.ManagedDataAccess.Client;
using System.Net.Mail;
using System.Net;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using ClosedXML.Excel;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace RCMC
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
/* OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
string insert = "INSERT INTO mdate (bdate, mdate)";
insert += " VALUES (";
insert += "'" + DropDownList1.SelectedValue + "-" + DropDownList2.SelectedValue + "-" + DropDownList3.SelectedValue + "'";
insert += ", '" + TextBox2.Text + "'";
insert += ")";
OracleCommand cmd = new OracleCommand(insert, con);
cmd.ExecuteNonQuery();
con.Close();*/
}
protected void Button2_Click(object sender, EventArgs e)
{
MailMessage o = new MailMessage("[email protected]", "[email protected]", "Hi ", "I'm There..");
NetworkCredential netCred = new NetworkCredential("[email protected]", "dhvfg;hgpl]44");
SmtpClient smtpobj = new SmtpClient("smtp.live.com", 587);
smtpobj.EnableSsl = true;
smtpobj.Credentials = netCred;
smtpobj.Send(o);
}
protected void ExportExcel(object sender, EventArgs e)
{
OracleConnection noc;
//string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (noc = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (OracleCommand cmd = new OracleCommand("SELECT * FROM survey"))
{
using (OracleDataAdapter da = new OracleDataAdapter())
{
cmd.Connection = noc;
da.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
da.Fill(dt);
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(dt, "members");
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename=survey.xlsx");
using (MemoryStream MyMemoryStream = new MemoryStream())
{
wb.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}
}
}
}
}
}
}
}