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 : 25-July-2007
* Created By      : Arun Vinoth.T
* Modified By     : 
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_Emp_SpouseView : Base.BasePage
{
    EmployeeEventData objEmployee = new EmployeeEventData();
    ResourceManager rm;
    CultureInfo ci;
    string[] spouse_name = new string[100];
    string[] spouse_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;
        // Session.LCID = 1033;
        if (!IsPostBack)
        {
            if (Request.QueryString["EmpID"] != null && Request.QueryString["EmpID"] != "")
            {
                empID = Convert.ToInt32(Request.QueryString["EmpID"].ToString());
                GetSpouseDetails(empID);
                GenerateControls();
            }
            else
            {
                Response.Clear();
                Response.Write("Fail");
                Response.End();
            }
        }
    }
    //function getting spouse details
    private void GetSpouseDetails(int empID)
    {
        if (empID != 0)
        {
            DataSet ds = new DataSet();
            ds = objEmployee.select_SpouseDetails(empID);
            rows = ds.Tables[0].Rows.Count;
            for (int i = 0; i < rows; i++)
            {
                spouse_name[i] = ds.Tables[0].Rows[i]["Name"].ToString();
                spouse_DOB[i] = ds.Tables[0].Rows[i]["DOB"].ToString();
            }
        }
    }
    //function generates control
    private void GenerateControls()
    {
        Response.Clear();
        string id1 = "";
        string id2 = "";
        int Spouse_No = rows;
        StringBuilder sb_spouse = new StringBuilder();
        sb_spouse.Append("<div id=\"tbl_spouse\" style='color:#5D5D5D'>");
        for (int i = 0; i < Spouse_No; i++)
        {
            string strdob = "";
            if (spouse_DOB[i].ToString() != "")
            {
                strdob = (Convert.ToDateTime(spouse_DOB[i].ToString())).ToString(Session["MDateFormat"].ToString());
            }
            id1 = "txt_SpName" + i;
            id2 = "txt_ChildDOB" + i;
            int j = i + 1;
            sb_spouse.Append("<div class='row'>");
            sb_spouse.Append("<div class='col-md-2'>");
            sb_spouse.Append(rm.GetString("Caption_Spouse", ci) + j + rm.GetString("OrgLevels_CompDetails_Name", ci) + "</div> <div class='col-md-3'> <label class='form-control'>" + spouse_name[i].ToString() + "</label>");
            sb_spouse.Append("</div><div class='col-md-1'></div>");
            sb_spouse.Append("<div class='col-md-2'>");
            sb_spouse.Append(rm.GetString("Caption_Spouse", ci) + j + rm.GetString("Caption_DOB", ci) + "</div> <div class='col-md-3'><label class='form-control'> " + strdob + "</label>");
            sb_spouse.Append("</div>");
            sb_spouse.Append("</div>");
        }
        sb_spouse.Append("</div>");
        Response.Write(sb_spouse);
        Response.End();
    }
}
