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 Personal_WeeklyPayment : 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 (Profile.UserName.Length <= 0 || !SES_Common.Authorize(Request.Url.ToString(), Profile.UserName)) {
            Response.Redirect("/SEST/Common/NoAuthorization.aspx");
        }
    }


    protected void Page_Load(object sender, EventArgs e) {
        //if (!IsPostBack) {
        //    txtStartDate.Text = DateTime.Today.AddYears(-1).AddDays(1).ToString("yyyy/MM/dd");
        //    txtEndDate.Text = DateTime.Today.ToString("yyyy/MM/dd");
        //    getData(txtStartDate.Text, txtEndDate.Text);
        //}

        // 判斷使用者是否有權限登入
        //hidUserName.Value = new HR_EmployeesData().getUserNameByAccount(Profile.UserName);
        DataTable dtUser = new HR_EmployeesData().SelectExcludeLeave("Name", "Account='" + Profile.UserName + "'");
        if (dtUser.Rows.Count == 1) {
            hidUserName.Value = dtUser.Rows[0]["Name"].ToString();
        }
        else
            Response.Redirect("../login.aspx");


    }
    protected void btnSearch_Click(object sender, EventArgs e) {
        //getData( txtStartDate.Text, txtEndDate.Text);
    }
    void getData(string StartDate, string EndDate) {
        //// =============== Top of : check date time format =======================
        //try {
        //    DateTime.Parse(StartDate);
        //    DateTime.Parse(EndDate);
        //}
        //catch {
        //    Response.Redirect("/SEST/Common/ErrorPage.aspx?BackPageCount=-1&ErrorMessage=Incorrect DateTime");
        //    return;
        //}
        //// =============== bottom of : check date time format =======================

        //// =============== Top of : get user name =======================
        //string sUserName = "";
        //try {
        //    sUserName = new HR_EmployeesData().getUserNameByAccount(Profile.UserName);
        //}
        //catch {
        //    Response.Redirect("/SEST/Common/ErrorPage.aspx?BackPageCount=-1&ErrorMessage=get user name failed");
        //    return;
        //}
        //// =============== bottom of : get user name =======================
        //// =============== Top of : display data =======================
        //try {
        //    DataTable dt = new HR_PettyCashData().Select(
        //        "(UserName like '%" + Profile.UserName + "%' or UserName like '%" + sUserName + "%') and " +
        //        " ReceiptDate>'" + StartDate + "' and ReceiptDate<'" + EndDate + "'");
        //    GridView1.DataSource = dt;
        //    GridView1.DataBind();
        //    if (dt.Rows.Count > 0) { //GridView1.HeaderRow.Cells[0] is PettyCashID
        //        GridView1.HeaderRow.Cells[1].Text = Resources.Universal.Comm_Item;
        //        GridView1.HeaderRow.Cells[2].Text = Resources.Universal.Employee_Name;
        //        GridView1.HeaderRow.Cells[3].Text = Resources.Universal.PettyCash_ReceiptDate;
        //        GridView1.HeaderRow.Cells[4].Text = Resources.Universal.PettyCash_PayDate;
        //        GridView1.HeaderRow.Cells[5].Text = Resources.Universal.PettyCash_Amount;

        //    }
        //}
        //catch (Exception ex) {
        //    Response.Redirect("/SEST/Common/ErrorPage.aspx?BackPageCount=-1&ErrorMessage=" + ex.Message.Replace("\r\n", "=>"));
        //}
        //// =============== bottom of : display data =======================
    }
}
