using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Text;
using System.Threading;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                        Created On  : 12-Aug-2007
* Module          : Employee Master                                  Modified On : 08-Aug-2007
* Created By      : Arun Vinoth.T
* Modified By     : 
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_Emp_ChildrenModify : Base.BasePage
{
    EmployeeEventData objEmployee = new EmployeeEventData();
    ResourceManager rm;
    CultureInfo ci;
    string[] children_name = new string[100];
    string[] children_DOB = new string[100];
    int rows = 0;
    int empID, No;
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        base.Page_Load(sender, e);
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        //Session.LCID = 1033;
        if (!IsPostBack)
        {
            if (Request.QueryString["EmpID"] != null && Request.QueryString["EmpID"] != "" && Request.QueryString["No"] != null && Request.QueryString["No"] != "")
            {
                empID = Convert.ToInt32(Request.QueryString["EmpID"]);
                No = Convert.ToInt32(Request.QueryString["No"]);
                GetChildrenDetails(empID);
                GenerateControls();
            }
            else
            {
                Response.Clear();
                Response.Write("Fail");
                Response.End();
            }
        }
    }
    //function getting children details
    private void GetChildrenDetails(int empID)
    {
        if (empID != 0)
        {
            DataSet ds = new DataSet();
            ds = objEmployee.select_ChildrenDetails(empID);
            rows = ds.Tables[0].Rows.Count;
            for (int i = 0; i < rows; i++)
            {
                children_name[i] = Convert.ToString(ds.Tables[0].Rows[i]["Name"]);
                children_DOB[i] = Convert.ToString(ds.Tables[0].Rows[i]["DOB"]);
            }
        }
    }
    //function generating controls
    private void GenerateControls()
    {
        Response.Clear();
        string id1 = "";
        string id2 = "";
        StringBuilder sb_Children = new StringBuilder();
        sb_Children.Append("<div id=\"tbl_children\" style='color:#5D5D5D'>");
        for (int i = 0; i < No; i++)
        {
            id1 = "txt_ChName" + i;
            id2 = "txt_ChildDOB" + i;
            int j = i + 1;
            if (i < rows)
            {
                string strdob = "";
                if (Convert.ToString(children_DOB[i]) != "")
                {
                    strdob = (Convert.ToDateTime(Convert.ToString(children_DOB[i]))).ToString(Convert.ToString(Session["MDateFormat"]));
                }
                sb_Children.Append("<div class='row form-group'>");
                sb_Children.Append("<div class='col-md-2'>");
                sb_Children.Append(rm.GetString("Caption_Child", ci) + j + rm.GetString("OrgLevels_CompDetails_Name", ci) + "</div> <div class='col-md-3'><INPUT value='" + Convert.ToString(children_name[i]) + "' type='Text' class='form-control' ID='" + id1 + "' onkeypress=\"return character_only(event,this)\" onchange=\"javascript:return assign_hiddenModify('1');\">");
                sb_Children.Append("</div><div class='col-md-1'></div>");
                sb_Children.Append("<div class='col-md-2'>");
                sb_Children.Append(rm.GetString("Caption_Child", ci) + j + rm.GetString("Caption_DOB", ci) + "</div> <div class='col-md-3'> <INPUT value='" + strdob + "' type='Text' class='form-control' onmouseover=\"javascript:return DynamicDatePicker('" + Convert.ToString(Session["IDateFormat"]) + "','" + id2 + "');\" runat ='Server'  ID='" + id2 + "' onkeypress=\"return key_press_nokey(event)\" onpaste=\"return false\" onblur=\"javascript:assign_hiddenModify(this);\">");
                sb_Children.Append("</div>");
                //sb_Children.Append("<div class='td' align='left'>");
                //sb_Children.Append("<input type=\"image\" src=\"../Images/dateicon.gif\" id=\"buttxt_childdob" + j + "\" onclick=\"Calendar.setup({inputField     :    '" + id2 + "',ifFormat       :    '" + Convert.ToString(Session["IDateFormat"]) + "',showsTime      :    false, button         :    'buttxt_childdob" + j + "',  singleClick    :    true,   step           :    1 });return false\"/>");
                //sb_Children.Append("</td>");
                sb_Children.Append("</div>");
            }
            else
            {
                sb_Children.Append("<div class='row form-group'>");
                sb_Children.Append("<div class='col-md-2'>");
                sb_Children.Append(rm.GetString("Caption_Child", ci) + j + rm.GetString("OrgLevels_CompDetails_Name", ci) + "</div> <div class='col-md-3'><INPUT type='Text' class='form-control' ID='" + id1 + "' onkeypress=\"return character_only(event,this)\" onchange=\"javascript:return assign_hiddenModify('1');\">");
                sb_Children.Append("</div><div class='col-md-1'></div>");
                sb_Children.Append("<div class='col-md-2'>");
                sb_Children.Append(rm.GetString("Caption_Child", ci) + j + rm.GetString("Caption_DOB", ci) + "</div> <div class='col-md-3'> <INPUT type='Text' class='form-control' runat ='Server'  ID='" + id2 + "' onkeypress=\"return key_press_nokey(event)\" onpaste=\"return false\" onmouseover=\"javascript:return DynamicDatePicker('" + Convert.ToString(Session["IDateFormat"]) + "','" + id2 + "');\" onblur=\"javascript:return assign_hiddenModify(this);\">");
                sb_Children.Append("</div>");
                //sb_Children.Append("<td class='td' align='left'>");
                //sb_Children.Append("<input type=\"image\" src=\"../Images/dateicon.gif\" id=\"buttxt_childdob" + j + "\" onclick=\"Calendar.setup({inputField     :    '" + id2 + "',ifFormat       :    '" + Convert.ToString(Session["IDateFormat"]) + "',showsTime      :    false, button         :    'buttxt_childdob" + j + "',  singleClick    :    true,   step           :    1 });return false\"/>");
                //sb_Children.Append("</td>");
                sb_Children.Append("</div>");
            }
        }
        sb_Children.Append("</div>");
        Response.Write(sb_Children);
        Response.End();
    }
}
