Page 258 - ระบบบริหารจัดการงบประมาณด้านเทคโนโลยีสารสนเทศและการสื่อสาร กรมพัฒนาที่ดิน
P. 258
ห้องสมุดกรมพัฒนาที่ดิน
ง-3
อ้างอิงไฟล์ login.aspx ดังนี้
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class login : System.Web.UI.Page
{ string str = ConfigurationManager.ConnectionStrings["SqlCon"].ConnectionString;
Utilities ut = new Utilities();
protected void Page_Load(object sender, EventArgs e)
{ Session.Clear(); }
protected void btnLogin_Click(object sender, EventArgs e)
{ string sSql = "select Username, Type, BureauID from PWD where username = '" +
txtU.Text + "' and PWD = '" + txtP.Text + "'";
DbMgt table = new DbMgt(str);
MyDataSet ds = new MyDataSet(table.exReader(sSql));
if (ds.RecordCount() == 1)
{ Session["Username"] = ds.showFieldValue("Username", 0);
Session["Type"] = ds.showFieldValue("Type", 0);
Session["Bureau"] = ds.showFieldValue("BureauID", 0);
if (Session["Type"].ToString() == "Admin")
Response.Redirect("MainAdmin/MainAdmin.html");
else if (Session["Type"].ToString() == "Exe")
Response.Redirect("MainExe/MainExe.html");
else if (Session["Type"].ToString() == "Appr")
Response.Redirect("MainAppr/MainAppr.html");
else Response.Redirect("main2.aspx"); }
else Response.Write(ut.alert("ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง")); } }