protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            base.Render(writer);

            Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
            objAngajat.AngajatId = AngajatID;
            objAngajat.LoadAngajat();

            /* Description:Pentru a nu se permite introducerea unui tip de absenta cand angajatul este lichidat,
             * este obtinuta data lichidarii si scrisa pe javascript pentru a se putea face validarile.
             */
            string dataLichidare;

            if ((DateTime.Equals(objAngajat.DataLichidare, System.DBNull.Value)) || (DateTime.Equals(objAngajat.DataLichidare, DateTime.MinValue)))
            {
                dataLichidare = DateTime.MaxValue.ToString("dd.MM.yyyy");
            }
            else
            {
                dataLichidare = objAngajat.DataLichidare.ToString("dd.MM.yyyy");
            }
            Response.Write("<script>DataLichidare =  '" + dataLichidare + "'</script>");

            DateTime DataAngajare = objAngajat.DataDeLa;

            Response.Write("<script>AngajareDataStart =  '" + DataAngajare.ToString("dd.MM.yyyy") + "'</script>");

            //Response.Write( "<script>var CheckIntreruperi = '"+this.CheckInterval.ClientID+"';</script>");
//			//Response.Write( "<script>var IntervIntreruperiID = '"+this.txtIntrerupereID.ClientID+"';</script>");
//			Response.Write( "<script>var ObservatiiIDIntrerupere = '"+this.txtObservatii.ClientID+"';</script>");
//			Response.Write( "<script>var ClientObservatiiID = '"+this.txtObservatii.ClientID+"';</script>");
//
            //string valoare = "<script>var tmpIntreruperi = new CreateIntervalIntreruperiElement('"+this.ClientID+"','"+this.txtDataStart.ClientID+"','"+this.txtDataEnd.ClientID+"','"+this.txtRetinereID.ClientID+"',null,'"+this.txtObservatii.ClientID+"');</script>";
            //Response.Write( valoare );
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            this.AngajatID = this.GetLoggedUserID();

            objectAngajat           = new Salaries.Business.Angajat();
            objectAngajat.AngajatId = AngajatID;
            objectAngajat.LoadAngajat();
        }
示例#3
0
        /// <summary>
        /// Procedura realizeaza autentificarea utilizatorului
        /// </summary>
        /// <param name="AngajatID">Id-ul angajatului</param>
        public void DoQuickLogin(int AngajatID)
        {
            // ************************* obs 1 : to perform login ! - sp - return AngajatID
            Salaries.Business.Angajat a = new Salaries.Business.Angajat();
            a.AngajatId = AngajatID;
            a.LoadAngajat();

            this.SaveSessionKey(Definitions.UserKEY, AngajatID);
            this.SaveSessionKey(Definitions.UserInstanceKEY, a);
        }
示例#4
0
        /// <summary>
        /// Procedura realizeaza autentificarea utilizatorului
        /// </summary>
        /// <param name="Firma">Firma</param>
        /// <param name="Utilizator">Utilizatorul</param>
        /// <param name="Parola">Parola</param>
        public void DoLogin(string Firma, string Utilizator, string Parola)
        {
            // ************************* obs 1 : to perform login ! - sp - return AngajatID
            int AngajatID = 1017;

            Salaries.Business.Angajat a = new Salaries.Business.Angajat();
            a.AngajatId = AngajatID;
            a.LoadAngajat();

            this.SaveSessionKey(Definitions.UserKEY, AngajatID);
            this.SaveSessionKey(Definitions.UserInstanceKEY, a);
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            #region variabile javascript
            string script_text = "<script>var ctrlID = \"" + this.UniqueID + "\"</script>";
            Response.Write(script_text);

            Response.Write("<script>var DateStartID = '" + this.DateStart.ClientID + "';</script>");
            Response.Write("<script>var DateEndID = '" + this.DateEnd.ClientID + "';</script>");
            Response.Write("<script>var ddlTipuriRetineriClient = '" + this.ddlTipuriRetineri.ClientID + "';</script>");
            Response.Write("<script>var txtDenumireRetinereClient = '" + this.txtRetinere.ClientID + "';</script>");
            Response.Write("<script>var txtDataStartClient = '" + this.txtDataStart.ClientID + "';</script>");
            Response.Write("<script>var txtDataEndClient = '" + this.txtDataEnd.ClientID + "';</script>");
            Response.Write("<script>var txtValoareClient = '" + this.txtValoare.ClientID + "';</script>");
            Response.Write("<script>var chkAlertaClient = '" + this.chkAlerta.ClientID + "';</script>");
            Response.Write("<script>var txtRetinereIdClient = '" + this.txtRetinereID.ClientID + "';</script>");
            #endregion

            string[] textTabs = { "Lista retineri angajat", "Adauga retinere angajat" };
            LoadRetineriAngajat();
            SiemensTM.utils.Utilities.CreateHeaderWithTabs(tableTabs, textTabs, "../", true);
            Response.Write("<script> var TipUtilizator = ''; </script>");

            #region angajat, luna activa
            Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
            objAngajat.AngajatId = AngajatID;
            objAngajat.LoadAngajat();

            Salaries.Business.Luni luni     = new Salaries.Business.Luni(objAngajat.AngajatorId);
            Salaries.Data.LunaData lunaData = luni.GetLunaActiva();
            lunaID = lunaData.LunaId;
            dataStartLunaActiva = lunaData.Data;
            #endregion

            Response.Write("<script> LunaActivaDataStart =  '" + dataStartLunaActiva.ToString("dd.MM.yyyy") + "'</script>");

            actiuneRetinere = ((System.Web.UI.HtmlControls.HtmlInputHidden)Page.FindControl("txtActiuneRetinere")).Value;
            if (IsPostBack)
            {
                TransferDateRetinereLaClient();
                HandleActions();
            }
            else
            {
                LoadTipuriRetineri();
                TransferDateRetinereLaClient();
            }
        }
        private void btnGenerati_Click(object sender, System.EventArgs e)
        {
            Salaries.Business.Angajat inspectorResurseUmane = new Salaries.Business.Angajat();
            inspectorResurseUmane.AngajatId = long.Parse(drpInspectorResurseUmane.SelectedValue);
            inspectorResurseUmane.LoadAngajat();

            if (ExistaToateDatele())
            {
                //sunt introduse in sesiune tipul comunicarii, numarul acesteia si suma
                Session["TipComunicare"]     = "adeverinta_medic.xml";
                Session["Numar"]             = txtNrCom.Text;
                Session["DataInregistrarii"] = txtDataInregistrarii.Text;

                // Numele managerului general.
                Session["ManagerGeneral"] = txtManagerGeneral.Text;
                // Numele directorului economic.
                Session["DirectorEconomic"] = txtDirectorEconomic.Text;

                // Numele inspectorului de resurse umane.
                Session["InspectorResurseUmane"] = drpInspectorResurseUmane.SelectedItem.Text;
                // Email-ul inspectorului de resurse umane
                Session["InspResUmaneMail"] = inspectorResurseUmane.Email;
                // Telefonul inspectorului de resurse umane
                Session["InspResUmaneNrTel"] = inspectorResurseUmane.Telefon;

                Response.Redirect("Comunicari/comunicare.aspx?id=" + objAngajat.AngajatId);

                //este generata comunicarea
                lblEroare.Text = "Comunicarea a fost generata.";
            }
            else
            {
                char[] sep           = { ':' };                 //se stabileste separatorul
                Array  aDate         = dateNecesare.Split(sep); //se face impartirea in functie de separator
                string dateNecesareF = "";

                for (int i = 0; i < aDate.Length - 2; i++)
                {
                    dateNecesareF += aDate.GetValue(i).ToString() + ", ";
                }
                dateNecesareF += aDate.GetValue(aDate.Length - 2).ToString();

                lblEroare.Text = "Pentru a genera adeverinta medicala a acestui angajat trebuie sa mai completati urmatoarele campuri: " + dateNecesareF;
            }
        }
 /// <summary>
 /// Procedura determina zilele imposibile din luna
 /// </summary>
 /// <param name="z"></param>
 /// <returns>Returneaza un DataSet care contine aceste date</returns>
 private DataSet GetZileLunaImposibile(Zile z)
 {
     try
     {
         Salaries.Business.Angajat ang = new Salaries.Business.Angajat();
         ang.AngajatId = GetAngajat();
         ang.LoadAngajat();
         //Modified: Ionel Popa
         //Description: Nu se ia in considerare DataPanaLa si DataLichidare
         if (ang.DataLichidare.Year == 1 && ang.DataLichidare.Month == 1 && ang.DataLichidare.Day == 1)
         {
             return(null);
         }
         DataSet ds = z.GetZileLunaImposibile(SelectedDate.Year, SelectedDate.Month, ang.DataLichidare);
         return(ds);
     }
     catch
     {
         return(null);
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Modificat: Cristina Muntean ... se permite modificarea pontajului numai daca luna selectata de
            //utilizator este luna activa a angajatorului sau daca exista situatie lunara pentru angajatul selectat

            //luna selectata de utilizator
            int lunaCurentaID = int.Parse(this.Session[SiemensHR.InterfataSalarii.Classes.Definitions.LunaCurentaKey].ToString());
            //id-ul angajatului selectat in dropdownlist
            int angajatID = this.GetAngajat();

            Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
            objAngajat.AngajatId = angajatID;
            objAngajat.LoadAngajat();

            //luna activa a angajatorului
            Salaries.Business.Luni luna     = new Salaries.Business.Luni(objAngajat.AngajatorId);
            Salaries.Data.LunaData lunaData = luna.GetLunaActiva();

            //se obtine situatie lunara a angajatului
            Salaries.Business.SituatieLunaraAngajat situatieLunaraAng  = new Salaries.Business.SituatieLunaraAngajat(objAngajat.AngajatId);
            Salaries.Data.InfoSituatieLunara        infoSituatieLunara = situatieLunaraAng.GetSituatieLunaraAngajat(objAngajat.AngajatId, lunaData.LunaId);

            //daca luna selectata de utilizator nu este luna activa sau daca nu exista o situatie lunara pentru angajatul selectat
            //atunci se permite doar vizualizarea pontajului,altfel se permite si modificarea acestuia
            if ((lunaCurentaID != lunaData.LunaId) || (infoSituatieLunara.SituatieID == -1))
            {
                //HtmlTableCell IntervaleContainer este ascunsa
                IntervaleContainer.Style.Add("display", "none");
            }
            else
            {
                //HtmlTableCell IntervaleContainer este facuta vizibila
                IntervaleContainer.Style.Add("display", "");
            }

            ClientSelectedDate1 = (System.Web.UI.HtmlControls.HtmlInputHidden)Page.FindControl("ClientSelectedDate");
            this.DoQuickLogin(this.GetAngajat());
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            string script_text = "<script>var ctrlID = \"" + this.UniqueID + "\"</script>";

            Response.Write(script_text);

            Response.Write("<script>var DateStartID = '" + this.DateStart.ClientID + "';</script>");
            Response.Write("<script>var DateEndID = '" + this.DateEnd.ClientID + "';</script>");
            Response.Write("<script>var txtDataStartID = '" + this.txtDataStart.ClientID + "';</script>");
            Response.Write("<script>var txtDataEndID = '" + this.txtDataEnd.ClientID + "';</script>");

            this.txtDataStart.Attributes["onblur"] = " if (document.getElementById(txtDataStartID).value!='') {getIntervalIntreruperi('" + this.ClientID + "').DataStartChanged();" +
                                                     "document.getElementById(DateStartID).value=document.getElementById(txtDataStartID).value;" +
                                                     "if (!isDate(document.getElementById(txtDataStartID).value)) { alert('Data de inceput nu este corecta!'); document.getElementById(txtDataStartID).value='';} }";
            this.txtDataEnd.Attributes["onblur"] = " if (document.getElementById(txtDataEndID).value!='') {getIntervalIntreruperi('" + this.ClientID + "').DataEndIntrerupereChanged(); " +
                                                   "document.getElementById(DateEndID).value=document.getElementById(txtDataEndID).value;" +
                                                   "if (!isDate(document.getElementById(txtDataEndID).value))  { alert('Data de sfarsit nu este corecta!'); document.getElementById(txtDataEndID).value='';} }";

            this.txtObservatii.Attributes["onblur"] = "getIntervalIntreruperi('" + this.ClientID + "').ObservatiiIntreruperiChanged()";

            string[] textTabs = { "Istoric intreruperi CIM", "Adauga intrerupere CIM" };
            LoadIstoricSuspendariCIM();

            SiemensTM.utils.Utilities.CreateHeaderWithTabs(tableTabs, textTabs, "", true);
            Response.Write("<script> var TipUtilizator = ''; </script>");

            Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
            objAngajat.AngajatId = AngajatID;
            objAngajat.LoadAngajat();

            Salaries.Business.Luni luni     = new Salaries.Business.Luni(objAngajat.AngajatorId);
            Salaries.Data.LunaData lunaData = luni.GetLunaActiva();
            dataStartLunaActiva = lunaData.Data;

            Response.Write("<script>LunaActivaDataStart =  '" + dataStartLunaActiva.ToString("dd.MM.yyyy") + "'</script>");
            btnStergeDate.Attributes.Add("onclick", "return CheckDelete('Sunteti sigur ca vreti sa stergeti intreruperea?');");
        }
        /// <summary>
        /// Procedura stabileste valoarea pentru tipul de nationalitate a angajatului
        /// </summary>
        private void CreateVarTipNationalitateDomiciliu()
        {
            int taraBazaID = 0;

            try
            {
                Salaries.Business.AdminTari tari = new Salaries.Business.AdminTari();
                DataSet dsTaraBaza = tari.GetTaraDeBaza();
                taraBazaID = int.Parse(dsTaraBaza.Tables[0].Rows[0]["TaraID"].ToString());
            }
            catch
            {
                taraBazaID = 0;
            }

            Salaries.Business.Angajat ang = new Salaries.Business.Angajat();
            ang.AngajatId = AngajatID;
            ang.LoadAngajat();

            if (ang.Nationalitate == taraBazaID)
            {
                if (ang.DTara == taraBazaID)
                {
                    tipNationalitateDomiciliu = 0;
                }
                else
                {
                    tipNationalitateDomiciliu = 1;
                }
            }
            else
            {
                tipNationalitateDomiciliu = 2;
            }

            Response.Write("<script>var tipNationalitateDomiciliu = " + tipNationalitateDomiciliu + ";</script>");
        }
        //Lungu Andreea - 20.09.2010
        public string ImportFisierSincronizare(string fileName)
        {
            ErrHandler.MyErrHandler.WriteError("SincronizareDateAngajati.ascx - start - ImportFisierSincronizare() - " + fileName);
            string marca = "", numePrenume = "", birou = "";

            Salaries.Data.ImportFisier imp = new Salaries.Data.ImportFisier();
            DataTable dt = imp.GetDataTableFromImport(fileName);

            string mesajImport             = "";

            foreach (DataRow dr in dt.Rows)
            {
                #region preiau datele din row-ul respectiv
                try
                {
                    marca       = dr["Marca"].ToString();
                    numePrenume = dr["Nume si Prenume"].ToString();
                    birou       = dr["Birou"].ToString();
                }
                catch (Exception exc)
                {
                    mesajImport += "Fisierul nu este in formatul corespunzator";
                    ErrHandler.MyErrHandler.WriteError("SincronizareDateAngajati.ascx - error - ImportFisierSincronizare() - 'Fisierul nu este in formatul corespunzator' ");
                    break;
                }
                #endregion

                #region determin id-ul angajatului pe baza marcii
                //determin id-ul angajatului pe baza marcii
                Salaries.Business.Angajat ang = new Salaries.Business.Angajat();
                ang.Marca = marca;
                int idAngajat = ang.GetAngajatIDByMarca(marca);
                ang.AngajatId = idAngajat;
                ang.LoadAngajat();

//				ang.LoadAngajat();
//				bool esteLichidat = true;
//				if ((ang.DataLichidare == DateTime.MinValue) || (ang.DataLichidare>dataStartLunaActiva))
//					esteLichidat = false;
                #endregion

                //if ((idAngajat != -1) && (!esteLichidat))
                if (idAngajat != -1)
                {
                    ang.Birou = birou;
                    ang.UpdateAngajat();
                }
                else
                {
                    if (!dr["Marca"].ToString().Equals(""))
                    {
                        mesajImport += "Nu exista angajatul cu marca " + dr["Marca"].ToString() + Environment.NewLine;
                    }
                    //ar trebui sa scriu intr-un fisier ca sa pot da un feedback
                    //if (esteLichidat)
                    //	mesajImport += "Angajatul " + dr["Nume si Prenume"].ToString() + " este lichidat.";
                }
            }
            ErrHandler.MyErrHandler.WriteError("SincronizareDateAngajati.ascx - end - ImportFisierSincronizare() - " + fileName);
            if (mesajImport.Equals(""))
            {
                mesajImport = "Sincronizarea datelor a fost realizata.";
            }
            return(mesajImport);
        }
        /// <summary>
        /// Se vizualizeaza nota de lichidare
        /// </summary>
        private void btnPreview_Click()
        {
            /*
             * Modified:  Oprescu Claudia
             * Date:      02.03.2006
             * Descriere: Modificarea consta in validarea datelor de intrare
             */

            //variabila booleana care indica daca au fost completate toate campurile obligatorii
            bool fill = true;
            //variabila booleana care indica daca au fost completate corect campurile
            bool correct = true;

            Salaries.Data.LichidareStruct lichidare = new Salaries.Data.LichidareStruct();
            Salaries.Business.Angajat     angajat   = new Salaries.Business.Angajat();
            angajat.AngajatId = GetAngajat();
            angajat.LoadAngajat();

            //se verifica daca au fost completate campurile
            if (txtNrInregistrare.Text == "" || txtDataLichidare.Text == "" || txtDataInregistrare.Text == "")
            {
                fill = false;
            }
            try
            {
                lichidare.NrInregistrare = txtNrInregistrare.Text;
                lichidare.DataLichidare  = Utilities.ConvertText2DateTime(txtDataLichidare.Text);

                lichidare.NrArticol         = txtNrArticol.Text;
                lichidare.AvansuriDecontare = decimal.Parse(txtAvansuriDecontare.Text);
                lichidare.Abonamente        = decimal.Parse(txtAbonamente.Text);
                lichidare.TicheteMasa       = decimal.Parse(txtTicheteMasa.Text);
                lichidare.EchipamentLucru   = decimal.Parse(txtEchipamentLucru.Text);
                lichidare.Laptop            = decimal.Parse(txtLaptop.Text);
                lichidare.TelServiciu       = decimal.Parse(txtTelServiciu.Text);
                lichidare.ObiecteInventar   = decimal.Parse(txtObiecteInventar.Text);
                lichidare.Carti             = decimal.Parse(txtCarti.Text);
                lichidare.CD = decimal.Parse(txtCD.Text);

                lichidare.DataInregistrare = Utilities.ConvertText2DateTime(txtDataInregistrare.Text);
                if (txtLunaRetinere.Text == "")
                {
                    lichidare.LunaRetinere = Utilities.ConvertText2DateTime("1.1.1753");
                }
                else
                {
                    lichidare.LunaRetinere = Utilities.ConvertText2DateTime(txtLunaRetinere.Text);
                }
            }
            catch (Exception)
            {
                //in cazul in care apare o eroare la conversie inseamna ca nu au fost completate corect campurile
                correct = false;
            }
            if (fill && correct)
            {
                //tre afisata nota de lichidare, in vederea printarii
                //javascript
                StringBuilder jScript = new StringBuilder();
                jScript.Append("<script language=\"JavaScript\">");
                jScript.Append("window.open('../Comunicari/comunicare.aspx?id=" + objAngajat.AngajatId + "', null,'status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')");
                jScript.Append("</script>");

                AdaugaInSesiune();

                Response.Write(jScript.ToString());
            }
            else
            {
                //in functie de eroare este afisat mesajul corespunzator
                if (!correct)
                {
                    Response.Write("<script>alert( 'Datele introduse nu sunt corecte!' );</script>");
                }
                if (!fill)
                {
                    Response.Write("<script>alert( 'Trebuie sa completati toate datele!' );</script>");
                }
            }
        }
        /// <summary>
        /// Initializeaza luna
        /// </summary>
        private void InitializareLunaClick()
        {
            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - start - click_initializareLuna()");
            // Va contine salariile indexate ale angajatilor.
            DataSet dsSalariiIndexate = new DataSet();

            Salaries.Business.Luni luna = new Salaries.Business.Luni(this.GetAngajator());
            ArrayList categs            = new ArrayList();

            /*
             * Adaugat:		Oprescu Claudia
             * Data:		24.04.2007
             * Descriere:	Daca exista angajati carora le-a expirat contractul de munca, nu se permite initializarea lunii pentru care trebuie facuta indexarea
             */
            if (performIndexing && ((this.SelectedDate.Month == 4) || (this.SelectedDate.Month == 10)))
            {
                Salaries.Business.Angajat angajati = new Salaries.Business.Angajat();
                Salaries.Business.IstoricSchimbareDateAngajat dataPosibilaIndexare = new Salaries.Business.IstoricSchimbareDateAngajat();
                dataPosibilaIndexare.DataStart = luna.GetLunaActiva().Data;
                while (dataPosibilaIndexare.DataEsteZiSarbatoare())
                {
                    dataPosibilaIndexare.DataStart = dataPosibilaIndexare.DataStart.AddDays(1);
                }
                DataSet dsAngajatiExpiraContract = angajati.GetAngajatiExpiraContractLunaCurenta(dataPosibilaIndexare.DataStart);
                if (dsAngajatiExpiraContract.Tables[0].Rows.Count != 0)
                {
                    Response.Write("<script> alert('Exista angajati carora le-a expirat contractul de munca, adica data de sfarsit a contractului este mai mica decat prima zi lucratoare a lunii curente. \\nPentru a vizualiza acesti angajati, accesati modulul Home al aplicatiei. \\nVa rugam actualizati data de sfarsit a contractului pentru acesti angajati pentru a se putea efectua indexarea. \\nVa multumim!'); </script>");
                    return;
                }
            }

            InitializeOreLucrateLunaAngajati();

            if (this.lstCategorii.SelectedIndex == 0)
            {
                for (int i = 1; i < this.lstCategorii.Items.Count; i++)
                {
                    categs.Add(int.Parse(this.lstCategorii.Items[i].Value));
                }
            }
            else
            {
                categs.Add(this.lstCategorii.SelectedValue);
            }

            /*
             * Adaugat:  Muntean Raluca Cristina
             * Data:     29.12.2005
             * Descriere:Sunt calculate salariile indexate ale angajatilor
             * si introduce schimbarea in baza de date.
             *
             * Modificat:
             *		- Ionel Popa - 18.12.2006: indexarea se face o data la sase luni: aprilie si octombrie
             */
            if (performIndexing && ((this.SelectedDate.Month == 4) || (this.SelectedDate.Month == 10)))
            {
                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - start - indexare");
                //a fost exectuata indexare si campul pentru specificarea indexarii este inactiv
                tdIndexare.Disabled      = true;
                indexareCheckBox.Checked = true;

                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - start - calcul salarii indexate");
                dsSalariiIndexate = luna.CalculSalariiIndexate(this.GetAngajator());
                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - end - calcul salarii indexate");

                Salaries.Business.Angajat ang = new Salaries.Business.Angajat();
                Salaries.Business.IstoricSchimbareDateAngajat isda;
                Salaries.Data.LunaData lunaActiva = luna.GetLunaActiva();
                string dataLunaActiva             = lunaActiva.Data.ToShortDateString();

                //Se creaza noul interval de schimbari:
                //Va contine ca data de start inceputul lunii si ca data de sfarsit DataTime.MaxValue
                Salaries.Business.IstoricSchimbareDateAngajat intsch = new Salaries.Business.IstoricSchimbareDateAngajat();
                intsch.DataEnd   = DateTime.MaxValue;
                intsch.DataStart = DateTime.Parse(dataLunaActiva);
                //se stabileste data de inceput a schimbarii
                //daca este o zi de sarbatoare, se va lua data urmatoare
                while (intsch.DataEsteZiSarbatoare())
                {
                    intsch.DataStart = intsch.DataStart.AddDays(1);
                }

                Salaries.Business.IstoricSchimbareDateAngajat interv;
                //Un angajat poate avea cel putin un interval care se termina inaintea datei de inceput a intervalului de schimbare
                //In acest caz retinem acest interval
                //Salaries.Business.IstoricSchimbareDateAngajat possibleLastInterval;

                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - start - schimbare date angajat(sal indexat)");
                foreach (DataRow angajatRow in dsSalariiIndexate.Tables[0].Rows)
                {
                    ang.AngajatId = long.Parse(angajatRow["AngajatID"].ToString());
                    ang.LoadAngajat();

                    //Se initializeaza schimbarile angajatului
                    isda             = new Salaries.Business.IstoricSchimbareDateAngajat();
                    isda.AngajatId   = ang.AngajatId;
                    isda.DataStart   = intsch.DataStart;
                    intsch.AngajatId = ang.AngajatId;

                    if (!ang.IsLichidat)
                    {
                        interv = new Salaries.Business.IstoricSchimbareDateAngajat();
                        DataSet existaCapat = new DataSet();

                        //Se verifica daca data de angajare este diferita de inceputul intervalului de schimbare
                        //In cazul in care sunt egale ... nu se face indexarea

                        /*if(ang.DataDeLa != intsch.DataStart)
                         * {
                         *      //Se extrage intervalul precedent intervalului de schimbare
                         *      isda.DataStart = intsch.DataStart.AddDays( -1 );
                         *      interv = isda.GetIntervalSchimbareByDataInside();
                         *      //In cazul in care angajatul a fost angajat pe o perioada determinata e posibil sa nu existe un interval care sa includa aceasta data
                         *      if( interv.ProgramLucru == -1)
                         *      {
                         *              interv = isda.GetLastIntervalSchimbare();
                         *              //Se seteaza doar DataEnd pentru ca aceasta e necesara mai jos in InsertCapatIntervalSchimbareAngajat/UpdateCapatIntervalSchimbareAngajat
                         *              interv.DataStart = intsch.DataStart.AddDays( -1 );
                         *              //Initializam si acest interval
                         *              possibleLastInterval = isda.GetLastIntervalSchimbare();
                         *              possibleLastInterval.DataStart = intsch.DataStart.AddDays( -1 );
                         *              isda.CategorieId = interv.CategorieId;
                         *              possibleLastInterval.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();
                         *      }
                         *      else
                         *      {
                         *              isda.CategorieId = interv.CategorieId;
                         *              interv.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();
                         *              //Initializam si acest interval
                         *              isda.DataStart = intsch.DataStart.AddDays( -1 );
                         *              possibleLastInterval = isda.GetIntervalSchimbareByDataInside();
                         *              isda.CategorieId = interv.CategorieId;
                         *              possibleLastInterval.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();
                         *      }
                         *
                         *
                         *      //Se verifica daca data de start a intervalului de schimbare este capat de interval
                         *      //Aceasta verificare este necesara pentru ca intervalele sa fie continue
                         *      //De ex: in cazul in care exista un capat mai mic decat capatul de start al intervalului de schimbare acesta este actualizat cu capatul de start al intervalului de schimbare
                         *      //!!Prin actiunea de mai jos se seteaza ca si capat de interval ultima zi a lunii precedente
                         *      isda.DataStart = intsch.DataStart.AddDays( -1 );
                         *      existaCapat = isda.GetCapatIntervalAngajatZi();
                         *      if ( existaCapat == null || existaCapat.Tables[ 0 ].Rows.Count == 0 )
                         *      {
                         *              //Daca nu exista un capat de interval acesta va fi inserat
                         *              interv.InsertCapatIntervalSchimbareAngajat();
                         *      }
                         *      else
                         *      {
                         *              //Daca exista un capat de interval acesta este actualizat
                         *              interv.IntervalAngajatId = int.Parse( existaCapat.Tables[ 0 ].Rows[ 0 ][ "IntervalAngajatID" ].ToString());
                         *              interv.UpdateCapatIntervalSchimbareAngajat();
                         *      }
                         *
                         *      //Se actulizeaza salariul de baza cu cel indexat
                         *      intsch.SalariuBaza = decimal.Parse( angajatRow["SalariuIndexat"].ToString() );
                         *      //Se insereaza schimbarea pentru angajatul curent
                         *      intsch.InsertSchimbareSalariuBaza();
                         *
                         *      //Se seteaza ca si capat de interval inceputul lunii active
                         *      isda.DataStart = intsch.DataStart;
                         *      interv = isda.GetIntervalSchimbareByDataInside();
                         *      if( interv.ProgramLucru == -1)
                         *      {
                         *              interv = possibleLastInterval;
                         *              interv.DataStart = DateTime.Parse(dataLunaActiva );
                         *      }
                         *      interv.SalariuBaza = intsch.SalariuBaza;
                         *      isda.CategorieId = interv.CategorieId;
                         *      interv.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();
                         *
                         *      isda.DataStart = intsch.DataStart;
                         *      existaCapat = isda.GetCapatIntervalAngajatZi();
                         *      if( existaCapat == null || existaCapat.Tables[ 0 ].Rows.Count == 0 )
                         *      {
                         *              interv.InsertCapatIntervalSchimbareAngajat();
                         *      }
                         *      else
                         *      {
                         *              interv.IntervalAngajatId = int.Parse( existaCapat.Tables[ 0 ].Rows[ 0 ][ "IntervalAngajatID" ].ToString());
                         *              interv.UpdateCapatIntervalSchimbareAngajat();
                         *      }
                         * }*/

                        //Se verifica daca data de angajare este diferita de inceputul intervalului de schimbare
                        //In cazul in care sunt egale ... nu se face indexarea
                        if (ang.DataDeLa != intsch.DataStart)
                        {
                            //Se extrage intervalul precedent intervalului de schimbare
                            isda.DataStart = intsch.DataStart.AddDays(-1);
                            //daca este o zi de sarbatoare, se va trece la ziua anterioara pana se va gasi o zi care nu este sarbatoare
                            while (isda.DataEsteZiSarbatoare())
                            {
                                isda.DataStart = isda.DataStart.AddDays(-1);
                            }
                            interv             = isda.GetIntervalSchimbareByDataInside();
                            isda.CategorieId   = interv.CategorieId;
                            interv.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();

                            //Se verifica daca data de start a intervalului de schimbare este capat de interval
                            //Aceasta verificare este necesara pentru ca intervalele sa fie continue
                            //De ex: in cazul in care exista un capat mai mic decat capatul de start al intervalului de schimbare acesta este actualizat cu capatul de start al intervalului de schimbare
                            //!!Prin actiunea de mai jos se seteaza ca si capat de interval ultima zi a lunii precedente
                            isda.DataStart = intsch.DataStart.AddDays(-1);
                            //daca este o zi de sarbatoare, se va trece la ziua anterioara pana se va gasi o zi care nu este sarbatoare
                            while (isda.DataEsteZiSarbatoare())
                            {
                                isda.DataStart = isda.DataStart.AddDays(-1);
                            }
                            existaCapat = isda.GetCapatIntervalAngajatZi( );
                            if (existaCapat == null || existaCapat.Tables[0].Rows.Count == 0)
                            {
                                //Daca nu exista un capat de interval acesta va fi inserat
                                interv.InsertCapatIntervalSchimbareAngajat();
                            }
                            else
                            {
                                //Daca exista un capat de interval acesta este actualizat
                                interv.IntervalAngajatId = int.Parse(existaCapat.Tables[0].Rows[0]["IntervalAngajatID"].ToString());
                                interv.UpdateCapatIntervalSchimbareAngajat();
                            }
                        }

                        //Se actulizeaza salariul de baza cu cel indexat
                        intsch.SalariuBaza = decimal.Parse(angajatRow["SalariuIndexat"].ToString());
                        //Se insereaza schimbarea pentru angajatul curent
                        intsch.InsertSchimbareSalariuBaza();

                        //Se seteaza ca si capat de interval inceputul lunii active
                        isda.DataStart     = intsch.DataStart;
                        interv             = isda.GetIntervalSchimbareByDataInside();
                        interv.SalariuBaza = intsch.SalariuBaza;
                        isda.CategorieId   = interv.CategorieId;
                        interv.CategorieId = isda.GetCategorieCorspunzatoareDinLunaActiva();

                        isda.DataStart = intsch.DataStart;
                        existaCapat    = isda.GetCapatIntervalAngajatZi();
                        if (existaCapat == null || existaCapat.Tables[0].Rows.Count == 0)
                        {
                            interv.InsertCapatIntervalSchimbareAngajat();
                        }
                        else
                        {
                            interv.IntervalAngajatId = int.Parse(existaCapat.Tables[0].Rows[0]["IntervalAngajatID"].ToString());
                            interv.UpdateCapatIntervalSchimbareAngajat();
                        }
                    }
                }
                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - end - schimbare date angajat(sal indexat)");
                ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - end - indexare");
            }

            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - start - adaugarea etichetelor asociate retinerilor");
            //Adaugat:		Oprescu Claudia
            //Descriere:	La initializarea fiecarei luni se adauga etichetele asociate acesteia
            Salaries.Business.TypesOfRestraints tr = new Salaries.Business.TypesOfRestraints();
            tr.InsertLabel(this.GetCurrentMonth());

            //Descriere:	Pentru fiecare angajat se adauga valori pentru retinerea din luna nou adaugata
            Salaries.Business.Angajat angajat = new Salaries.Business.Angajat();
            DataSet angajatiID = angajat.GetAngajatIDAll();

            foreach (DataRow dr in angajatiID.Tables[0].Rows)
            {
                long AngajatID = long.Parse(dr["AngajatID"].ToString());
                Salaries.Business.TipuriRetineriValori trv = new Salaries.Business.TipuriRetineriValori();
                trv.InsertRetineriValori(this.GetCurrentMonth(), AngajatID);
            }
            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - end - adaugarea etichetelor asociate retinerilor");

            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - start - generare situatii lunare");
            for (int i = 0; i < categs.Count; i++)
            {
                int CategorieID = int.Parse(categs[i].ToString());

                DataSet CategorieAngajati = new Salaries.Business.CategoriiAngajat().GetCategorieAngajati(CategorieID);

                foreach (DataRow dr in CategorieAngajati.Tables[0].Rows)
                {
                    long AngajatID = long.Parse(dr["AngajatID"].ToString());

                    Salaries.Business.SituatieLunaraAngajat sla = new Salaries.Business.SituatieLunaraAngajat(AngajatID);
                    sla.GenerareSituatieLunaraAngajat(this.GetCurrentMonth(), this.GetAngajator());

                    //se adauga valorile retinerilor pentru un angajat dintr-o luna
                    //Salaries.Business.TipuriRetineriValori().InsertRetineriValori(this.GetCurrentMonth(), this.GetAngajator());

                    Salaries.Data.InfoSituatieLunara isl = sla.GetSituatieLunaraAngajat(AngajatID, this.GetCurrentMonth());

                    //Salaries.Business.SituatieLunaraAngajat sla = new Salaries.Business.SituatieLunaraAngajat(AngajatID);

                    Salaries.Data.InfoSituatieLunara x = new Salaries.Data.InfoSituatieLunara();

                    x.SituatieID                = -1;
                    x.AngajatID                 = AngajatID;
                    x.LunaID                    = this.GetCurrentMonth();
                    x.NrZileLuna                = isl.NrZileLuna;
                    x.NrOreConcediuBoala        = isl.NrOreConcediuBoala;
                    x.NrOreConcediuOdihna       = isl.NrOreConcediuOdihna;
                    x.NrOreEvenimDeoseb         = isl.NrOreEvenimDeoseb;
                    x.NrOreInvoire              = isl.NrOreInvoire;
                    x.NrOreObligatiiCetatenesti = isl.NrOreObligatiiCetatenesti;
                    x.NrOreAbsenteNemotivate    = isl.NrOreAbsenteNemotivate;
                    x.NrOreConcediuFaraPlata    = isl.NrOreConcediuFaraPlata;
                    x.NrOreLucrate              = isl.NrOreLucrate;
                    //x.NrOreSup100Proc = isl.NrOreSup100Proc;
                    //x.NrOreSup50Proc = isl.NrOreSup50Proc;
                    x.NrOreSup100Proc = int.Parse(this.txtNrOreSup100Proc.Text);
                    x.NrOreSup50Proc  = int.Parse(this.txtNrOreSup50Proc.Text);

                    x.PrimeSpeciale     = decimal.Parse(this.txtPrimeSpeciale.Text);
                    x.SporActivitatiSup = decimal.Parse(this.txtSporActivitatiSup.Text);
                    x.EmergencyService  = decimal.Parse(this.txtEmergencyService.Text);
                    x.AlteDrepturi      = decimal.Parse(this.txtAlteDrepturi.Text);
                    x.AlteDrepturiNet   = decimal.Parse(this.txtAlteDrepturiNet.Text);
                    x.Avans             = decimal.Parse(this.txtAvans.Text);
                    x.PrimaProiect      = decimal.Parse(this.txtPrimaProiect.Text);

                    //se calculeaza suma pe care trebuie sa o plateasca cei scutiti de contributia la sanatate
                    int lunaID = this.GetCurrentMonth();
                    x.RetinereSanatate = 0;
                    x.CategorieID      = CategorieID;

                    sla.AddSituatieLunaraAngajat(x, true);

                    //distribuie orele suplimentare
                    //ore 100%
                    lunaID = this.GetCurrentMonth();
                    Salaries.Business.Luni l  = new Salaries.Business.Luni(this.GetAngajator());
                    Salaries.Data.LunaData ld = l.GetDetalii(lunaID);
                    int tipIntervalID         = new SiemensTM.Classes.IntervaleAngajat(AngajatID).GetTipIntervalIDByName(Salaries.Business.SituatieLunaraAngajat.denumireOreLucrate[1]);;
                    int valEroare             = new SiemensTM.Classes.IntervaleAngajat(AngajatID).DistribuieOreSuplimentareTip(ld.Data, tipIntervalID, x.NrOreSup50Proc, 0, 0);

                    /*if ( valEroare == 1 )
                     * {
                     *      Response.Write( "<script>alert( 'Numarul de ore suplimentare 100% depaseste numarul de ore disponibile!' );</script>" );
                     * }*/

                    //ore 200%
                    tipIntervalID = new SiemensTM.Classes.IntervaleAngajat(AngajatID).GetTipIntervalIDByName(Salaries.Business.SituatieLunaraAngajat.denumireOreLucrate[2]);;
                    valEroare     = new SiemensTM.Classes.IntervaleAngajat(AngajatID).DistribuieOreSuplimentareTip(ld.Data, tipIntervalID, x.NrOreSup100Proc, 0, 1);

                    //Reportare
                    sla.ReporteazaDiferentaCorectiTichete(lunaID);
                    sla.GenerareSituatieLunaraAngajat(this.GetCurrentMonth(), this.GetAngajator());

                    /*if ( valEroare == 1 )
                     * {
                     *      Response.Write( "<script>alert( 'Numarul de ore suplimentare 200% depaseste numarul de ore disponibile!' );</script>" );
                     * }*/
                }
            }
            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - click_initializareLuna() - end - generare situatii lunare");
            ErrHandler.MyErrHandler.WriteError("InitializareLuna.ascx - end - click_initializareLuna()");
        }
        /// <summary>
        /// Salveaza datele unui angajat
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butSaveAngajat_Click(object sender, System.EventArgs e)
        {
            try
            {
                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;

                lstDTara.SelectedValue       = DTaraHidden.Value;
                lstRTara.SelectedValue       = RTaraHidden.Value;
                lstTaraNastere.SelectedValue = TaraNastereHidden.Value;

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

                lstDJudetSector.SelectedValue = DJudetSectorHidden.Value;
                lstRJudetSector.SelectedValue = RJudetSectorHidden.Value;
                lstJudetNastere.SelectedValue = JudetNastereHidden.Value;

                //Date personale
                objAngajat.Nume                  = txtNume.Text;
                objAngajat.Prenume               = txtPrenume.Text;
                objAngajat.NumeAnterior          = txtNumeAnterior.Text;
                objAngajat.DataSchimbariiNumelui = Utilities.ConvertText2DateTime(txtDataSchimbariiNumelui.Text);
                objAngajat.StareCivila           = Convert.ToByte(lstStareCivila.SelectedValue, 10);
                objAngajat.NrCopii               = Convert.ToByte(txtNrCopii.Text, 10);
                objAngajat.Sex           = lstSex.SelectedValue;
                objAngajat.Nationalitate = int.Parse(lstNationalitate.SelectedValue);
                objAngajat.TitluId       = Convert.ToInt32(lstTitlu.SelectedValue, 10);
                objAngajat.StudiuId      = Convert.ToInt32(lstStudiu.SelectedValue, 10);
                if (txtAnAbsolvire.Text != "")
                {
                    objAngajat.AnAbsolvire = int.Parse(txtAnAbsolvire.Text);
                }
                objAngajat.NrDiploma = txtNrDiploma.Text;
                objAngajat.Telefon   = txtTelefon.Text;
                objAngajat.Descriere = txtDescriere.Text;

                if ((filePozaAngajat.PostedFile.FileName != "") || (filePozaAngajat.PostedFile.ContentLength != 0))
                {
                    string contentFile = filePozaAngajat.PostedFile.ContentType.ToString();

                    if (contentFile.Substring(0, 5) == "image")
                    {
                        //Modificat: Oprescu Claudia
                        //Descriere: Se incearca copierea. Daca poza depaseste dimensiunea se arunca o exceptie
                        try
                        {
                            objAngajat.PozaAngajat = CopiazaPozaPeServer();
                        }
                        catch (Exception ex)
                        {
                            Response.Write("<script>alert('" + ex.Message + "');</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Se pot salva numai fisiere de tip image (gif, jpg, jpeg...)!');</script>");
                    }
                }

                //Domiciliul  - Resedinta
                objAngajat.DTara          = Convert.ToInt32(lstDTara.SelectedValue, 10);
                objAngajat.DJudetSectorId = Convert.ToInt32(lstDJudetSector.SelectedValue, 10);
                objAngajat.DLocalitate    = txtDLocalitate.Text;
                objAngajat.DStrada        = txtDStrada.Text;
                objAngajat.DNumar         = txtDNumar.Text;
                objAngajat.DCodPostal     = long.Parse(txtDCodPostal.Text);
                objAngajat.DScara         = txtDScara.Text;
                objAngajat.DBloc          = txtDBloc.Text;
                objAngajat.DEtaj          = txtDEtaj.Text;
                objAngajat.DApartament    = txtDApartament.Text;

                objAngajat.RTara          = Convert.ToInt32(lstRTara.SelectedValue, 10);
                objAngajat.RJudetSectorId = Convert.ToInt32(lstRJudetSector.SelectedValue, 10);
                objAngajat.RLocalitate    = txtRLocalitate.Text;
                objAngajat.RApartament    = txtRApartament.Text;
                objAngajat.RBloc          = txtRBloc.Text;
                objAngajat.RCodPostal     = long.Parse(txtRCodPostal.Text);
                objAngajat.REtaj          = txtREtaj.Text;
                objAngajat.RNumar         = txtRNumar.Text;
                objAngajat.RScara         = txtRScara.Text;
                objAngajat.RStrada        = txtRStrada.Text;

                //Buletin pasaport
                objAngajat.CNP               = Convert.ToInt64(txtCNP.Text, 10);
                objAngajat.DataNasterii      = Utilities.ConvertText2DateTime(txtDataNasterii.Text);
                objAngajat.TaraNastereId     = Convert.ToInt32(lstTaraNastere.SelectedValue, 10);
                objAngajat.JudetNastereId    = Convert.ToInt32(lstJudetNastere.SelectedValue, 10);
                objAngajat.LocalitateNastere = txtLocalitateNastere.Text;
                objAngajat.PrenumeMama       = txtPrenumeMama.Text;
                objAngajat.PrenumeTata       = txtPrenumeTata.Text;

                objAngajat.CIDataEliberarii = Utilities.ConvertText2DateTime(txtCIDataEliberarii.Text);
                objAngajat.CIEliberatDe     = txtCIEliberatDe.Text;
                objAngajat.CINumar          = txtCINumar.Text;
                objAngajat.CISerie          = txtCISerie.Text;

                if (txtCIValabilPanaLa.Text != "")
                {
                    objAngajat.CIValabilPanaLa = Utilities.ConvertText2DateTime(txtCIValabilPanaLa.Text);
                }

                objAngajat.PASDataEliberarii = Utilities.ConvertText2DateTime(txtPASDataEliberarii.Text);
                objAngajat.PASEliberatDe     = txtPASEliberatDe.Text;
                objAngajat.PASNumar          = txtPASNumar.Text;
                objAngajat.PASSerie          = txtPASSerie.Text;
                objAngajat.PASValabilPanaLa  = Utilities.ConvertText2DateTime(txtPASValabilPanaLa.Text);
                objAngajat.Invaliditate      = short.Parse(chkLstInvalid.SelectedValue);

                // added by Anca Holostencu:
                // NIF nu poate avea valoarea NULL
                objAngajat.NIF = "";

                objAngajat.UpdateAngajat();

                DTaraHidden.Value        = "";
                RTaraHidden.Value        = "";
                TaraNastereHidden.Value  = "";
                DJudetSectorHidden.Value = "";
                RJudetSectorHidden.Value = "";
                JudetNastereHidden.Value = "";

                long idAng = objAngajat.AngajatId;
                objAngajat           = new Salaries.Business.Angajat();
                objAngajat.AngajatId = idAng;
                objAngajat.LoadAngajat();

                CreateVarTipNationalitateDomiciliu(objAngajat);
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        /// <summary>
        /// Afiseaza lista cu checkup-uri
        /// </summary>
        private void LoadFormCheckupuri()
        {
            try
            {
                settings = Salaries.Configuration.ModuleConfig.GetSettings();
                UtilitiesDb utilDb = new UtilitiesDb(settings.ConnectionString);
                listTable.Rows.Clear();

                //Modificat:Muntean Raluca Cristina  - am adaugat ca parametru si id-ul angajatorului
                utilDb.CreateAngajatiSelectBoxEx(this.lstResponsabil, this.GetAngajator());

                Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
                objAngajat.AngajatId = AngajatID;
                objAngajat.LoadAngajat();

                this.lstResponsabil.SelectedValue = "-1";
                if (objAngajat.SefId.ToString() != "-1")
                {
                    if (lstResponsabil.Items.FindByValue(this.SefID.ToString()) != null)
                    {
                        this.lstResponsabil.SelectedValue = this.SefID.ToString();
                    }
                }

                listTable.Attributes.Add("width", "100%");
                listTable.Style.Add("border", "1px solid #20b2aa");
                listTable.Attributes.Add("cellpadding", "0");
                listTable.Attributes.Add("cellspacing", "1");

                Salaries.Business.Checkupuri checkupList = new Salaries.Business.Checkupuri();
                checkupList.AngajatId = AngajatID;

                string[] arHeader = { "Necesar Instruire", "Data urmatorului", "Responsabil", "Data efectuarii", "Fisier Checkup", "Tip Fisier" };
                string[] arCols   = { "NecesarInstruire", "DataUrmatorului", "NumeIntreg", "DataEfectuarii", "CheckupFile", "CheckupID" };

                ListTable objListTable = new ListTable(listTable, checkupList.LoadCheckupuriAngajat(), arHeader, arCols);

                objListTable.textForEmptyDataSet = "Nu exista nici un checkup asociat acestui angajat!";

                string[] ar_OnClickParam     = { AngajatID.ToString(), "CheckupID", "NecesarInstruire", "DataEfectuarii", "ResponsabilID", "DataUrmatorului", "CheckupFile" };
                string[] ar_OnClickParamType = { "const", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset" };

                objListTable.OnclickParams     = ar_OnClickParam;
                objListTable.OnclickParamsType = ar_OnClickParamType;
                objListTable.OnclickJSMethod   = "SelectCheckup";

                objListTable.DrawListTableWithoutDigits();

                for (int i = 1; i < listTable.Rows.Count - 1; i++)
                {
                    TableRow r = listTable.Rows[i];

                    //Daca linia nu este separator (are mai multe celule)
                    if (r.Cells.Count >= 6)
                    {
                        if (r.Cells[3].Text == "")
                        {
                            r.Cells[3].Text = "NU ESTE ANGAJAT AL FIRMEI";
                        }

                        string name     = "Checkup_" + r.Cells[6].Text + "_" + r.Cells[5].Text;
                        string FullPath = GetCheckupPath() + "//" + name;

                        if (Session["Recrutori"].ToString() == "Recrutori")
                        {
                            if (r.Cells[5].Text.Length == 0)
                            {
                                r.Cells[5].Text = " nu exista "; r.Cells[6].Text = "n/a";
                            }
                            else
                            {
                                r.Cells[6].Text = "<img src='../utils/ShowIcon.aspx?AngajatID=" + this.AngajatID + "&CheckupID=" + r.Cells[6].Text + "&file=" + r.Cells[5].Text + "'>";
                            }
                        }
                        else
                        {
                            if (r.Cells[5].Text.Length == 0)
                            {
                                r.Cells[5].Text = " nu exista "; r.Cells[6].Text = "n/a";
                            }
                            else
                            {
                                r.Cells[6].Text = "<img src='utils/ShowIcon.aspx?AngajatID=" + this.AngajatID + "&CheckupID=" + r.Cells[6].Text + "&file=" + r.Cells[5].Text + "'>";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                //se obtine tipul de autentificare la aplicatie
                string authentication = Salaries.Configuration.CryptographyClass.getSettingsWithoutDecode("authentication");

                //virtual path
                string    path      = Page.Request.FilePath;
                char      separator = '/';
                string [] pathArr   = path.Split(separator);
                int       nr        = pathArr.Length;

                //autentificare de tip windows
                if (authentication == "1")
                {
                    //user-ul loginat
                    user = new WindowsPrincipal(WindowsIdentity.GetCurrent());

                    //user-ul loginat nu are dreptul sa acceseze aceasta pagina este redirectat catre o pagina care sa il instiinteze de acest lucru
                    if (!Salaries.Business.Authentication.HasUserRightsOnPage(pathArr[nr - 1], user))
                    {
                        ErrHandler.MyErrHandler.WriteError("EditAngajat.aspx - autentificare windows fara drepturi - " + user.Identity.Name);
                        Response.Redirect("Unauthorized.aspx");
                    }
                }
                //autentificare cu user si parola
                else
                {
                    try
                    {
                        string nume        = Session["Nume"].ToString();
                        string parola      = Session["Parola"].ToString();
                        int    angajatorId = int.Parse(Session["AngajatorId"].ToString());

                        //user-ul loginat nu are dreptul sa acceseze aceasta pagina este redirectat catre o pagina care sa il instiinteze de acest lucru
                        if (!Salaries.Business.Authentication.HasUserRightsOnPage(pathArr[nr - 1], nume, parola, angajatorId))
                        {
                            ErrHandler.MyErrHandler.WriteError("EditAngajat.aspx - autentificare user parola fara drepturi - " + nume + ", " + angajatorId);
                            Response.Redirect("Unauthorized.aspx");
                        }
                    }
                    catch (Exception exc)
                    {
                        Response.Redirect("index.aspx");
                    }
                }
            }

            idAngajat = Convert.ToInt32(Request.QueryString["id"]);
            string myCmd = Request.QueryString["cmd"];

            mainTable.Attributes.Add("width", "100%");
            mainTable.Attributes.Add("height", "100%");
            mainTable.Attributes.Add("border", "0");
            mainTable.Attributes.Add("cellpadding", "0");
            mainTable.Attributes.Add("cellspacing", "0");

            TableRow  myRow;
            TableRow  mySecondRow;
            TableCell myCell;

            // al doilea table.. care va contine 2 linii - taskuri si control centru
            Table secondTable = new Table();

            secondTable.Attributes.Add("width", "100%");
            secondTable.Attributes.Add("height", "100%");
            secondTable.Attributes.Add("border", "0");
            secondTable.Attributes.Add("cellpadding", "0");
            secondTable.Attributes.Add("cellspacing", "0");

            try
            {
                objAngajat           = new Salaries.Business.Angajat();
                objAngajat.AngajatId = idAngajat;
                objAngajat.LoadAngajat();
            }
            catch (Exception ex)
            {
                Response.Write("Error loading employee data: <br>");
                Response.Write(ex.Message);
                Response.End();
            }


            // se adauga partea stanga
            myRow             = new TableRow();
            myCell            = new TableCell();
            myCell            = new TableCell();
            myCell.RowSpan    = 3;
            myCell.Width      = new Unit(310, UnitType.Pixel);
            myEditAngajatLeft = (EditAngajatLeft)LoadControl("EditAngajatLeft.ascx");

            myEditAngajatLeft.XmlSursa   = "Navigare/EditAngajat_LeftNavigation.xml";
            myEditAngajatLeft.AngajatID  = idAngajat;
            myEditAngajatLeft.objAngajat = objAngajat;
            myCell.Attributes.Add("valign", "top");
            myCell.Controls.Add(myEditAngajatLeft);
            myRow.Cells.Add(myCell);

            // se adauga partea dreapta
            mySecondRow = new TableRow();
            myCell      = new TableCell();
            EditAngajatUp myEditAngajatUp = (EditAngajatUp)LoadControl("EditAngajatUp.ascx");

            myCell.Attributes.Add("valign", "top");
            myCell.Attributes.Add("height", "10");
            myEditAngajatUp.AngajatID = idAngajat;
            myCell.Controls.Add(myEditAngajatUp);
            mySecondRow.Cells.Add(myCell);
            secondTable.Rows.Add(mySecondRow);

            // se adauga a doua linie din tabel.. ce contine controlul
            mySecondRow = new TableRow();
            myCell      = new TableCell();
            myCell.Attributes.Add("valign", "top");
            myCell.Attributes.Add("height", "100%");
            myCell.Attributes.Add("align", "center");

            switch (myCmd)
            {
            case "date_personale":
            case null:
                EditAngajatDatePersonale myEditControl = (EditAngajatDatePersonale)LoadControl("EditTasks/EditAngajatDatePersonale.ascx");
                myEditControl.objAngajat = objAngajat;
                myCell.Controls.Add(myEditControl);
                break;

            case "date_angajare":
                //var control = LoadControl("EditTasks/EditAngajatDateAngajare.ascx");
                //EditAngajatDateAngajare myEditDateAngajatControl = (EditAngajatDateAngajare) control;

                EditAngajatDateAngajare myEditDateAngajatControl = (EditAngajatDateAngajare)LoadControl("EditTasks/EditAngajatDateAngajare.ascx");
                myEditDateAngajatControl.objAngajat = objAngajat;
                myCell.Controls.Add(myEditDateAngajatControl);
                break;

            case "istoric_departamente":
                IstoricDepartamente myIstoricDepartamenteControl = (IstoricDepartamente)LoadControl("EditTasks/IstoricDepartamente.ascx");
                myIstoricDepartamenteControl.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricDepartamenteControl);
                break;

            case "contract_munca":
                contract_munca myContractMunca = (contract_munca)LoadControl("Comunicari/contract_munca.ascx");
                myContractMunca.objAngajat = objAngajat;
                myCell.Controls.Add(myContractMunca);
                break;

            case "comunicare_prima":
                Comunicare_prima myComunicarePrima = (Comunicare_prima)LoadControl("Comunicari/Comunicare_prima.ascx");
                myComunicarePrima.objAngajat = objAngajat;
                myCell.Controls.Add(myComunicarePrima);
                break;

            case "comunicare_majorare":
                comunicare_majorare myComunicareMajorare = (comunicare_majorare)LoadControl("Comunicari/Comunicare_majorare.ascx");
                myComunicareMajorare.objAngajat = objAngajat;
                myCell.Controls.Add(myComunicareMajorare);
                break;

            case "comunicare_indexare":
                comunicare_indexare myComunicareIndexare = (comunicare_indexare)LoadControl("Comunicari/Comunicare_indexare.ascx");
                myComunicareIndexare.objAngajat = objAngajat;
                myCell.Controls.Add(myComunicareIndexare);
                break;

            case "comunicare_indexare_majorare":
                comunicare_indexare_majorare myComunicareIM = (comunicare_indexare_majorare)LoadControl("Comunicari/Comunicare_indexare_majorare.ascx");
                myComunicareIM.objAngajat = objAngajat;
                myCell.Controls.Add(myComunicareIM);
                break;

            case "comunicare_prelungire_cim":
                comunicare_prelungire_cim myComunicareCIM = (comunicare_prelungire_cim)LoadControl("Comunicari/Comunicare_prelungire_cim.ascx");
                myComunicareCIM.objAngajat = objAngajat;
                myCell.Controls.Add(myComunicareCIM);
                break;

            case "fisa_postului":
                fisa_postului myfisapostului = (fisa_postului)LoadControl("Comunicari/fisa_postului.ascx");
                myfisapostului.objAngajat = objAngajat;
                myCell.Controls.Add(myfisapostului);
                break;

            case "adeverintaMedicDeFamilie":
                adeverintaMedicDeFamilie myAdevMedicDeFamilie = (adeverintaMedicDeFamilie)LoadControl("Comunicari/adeverintaMedicDeFamilie.ascx");
                myAdevMedicDeFamilie.objAngajat = objAngajat;
                myCell.Controls.Add(myAdevMedicDeFamilie);
                break;

            case "conturi_banca":
                ConturiBanca myConturiBanca = (ConturiBanca)LoadControl("EditTasks/ConturiBanca.ascx");
                myConturiBanca.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myConturiBanca);
                break;

            case "change_poza":
                ChangePoza myChangePoza = (ChangePoza)LoadControl("EditTasks/ChangePoza.ascx");
                myChangePoza.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myChangePoza);
                break;

            case "istoric_functii":
                IstoricFunctii myIstoricFunctii = (IstoricFunctii)LoadControl("EditTasks/IstoricFunctii.ascx");
                myIstoricFunctii.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricFunctii);
                break;

            case "situatie_militara":
                SituatiiMilitare mySitMilitar = (SituatiiMilitare)LoadControl("EditTasks/SituatiiMilitare.ascx");
                mySitMilitar.objAngajat = objAngajat;
                myCell.Controls.Add(mySitMilitar);
                break;

            case "istoric_training":
                IstoricTraininguri myIstoricTraininguri = (IstoricTraininguri)LoadControl("EditTasks/IstoricTraininguri.ascx");
                myIstoricTraininguri.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricTraininguri);
                break;

            case "checkupuri":
                CheckupuriAngajat myCheckup = (CheckupuriAngajat)LoadControl("EditTasks/CheckupuriAngajat.ascx");
                myCheckup.AngajatID = objAngajat.AngajatId;
                myCheckup.SefID     = objAngajat.SefId;
                myCell.Controls.Add(myCheckup);
                break;

            case "evaluari_psihologice":
                EvaluariPsihologiceAngajat myEval = (EvaluariPsihologiceAngajat)LoadControl("EditTasks/EvaluariPsihologiceAngajat.ascx");
                myEval.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myEval);
                break;

            case "istoric_referinte":
                ReferinteAngajat myReferinte = (ReferinteAngajat)LoadControl("EditTasks/ReferinteAngajat.ascx");
                myReferinte.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myReferinte);
                break;

            case "pers_intretinere":
                PersoaneIntretinere myPersIntretinere = (PersoaneIntretinere)LoadControl("EditTasks/PersoaneIntretinere.ascx");
                myPersIntretinere.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myPersIntretinere);
                break;

            case "istoric_schimbari":
                IstoricSchimbariDateAngajat myIstoricSchimbari = (IstoricSchimbariDateAngajat)LoadControl("EditTasks/IstoricSchimbariDateAngajat.ascx");
                myIstoricSchimbari.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricSchimbari);
                break;

            case "istoric_concedii_odihna":
                IstoricConcediiOdihnaAngajat myIstoricCO = (IstoricConcediiOdihnaAngajat)LoadControl("EditTasks/IstoricConcediiOdihnaAngajat.ascx");
                myIstoricCO.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricCO);
                break;

            case "istoric_concedii_medicale":
                IstoricConcediiMedicaleAngajat myIstoricCM = (IstoricConcediiMedicaleAngajat)LoadControl("EditTasks/IstoricConcediiMedicaleAngajat.ascx");
                myIstoricCM.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricCM);
                break;

            case "istoric_permis_munca":
                IstoricPermiseMunca myIstoricPermiseMunca = (IstoricPermiseMunca)LoadControl("EditTasks/IstoricPermiseMunca.ascx");
                myIstoricPermiseMunca.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricPermiseMunca);
                break;

            case "istoric_legitimatie_sedere":
                IstoricLegitimatiiSedere myIstoricLegitimatiiSedere = (IstoricLegitimatiiSedere)LoadControl("EditTasks/IstoricLegitimatiiSedere.ascx");
                myIstoricLegitimatiiSedere.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricLegitimatiiSedere);
                break;

            case "istoric_NIF":
                IstoricNIFuri myIstoricNIFuri = (IstoricNIFuri)LoadControl("EditTasks/IstoricNIFuri.ascx");
                myIstoricNIFuri.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricNIFuri);
                break;

            case "istoric_carte_identitate":
                IstoricCartiIdentitate myIstoricCartiIdentitate = (IstoricCartiIdentitate)LoadControl("EditTasks/IstoricCartiIdentitate.ascx");
                myIstoricCartiIdentitate.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricCartiIdentitate);
                break;

            case "istoric_pasaport":
                IstoricPasapoarte myIstoricPasapoarte = (IstoricPasapoarte)LoadControl("EditTasks/IstoricPasapoarte.ascx");
                myIstoricPasapoarte.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricPasapoarte);
                break;

            case "alerte_speciale":
                EditIstoricAlerte myEditIstoricAlerte = (EditIstoricAlerte)LoadControl("EditTasks/EditIstoricAlerte.ascx");
                myEditIstoricAlerte.AngajatID = int.Parse(objAngajat.AngajatId.ToString());
                myCell.Controls.Add(myEditIstoricAlerte);
                break;

            case "istoric_intreruperi_cim":
                IstoricSuspendariCIM myIstoricSusp = (IstoricSuspendariCIM)LoadControl("EditTasks/IstoricSuspendariCIM.ascx");
                myIstoricSusp.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricSusp);
                break;

            case "istoric_tichete_de_masa":
                IstoricTicheteDeMasa myIstoricTichete = (IstoricTicheteDeMasa)LoadControl("EditTasks/IstoricTicheteDeMasa.ascx");
                myIstoricTichete.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myIstoricTichete);
                break;

            case "nivel_angajat":
                NivelAngajat myNivel = (NivelAngajat)LoadControl("EditTasks/NivelAngajat.ascx");
                myNivel.AngajatID = objAngajat.AngajatId;
                myCell.Controls.Add(myNivel);
                break;

            default:
                myCell.Text = "<img src=\"images/1x1.gif\" width=\"100%\" height=\"100%\">";
                break;
            }
            mySecondRow.Cells.Add(myCell);
            secondTable.Rows.Add(mySecondRow);

//			 se adauga al doilea tabel la primul
            myCell = new TableCell();
            myCell.Controls.Add(secondTable);
            myCell.Attributes.Add("height", "100%");
            myCell.Attributes.Add("width", "100%");
            myRow.Cells.Add(myCell);
            mainTable.Rows.Add(myRow);
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SeteazaCampuriInvizibile();

            Salaries.Business.Luni l = new Salaries.Business.Luni(this.GetAngajator(), this.GetCurrentMonth());
            this.SelectedDate = l.Data;

            if (IsPostBack)
            {
                //performIndexing = this.indexareCheckBox.Checked;
                performIndexing = !tdIndexare.Disabled && indexareCheckBox.Checked;
            }

            /*
             * Adaugat:   Cristina Raluca Mutean
             * Data:      29.12.2005
             * Descriere: Seteaza vizibil sau nu randul corespunzator controalelor legate de indexare
             * in functie de luna activa.
             */
            /*if (( this.SelectedDate.Month == LUNA_INDEXARE_1 ) || ( this.SelectedDate.Month == LUNA_INDEXARE_2 ))
             * {
             *      tdIndexare.Disabled = false;
             *      indexareCheckBox.Checked = true;
             * }
             * else
             * {
             *      tdIndexare.Disabled = true;
             *      indexareCheckBox.Checked = false;
             * }*/


            //daca este luna de executare a indexarii
            if ((this.SelectedDate.Month == LUNA_INDEXARE_1) || (this.SelectedDate.Month == LUNA_INDEXARE_2))
            {
                //se calculeaza salariul indexat al unui angajat
                float venitBrutIndexat = 0;
                Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
                Salaries.Business.Salariu salariu    = new Salaries.Business.Salariu();
                DataSet ds = objAngajat.GetAngajatIDAll();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    salariu.AngajatID    = int.Parse(ds.Tables[0].Rows[0]["AngajatId"].ToString());
                    objAngajat.AngajatId = int.Parse(ds.Tables[0].Rows[0]["AngajatId"].ToString());
                    objAngajat.LoadAngajat();
                    venitBrutIndexat = salariu.CalculVenitBrutIndexat();
                }

                //daca nu a fost executata deja indexarea, adica salariu curent este egal cu cel indexat
                if (decimal.Parse(venitBrutIndexat.ToString()) != objAngajat.SalariuBaza)
                {
                    //se seteaza campul pentru efectuarea indexarii ca fiind activ
                    tdIndexare.Disabled = false;
                    //indexareCheckBox.Checked = true;
                }
                //a fost deja executata o indexare, nu se va mai realiza alta indexare
                else
                {
                    tdIndexare.Disabled = true;
                    //indexareCheckBox.Checked = false;
                }
                indexareCheckBox.Checked = true;
            }
            //nu este luna de indexare
            else
            {
                tdIndexare.Disabled      = true;
                indexareCheckBox.Checked = false;
            }
        }
        /// <summary>
        /// Salveaza o lichidate
        /// </summary>
        private void btnSalveaza_Click()
        {
            /*
             * Modified:  Cristina Raluca Muntean
             * Date:      10.09.2005
             * Descriere: Modificarea consta in validarea datelor de intrare, a statusului angajatului(lichidat/nu este lichidat)
             * si a generarii situatiei lunare conform cu noile date corespunzatoare lichidarii.
             */

            //Modificat: Oprescu Claudia
            //Descriere: Se face mai intai validarea datelor introduse si apoi daca angajatul nu este lichidat se face lichidarea lui
            //			 Daca este deja lichidat se face actualizare la datele lichidarii, adica se sterge cea veche si se adauga una noua
            int idAng = GetAngajat();

            ErrHandler.MyErrHandler.WriteError("LichidareAngajat.ascx - start - Salveaza() - idAng: " + idAng.ToString());
            try
            {
                Salaries.Data.LichidareStruct lichidare = new Salaries.Data.LichidareStruct();
                Salaries.Business.Angajat     angajat   = new Salaries.Business.Angajat();
                angajat.AngajatId = GetAngajat();
                angajat.LoadAngajat();

                lichidare.AngajatID = this.GetAngajat();

                //variabila booleana care indica daca au fost completate toate campurile obligatorii
                bool fill = true;
                //variabila booleana care indica daca au fost completate corect campurile
                bool correct = true;

                //se verifica daca au fost completate campurile
                if (txtNrInregistrare.Text == "" || txtDataLichidare.Text == "" || txtDataInregistrare.Text == "")
                {
                    fill = false;
                }
                try
                {
                    lichidare.NrInregistrare   = txtNrInregistrare.Text;
                    lichidare.DataLichidare    = Utilities.ConvertText2DateTime(txtDataLichidare.Text);
                    lichidare.MotivDePlecareId = int.Parse(((System.Web.UI.HtmlControls.HtmlInputHidden)Page.FindControl("txtMotivDePlecareHidden")).Value);

                    lichidare.NrArticol         = txtNrArticol.Text;
                    lichidare.AvansuriDecontare = decimal.Parse(txtAvansuriDecontare.Text);
                    lichidare.Abonamente        = decimal.Parse(txtAbonamente.Text);
                    lichidare.TicheteMasa       = decimal.Parse(txtTicheteMasa.Text);
                    lichidare.EchipamentLucru   = decimal.Parse(txtEchipamentLucru.Text);
                    lichidare.Laptop            = decimal.Parse(txtLaptop.Text);
                    lichidare.TelServiciu       = decimal.Parse(txtTelServiciu.Text);
                    lichidare.ObiecteInventar   = decimal.Parse(txtObiecteInventar.Text);
                    lichidare.Carti             = decimal.Parse(txtCarti.Text);
                    lichidare.CD = decimal.Parse(txtCD.Text);

                    lichidare.DataInregistrare = Utilities.ConvertText2DateTime(txtDataInregistrare.Text);
                    if (txtLunaRetinere.Text == "")
                    {
                        lichidare.LunaRetinere = Utilities.ConvertText2DateTime("1.1.1753");
                    }
                    else
                    {
                        lichidare.LunaRetinere = Utilities.ConvertText2DateTime(txtLunaRetinere.Text);
                    }
                }
                catch (Exception)
                {
                    //in cazul in care apare o eroare la conversie inseamna ca nu au fost completate corect campurile
                    correct = false;
                }

                Salaries.Business.Luni luni     = new Salaries.Business.Luni(this.GetAngajator());
                Salaries.Data.LunaData lunaData = luni.GetLunaActiva();

                //daca au fost completate toate campurile corect si data lichidarii se afla in luna activa se poate realiza efectiv lichidarea
                if (fill && correct)
                {
                    if ((lunaData.Data.Month == DateTime.Parse(txtDataLichidare.Text).Date.Month&& lunaData.Data.Year == DateTime.Parse(txtDataLichidare.Text).Date.Year) ||
                        (DateTime.Parse(txtDataLichidare.Text).Date.Day == 1) && (DateTime.Parse(txtDataLichidare.Text).Date.Month == lunaData.Data.Month + 1) && (lunaData.Data.Year == DateTime.Parse(txtDataLichidare.Text).Date.Year) ||
                        (DateTime.Parse(txtDataLichidare.Text).Date.Day == 1) && (DateTime.Parse(txtDataLichidare.Text).Date.Month == 1) && (lunaData.Data.Month == 12) && (lunaData.Data.Year + 1 == DateTime.Parse(txtDataLichidare.Text).Date.Year))
                    {
                        SiemensTM.Classes.IntervaleAngajat intervaleAngajat = new SiemensTM.Classes.IntervaleAngajat(lichidare.AngajatID);
                        //sterge toate intervalele orare, inclusiv capetele de interval
                        intervaleAngajat.DeleteIntervaleAngajatPerioada(lichidare.DataLichidare, DateTime.MaxValue, true);
                        //initializeaza luna pentru angajatul in cauza
                        intervaleAngajat.InitializeOreLucrateLunaAngajat(lunaData.Data, objAngajat.DataDeLa, lichidare.DataLichidare);

                        //se genereaza situatia lunara a angajatului
                        //Salaries.Business.SituatieLunaraAngajat sla = new Salaries.Business.SituatieLunaraAngajat( lichidare.AngajatID );
                        //sla.GenerareSituatieLunaraAngajat( this.GetCurrentMonth(), this.GetAngajator());

                        //Adaugat:		Oprescu Claudia
                        //Descriere:	Se verifica sa nu existe deja o lichidare pentru luna activa.
                        //				Daca exista atunci se actualizeaza acea inregistrare.
                        //				Daca nu exista se adauga o inregistrare noua.
                        int lichidareID = new Salaries.Business.Lichidare().CheckIfLichidareCanBeAdded(lichidare.AngajatID, lichidare.DataLichidare);
                        if (lichidareID == 0)
                        {
                            new Salaries.Business.Lichidare().AddLichidare(lichidare);
                        }
                        else
                        {
                            lichidare.LichidareID = lichidareID;
                            new Salaries.Business.Lichidare().UpdateLichidare(lichidare);
                        }

                        //Modified: Cristina Raluca Muntean
                        //se genereaza situatia lunara a angajatului
                        SiemensTM.Classes.SituatieAngajat situatieLunaraAng = new SiemensTM.Classes.SituatieAngajat(this.GetAngajat());
                        //Added: Ionel Popa -> daca este lichidat in prima zi a lunii i se sterge situatia lunara
                        Salaries.Business.Luni activeMonth = new Salaries.Business.Luni(this.GetAngajator(), lunaData.LunaId);
                        if (activeMonth.Data == lichidare.DataLichidare)
                        {
                            Salaries.Business.SituatieLunaraAngajat sla = new Salaries.Business.SituatieLunaraAngajat(this.GetAngajat());
                            sla.DeleteSituatieAngajat(GetCurrentMonth(), this.GetAngajat());
                        }
                        else
                        {
                            //Modificat:	Oprescu Claudia
                            //Descriere:	Se apeleaza metoda pentru generarea situatiei lunare a angajatului
                            //				La generarea situatiei se calculeaza numarul de zile de concediu de odihna neefectuat si efectuat in avans
                            situatieLunaraAng.GenerareSituatieLunaraAngajatLichidat();
                        }

                        //javascript
                        StringBuilder jScript = new StringBuilder();
                        jScript.Append("<script language=\"JavaScript\">");
                        jScript.Append("window.open('../Comunicari/comunicare.aspx?id=" + objAngajat.AngajatId + "',null,'status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')");
                        jScript.Append("</script>");

                        AdaugaInSesiune();

                        Response.Write(jScript.ToString());
                    }
                    else
                    {
                        //este afisat mesajul de eroare
                        Response.Write("<script>alert( 'Data lichidarii angajatului trebuie sa faca parte din luna activa!' );</script>");
                    }
                }
                else
                {
                    //in functie de eroare este afisat mesajul corespunzator
                    if (!correct)
                    {
                        Response.Write("<script>alert( 'Datele introduse nu sunt corecte!' );</script>");
                    }
                    if (!fill)
                    {
                        Response.Write("<script>alert( 'Trebuie sa completati toate datele!' );</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
                ErrHandler.MyErrHandler.WriteError("LichidareAngajat.ascx - start - Salveaza() - idAng: " + idAng.ToString() + " - " + ex.Message);
            }
            ErrHandler.MyErrHandler.WriteError("LichidareAngajat.ascx - end - Salveaza() - idAng: " + idAng.ToString());
        }