using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using DataLibrary; using System.Data; using EncryptDecryptEngine; using System.Diagnostics; using System.Security; namespace SingleSignOn { public partial class Login : System.Web.UI.Page { public bool branchFlag = false; public bool BranchFlag { get { // ประกาศตัวแปร transaction Sta ta = null; string connectionString; // ทำการเชื่อมต่อ database ถ้าเชื่อมต่อไม่ได้ให้แจ้ง error และจบการทำงาน try { DataTable dtDb = xml.ConnectionStringData; connectionString = dtDb.Rows[DdDatabase.SelectedIndex]["connection_string"].ToString().Trim(); ta = new Sta(connectionString); } catch { LtServerMessage.Text = ErrorMessage("ไม่สามารถเชื่อมต่อฐานข้อมูล"); } //if (DdDatabaseTmp.Text != DdDatabase.SelectedValue.Trim()) { try { string sqlCoop = "select coop_id,CONCAT(CONCAT(coop_id,' - '),coop_name ) as coop_name from cmcoopmaster order by coop_id asc"; DataTable dtCoop = ta.QueryDataTable(sqlCoop); branchFlag = dtCoop.Rows.Count > 1; this.TbCoopId.Text = dtCoop.Rows[0][0].ToString().Trim(); DdDatabaseTmp.Text = DdDatabase.SelectedValue.Trim(); } catch { } //} try { ta.Close(); } catch { } return branchFlag; } } private string ErrorMessage(string message) { return "
" + message + "
"; } private string WarnningMessage(string message) { return "
" + message + "
"; } private string CompleteMessage(string message) { return "
" + message + "
"; } private int conId = 0; public string vDir = ""; private string sessionId = ""; private string refUrl = ""; private string ChecKCOOP = ""; private string gcoopPath = ""; private XmlConfigService xml = null; public bool googleMapFlag { set; get; } public String HM9ColorFilter { set; get; } public String CoopLogo { set; get; } public bool LiveChatFlag { set; get; } public int LiveChatId { set; get; } protected void Page_Load(object sender, EventArgs e) { // สร้าง fullpath ของโฟลเดอร์ GCOOP try { vDir = Session["virtual_directory"].ToString(); } catch { vDir = "YTK"; //ย่านตาขาว // vDir = "URS"; ศรีธาตุ เกษตรวิสัย //vDir = "IEXT"; ไซด์ Oracle } Session["currentDir"] = HttpContext.Current.Request.MapPath("~/").Substring(0, 1); gcoopPath = Session["currentDir"] + ":\\ICOOP_ALL\\" + vDir + "\\ICOOP\\"; // สร้าง object xml เป็นตัวแปร local xml = new XmlConfigService(gcoopPath); this.LiveChatFlag = xml.LiveChatFlag==1; this.LiveChatId = xml.LiveChatId; googleMapFlag = xml.ShowmapFlag==1 ?CoreSavingLibrary.WebUtil.urlExists("http://map.google.com"):false; // ทำ server message ให้เป็นค่าว่าง LtServerMessage.Text = ""; try { // ตั้งค่าตัวแปรจาก session หากไม่พบให้ throw error try { conId = Convert.ToInt32(Session["connection_index"]); vDir = Session["virtual_directory"].ToString(); sessionId = Session["session_id"].ToString(); refUrl = Session["reference_url"].ToString(); } catch { vDir = xml.SavPathOpenType1; throw new Exception("ไม่พบการอ้างอิงจากระบบต้นทาง กดที่นี่เพื่อเข้าหน้าหลักอีกครั้ง