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 Maintenance_HR_Employee : 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;

        // 沒有權限
        if (!SES_Common.Authorize(Request.Url.ToString(), Profile.UserName)) {
            Response.Redirect("/SEST/Common/NoAuthorization.aspx");
        }
    }



    protected void Page_Load(object sender, EventArgs e) {
        //SEST_Sql sess = new SEST_Sql();
        //sess.Open();
        //GridView1.DataSource = sess.getDataSet_Employees().Tables[0];
        //GridView1.DataBind();

        //GridView1.Columns.RemoveAt(2);
        //GridView1.Columns.RemoveAt(3);
        //GridView1.Columns.RemoveAt(4);
        //GridView1.Columns.RemoveAt(5);
        //GridView1.Columns.RemoveAt(6);
        //GridView1.Columns.RemoveAt(7);
        //GridView1.Columns.RemoveAt(8);

        // 不是來自管理的路徑 (功能 hidden)
        if (Request.Url.ToString().ToUpper().IndexOf("SEST/MAINTENANCE/") < 0) {
            hyAddNew.Visible = false;
        }
    }
    protected void btnSumit_Click(object sender, EventArgs e) {
        if (chkContainLeftPersonal.Checked)
            ObjectDataSource1.SelectMethod = "SelectIncludeLeave";
        else
            ObjectDataSource1.SelectMethod = "SelectExcludeLeave";


        GridView1.DataBind();
    }
    protected void GridView1_DataBound(object sender, EventArgs e) {
        //lblAmount.Text = (GridView1.PageCount-1) * GridView1.PageSize + GridView1.Page.n

        foreach (GridViewRow gvr in GridView1.Rows) { 
            if (gvr.Cells[gvr.Cells.Count-1].Text.Replace("&nbsp;","").Trim() != "")
                gvr.ForeColor = System.Drawing.Color.Red;
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) {
        if (chkContainLeftPersonal.Checked)
            ObjectDataSource1.SelectMethod = "SelectIncludeLeave";
        else
            ObjectDataSource1.SelectMethod = "SelectExcludeLeave";
        
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) {
        if (chkContainLeftPersonal.Checked)
            ObjectDataSource1.SelectMethod = "SelectIncludeLeave";
        else
            ObjectDataSource1.SelectMethod = "SelectExcludeLeave";

    }
}
