/// <summary>
        /// Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va face refresh la combo-ul cu studii
        /// </summary>
        private void CreateRefreshFunctionForAddAngajat()
        {
            string outStr = "";

            //cream scriptul care va contine functia de refresh
            //ne bazam pe faptul ca se cunoaste numele selectului care contine studiile
            //initial se sterg toate intrarile din combo
            outStr += "<script> \r\n function RefreshAddAngajatPage() \r\n" +
                      "{ \r\n" +
                      "window.opener.DeleteStudiiCombo(); \r\n" +
                      " FillStudiiCOmbo(); \r\n" +
                      "} \r\n";

            //acum se creeaza functie care adauga studiile din recordset
            //se foloseste o functie din AddAngajat ... FillStudiuCombo
            Salaries.Business.AdminStudii objAdminStudii = new Salaries.Business.AdminStudii();

            outStr += " function FillStudiiCOmbo() \r\n" +
                      "{ \r\n";
            foreach (DataRow dataRow in objAdminStudii.LoadInfoStudii().Tables[0].Rows)
            {
                outStr += "window.opener.FillStudiuCombo('" +
                          dataRow["Nume"].ToString() + "'," +
                          dataRow["StudiuID"].ToString() + ");";
            }

            outStr += "} \r\n" +
                      "</script>";

            Response.Write(outStr);
        }
        /// <summary>
        /// Sterge o categorie de studii
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            try
            {
                int studiuId = Convert.ToInt32(txtStudiuID.Text);
                Salaries.Business.AdminStudii studiu = new Salaries.Business.AdminStudii();
                studiu.StudiuId = studiuId;
                int sePoateSterge = studiu.CheckIfStudiuCanBeDeleted();

                if (sePoateSterge == 1)
                {
                    Response.Write("<script> alert('Categoria de studiu nu poate fi stearsa! Este inca asociata unor angajati!'); </script>");
                    FillEditForm();
                }
                if (sePoateSterge == 2)
                {
                    Response.Write("<script> alert('Operatiunea nu a fost efectuata deoarece nomenclatoul trebuie sa contina cel putin o categorie de studii.'); </script>");
                    FillEditForm();
                }
                if (sePoateSterge == 0)
                {
                    studiu.DeleteStudiu();
                    ListareStudii();
                }

                //Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va face refresh la combo-ul cu studii
                CreateRefreshFunctionForAddAngajat();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        /// <summary>
        /// Modifica o categorie de studii
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModify_Click(object sender, System.EventArgs e)
        {
            try
            {
                int studiuId = Convert.ToInt32(txtStudiuID.Text);
                Salaries.Business.AdminStudii studiu = new Salaries.Business.AdminStudii();
                studiu.StudiuId = studiuId;
                studiu.Nume     = txtDenumire.Text;

                if (studiu.CheckIfStudiuCanBeAdded())
                {
                    studiu.UpdateStudiu();
                }
                else
                {
                    Response.Write("<script> alert('Mai exista un studiu cu acelasi nume!'); </script>");
                }

                //Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va face refresh la combo-ul cu studii
                CreateRefreshFunctionForAddAngajat();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
            ListareStudii();
        }
        /// <summary>
        /// Completeaza campurile pentru o categorie de studii
        /// </summary>
        private void FillEditForm()
        {
            try
            {
                int studiuId = Convert.ToInt32(txtStudiuID.Text);
                Salaries.Business.AdminStudii studiu = new Salaries.Business.AdminStudii();
                studiu.StudiuId = studiuId;
                DataRow rowStudiu = studiu.GetStudiuInfo().Tables[0].Rows[0];

                txtDenumire.Text = rowStudiu["Nume"].ToString();
                txtStudiuID.Text = studiuId.ToString();

                td_addLine.Visible  = false;
                td_editLine.Visible = true;
                add_form.Style.Add("display", "");
                add_buttonLine.Visible = false;
                tdTitle.InnerText      = "Editare categorie studiu";

                //Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va face refresh la combo-ul cu studii
                //In acest caz va fi goala ...
                CreateEmptyRefreshFunctionForAddAngajat();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
 private void BindStudiiCombo()
 {
     Salaries.Business.AdminStudii studii = new Salaries.Business.AdminStudii();
     lstStudiiSearch.DataSource     = studii.LoadInfoStudiiUnion();
     lstStudiiSearch.DataValueField = "StudiuID";
     lstStudiiSearch.DataTextField  = "Nume";
     lstStudiiSearch.DataBind();
 }
        /// <summary>
        /// Listarea studiilor
        /// </summary>
        public void ListareStudii()
        {
            try
            {
                TableRow  myRow  = new TableRow();
                TableCell myCell = new TableCell();


                //titlul de la listare
                myCell.CssClass        = "BigBlueBold";
                myCell.HorizontalAlign = HorizontalAlign.Center;
                myCell.VerticalAlign   = VerticalAlign.Middle;
                myCell.Text            = "Lista categoriilor de studiu existente";
                myCell.Height          = new Unit(50);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);

                // lista de banci existente
                myRow  = new TableRow();
                myCell = new TableCell();
                myCell.Attributes.Add("width", "100%");
                myCell.HorizontalAlign = HorizontalAlign.Center;
                myCell.VerticalAlign   = VerticalAlign.Top;
                Table listTable = new Table();

                string[] tableHeader = { "Denumire categorie studiu" };
                string[] tableCols   = { "Nume" };

                Salaries.Business.AdminStudii objAdminStudii = new Salaries.Business.AdminStudii();
                ListTable objListTable = new ListTable(listTable, objAdminStudii.LoadInfoStudii(), tableHeader, tableCols);

                string[] ar_OnClickParam     = { "StudiuID" };
                string[] ar_OnClickParamType = { "dataset" };

                objListTable.OnclickJSMethod   = "SelectLine";
                objListTable.OnclickParams     = ar_OnClickParam;
                objListTable.OnclickParamsType = ar_OnClickParamType;
                objListTable.DrawListTableWithoutDigits();

                myCell.Controls.Add(listTable);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);

                td_editLine.Visible = false;
                add_form.Style.Add("display", "none");
                btnEdit.Style.Add("display", "none");
                td_addLine.Visible     = true;
                add_buttonLine.Visible = true;
                tdTitle.InnerText      = "Adaugare categorie de studiu noua";
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        /// <summary>
        /// Procedura incarca datele unui angajat
        /// </summary>
        private void LoadAngajatDates()
        {
            // Titlurile ce le pot avea angajatii.
            Salaries.Business.AdminTitluriAngajati titluri = new Salaries.Business.AdminTitluriAngajati();

            // Studiile pe care le pot avea angajatii.
            Salaries.Business.AdminStudii studii = new Salaries.Business.AdminStudii();

            // Tarile din sistem.
            Salaries.Business.AdminTari tari = new Salaries.Business.AdminTari();

            try
            {
                // Se completeaza formularul de editare cu datele din baza de date
                lstTitlu.DataSource     = titluri.LoadInfoTitluriAngajati();
                lstTitlu.DataValueField = "TitluID";
                lstTitlu.DataTextField  = "Denumire";
                lstTitlu.DataBind();

                lstStudiu.DataSource     = studii.LoadInfoStudii();
                lstStudiu.DataValueField = "StudiuID";
                lstStudiu.DataTextField  = "Nume";
                lstStudiu.DataBind();

                lstTaraNastere.DataSource     = tari.LoadInfoTariCuJudete();
                lstTaraNastere.DataTextField  = "NumeTara";
                lstTaraNastere.DataValueField = "TaraID";
                lstTaraNastere.DataBind();

                lstDTara.DataSource     = tari.LoadInfoTariCuJudete();
                lstDTara.DataTextField  = "NumeTara";
                lstDTara.DataValueField = "TaraID";
                lstDTara.DataBind();

                lstRTara.DataSource     = tari.LoadInfoTariCuJudete();
                lstRTara.DataTextField  = "NumeTara";
                lstRTara.DataValueField = "TaraID";
                lstRTara.DataBind();

                BindLstDJudetDDL();
                BindLstRJudetDDL();
                BindLstJudetNastereDDL();
                BindLstNationalitateDDL();

                if (!IsPostBack)
                {
                    BindInvaliditateDDL();
                }

                this.chkLstInvalid.SelectedValue = objAngajat.Invaliditate.ToString();

                txtNume.Text                   = objAngajat.Nume;
                txtPrenume.Text                = objAngajat.Prenume;
                txtNumeAnterior.Text           = objAngajat.NumeAnterior.ToString();
                txtDataSchimbariiNumelui.Text  = Utilities.ConvertDateTime2Text(objAngajat.DataSchimbariiNumelui);
                lstStareCivila.SelectedValue   = objAngajat.StareCivila.ToString();
                txtNrCopii.Text                = objAngajat.NrCopii.ToString();
                lstSex.SelectedValue           = objAngajat.Sex.ToString();
                lstNationalitate.SelectedValue = objAngajat.Nationalitate.ToString();
                lstTitlu.SelectedValue         = objAngajat.TitluId.ToString();
                lstStudiu.SelectedValue        = objAngajat.StudiuId.ToString();
                txtAnAbsolvire.Text            = objAngajat.AnAbsolvire.ToString();
                txtNrDiploma.Text              = objAngajat.NrDiploma;
                txtTelefon.Text                = objAngajat.Telefon;
                txtDescriere.Text              = objAngajat.Descriere;
                txtCNP.Text          = objAngajat.CNP.ToString();
                txtCNPAnterior.Text  = objAngajat.CNPAnterior.ToString();
                txtDataNasterii.Text = Utilities.ConvertDateTime2Text(objAngajat.DataNasterii);
                if (objAngajat.TaraNastereId != 0)
                {
                    lstTaraNastere.SelectedValue = TaraNastereHidden.Value == "" ? objAngajat.TaraNastereId.ToString() : TaraNastereHidden.Value;
                }
                if (objAngajat.JudetNastereId != 0)
                {
                    BindLstJudetNastereDDL();
                    lstJudetNastere.SelectedValue = JudetNastereHidden.Value == "" ? objAngajat.JudetNastereId.ToString() : JudetNastereHidden.Value;
                }
                txtLocalitateNastere.Text = objAngajat.LocalitateNastere;
                txtPrenumeMama.Text       = objAngajat.PrenumeMama;
                txtPrenumeTata.Text       = objAngajat.PrenumeTata;

                if (objAngajat.DTara != 0)
                {
                    lstDTara.SelectedValue = DTaraHidden.Value == "" ? objAngajat.DTara.ToString() : DTaraHidden.Value;
                }
                if (objAngajat.DJudetSectorId != 0)
                {
                    BindLstDJudetDDL();
                    lstDJudetSector.SelectedValue = DJudetSectorHidden.Value == "" ? objAngajat.DJudetSectorId.ToString() : DJudetSectorHidden.Value;
                }
                txtDLocalitate.Text = objAngajat.DLocalitate;
                txtDStrada.Text     = objAngajat.DStrada;
                txtDNumar.Text      = objAngajat.DNumar;
                txtDCodPostal.Text  = objAngajat.DCodPostal.ToString();
                txtDBloc.Text       = objAngajat.DBloc;
                txtDScara.Text      = objAngajat.DScara;
                txtDEtaj.Text       = objAngajat.DEtaj;
                txtDApartament.Text = objAngajat.DApartament;

                if (objAngajat.RTara != 0)
                {
                    lstRTara.SelectedValue = RTaraHidden.Value == "" ? objAngajat.RTara.ToString() : RTaraHidden.Value;
                }
                if (objAngajat.RJudetSectorId != 0)
                {
                    BindLstRJudetDDL();
                    lstRJudetSector.SelectedValue = RJudetSectorHidden.Value == "" ? objAngajat.RJudetSectorId.ToString() : RJudetSectorHidden.Value;
                }
                txtRLocalitate.Text = objAngajat.RLocalitate;
                txtRStrada.Text     = objAngajat.RStrada;
                txtRNumar.Text      = objAngajat.RNumar;
                txtRCodPostal.Text  = objAngajat.RCodPostal.ToString();
                txtRBloc.Text       = objAngajat.RBloc;
                txtRScara.Text      = objAngajat.RScara;
                txtREtaj.Text       = objAngajat.REtaj;
                txtRApartament.Text = objAngajat.RApartament;

                DTaraHidden.Value        = DTaraHidden.Value == "" ? lstDTara.SelectedValue : DTaraHidden.Value;
                RTaraHidden.Value        = RTaraHidden.Value == "" ? lstRTara.SelectedValue : RTaraHidden.Value;
                TaraNastereHidden.Value  = TaraNastereHidden.Value == "" ? lstTaraNastere.SelectedValue : TaraNastereHidden.Value;
                DJudetSectorHidden.Value = DJudetSectorHidden.Value == "" ? lstDJudetSector.SelectedValue : DJudetSectorHidden.Value;
                RJudetSectorHidden.Value = RJudetSectorHidden.Value == "" ? lstRJudetSector.SelectedValue : RJudetSectorHidden.Value;
                JudetNastereHidden.Value = JudetNastereHidden.Value == "" ? lstJudetNastere.SelectedValue : JudetNastereHidden.Value;

                CreateVarJavaScript();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }