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

        // ¨S¦³Åv­­
        if (!SES_Common.Authorize(Request.Url.ToString(), Profile.UserName)) {
            Response.Redirect("/SEST/Common/NoAuthorization.aspx");
        }
    }

    
    
    protected void Page_Load(object sender, EventArgs e) {
        //DataTable dt = new HR_EmployeesData().Select("Name","LeaveDate is null", "DutyFormGrouping");
        //foreach (DataRow dr in dt.Rows) { 
        //    lstEmployees.Items.Add(dr["Name"].ToString());
        //}
    }
    protected void btnUpdate_Click(object sender, EventArgs e) {
        HR_EmployeesData emp = new HR_EmployeesData();
        string sEmployeeID = "", sName = "", sGrouping = "", sEnabled="0", sPriority = "99";
        for (int i = 0; i < GridView1.Rows.Count; i++) {
            sEmployeeID = ((Label)GridView1.Rows[i].FindControl("lblEmployeeID")).Text;
            sName = ((Label)GridView1.Rows[i].FindControl("lblName")).Text;
            sGrouping = ((TextBox)GridView1.Rows[i].FindControl("txtGrouping")).Text;
            sEnabled = Convert.ToInt32(((CheckBox)GridView1.Rows[i].FindControl("chkDutyFormEnabled")).Checked).ToString();
            sPriority = ((TextBox)GridView1.Rows[i].FindControl("txtPriority")).Text;
            try {
                int.Parse(sPriority);
            }
            catch { sPriority = "99";}

            emp.Update("Grouping='" + sGrouping + "',DutyFormEnabled='" + sEnabled + "',DutyFormPriority='" + sPriority + "'", "EmployeeID='" + sEmployeeID + "'");
        }
    }
}
