using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SubPages_Employees : System.Web.UI.Page {
    //the function code for localization on this page
    protected override void InitializeCulture() {
        ProfileCommon p = (ProfileCommon)this.Context.Profile;

        if (Request.Form.Get("ctl00$selLanguage") != null)
            p.lang = Request.Form.Get("ctl00$selLanguage").ToString();
        if (p.lang == String.Empty)
            p.lang = Session["Localization"].ToString();

        if (p.lang.Length > 0) {
            this.Culture = p.lang;
            this.UICulture = System.Globalization.CultureInfo.CreateSpecificCulture(p.lang).Name;
        }
    }
    //select theme
    protected void Page_PreInit(object sender, EventArgs e) {
        Page.Theme = Profile.UI.Theme;
    }

    
    
    protected void Page_Load(object sender, EventArgs e) {
        int iRowCount = 5, iCount = 0;
        if (Request["DialogClientID"] != null) {
            string sParentID = Request["DialogClientID"].ToString().Trim();

            DataTable dt = new HR_EmployeesData().SelectExcludeLeave("Name", null);
            // 判斷是否有找到資料, 沒有則return 
            if (dt.Rows.Count <= 0) {
                Label lbl = new Label();
                lbl.Text = Resources.Universal.Msg_NotFindData;
                this.form1.Controls.Add(lbl);
                return;
            }
            // show data with table
            Table tblDisplay = new Table();
            tblDisplay.GridLines = System.Web.UI.WebControls.GridLines.Both;
            //tblDisplay.Width = System.Web.UI.WebControls.Unit.Pixel(400);
            tblDisplay.ForeColor = System.Drawing.Color.White;
            tblDisplay.Font.Bold = true;
            tblDisplay.BackColor = System.Drawing.Color.SkyBlue;
            TableRow tableRow = null;
            for (int i = 0; i < dt.Rows.Count; i++) {
                string sName = dt.Rows[i]["Name"].ToString();
                if ((iCount % iRowCount) == 0)
                    tableRow = new TableRow();
                TableCell tableCell = new TableCell();
                Label lbl = new Label();
                lbl.Text = sName;
                lbl.Attributes.Add("onclick", "AssignValueToParent('" + sParentID + "','" + sName + "')");
                lbl.Attributes.Add("style", "cursor:hand");
                tableCell.Controls.Add(lbl);
                tableRow.Controls.Add(tableCell);
                if (((iCount + 1) % iRowCount) == 0)
                    tblDisplay.Controls.Add(tableRow);
                iCount++;
            }
            if ((iCount % iRowCount) != 0)
                tblDisplay.Controls.Add(tableRow);
            this.form1.Controls.Add(tblDisplay);
            Button btn = new Button();
            btn.Text = Resources.Universal.Msg_Close;
            btn.Attributes.Add("onclick", "window.close();");
            this.form1.Controls.Add(btn);
        }
    }
}
