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 : 19-May-2007
* Created By      : Arun Vinoth.T
* Modified By     : 
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_Emp_ChildrenView : 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;
    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;
        if (!IsPostBack)
        {
            if (Request.QueryString["EmpID"] != null && Request.QueryString["EmpID"] != "")
            {
                empID = Convert.ToInt32(Request.QueryString["EmpID"].ToString());
                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] = ds.Tables[0].Rows[i]["Name"].ToString();
                children_DOB[i] = ds.Tables[0].Rows[i]["DOB"].ToString();
            }
        }
    }
    //function generates control
    private void GenerateControls()
    {
        Response.Clear();
        string id1 = "";
        string id2 = "";
        int Children_No = rows;
        StringBuilder sb_Children = new StringBuilder();
        sb_Children.Append("<div id=\"tbl_children\" style='color:#5D5D5D'>");
        for (int i = 0; i < Children_No; i++)
        {
            string strdob = "";
            if (children_DOB[i].ToString() != "")
            {
                strdob = (Convert.ToDateTime(children_DOB[i].ToString())).ToString(Session["MDateFormat"].ToString());
            }
            id1 = "txt_ChName" + i;
            id2 = "txt_ChildDOB" + i;
            int j = i + 1;
            sb_Children.Append("<div class='row'>");
            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'> <label class='form-control'>" + children_name[i].ToString() + "</label>");
            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'><label class='form-control'> " + strdob + "</label>");
            sb_Children.Append("</div>");
            sb_Children.Append("</div>");
        }
        sb_Children.Append("</div>");
        Response.Write(sb_Children);
        Response.End();
    }
}
