Page 166 - ระบบสารสนเทศเพื่อการบริหารจัดการเอกสารอิเล็กทรอนิกส์ (e-Document)
P. 166

ห้องสมุดกรมพัฒนาที่ดิน
                                                                                                        ค- 53




                  อ้างอิงไฟล์  SystemLogin.aspx.cs ดังนี้

                  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 SystemLogin : 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, Password, Promote, Deputy, Letter
                  from UserAdmin where Username = '" + txtU.Text + "' and Password = '" +
                  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["Bureau"] = ds.showFieldValue("Bureau", 0);
                              Session["Promote"] = ds.showFieldValue("Promote", 0);
                              Session["Deputy"] = ds.showFieldValue("Deputy", 0);
                              Session["Letter"] = ds.showFieldValue("Letter", 0);
                              Response.Redirect("MainAdmin.aspx");
                          }
                          else
                              Response.Write(ut.alert("ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง"));
                      }
                  }

                               ----------------------------------------------------------------------------------------------
   161   162   163   164   165   166   167   168   169   170   171