/// <summary>
        /// Procedura calculeaza nr de zile de CB pe luna oferite de firma
        /// </summary>
        /// <param name="lunaID">Id-ul lunii</param>
        /// <param name="angajatorID">Id-ul angajatorului</param>
        /// <returns>Returneaza nr de zile de CB</returns>
        private int GetNrZileConcediuBoalaLunaFirma(int lunaID, int angajatorID)
        {
            Salaries.Data.SituatieLunaraAngajat sla = new Salaries.Data.SituatieLunaraAngajat(this.settings.ConnectionString);
            int LunaID = new Luni(angajatorID).GetLunaPrecedenta(lunaID);

            return(LunaID == 0 ? sla.GetNrZileConcediuBoalaLunaFirma(lunaID, angajatorID) : sla.GetNrZileConcediuBoalaLunaFirma(LunaID, angajatorID));
        }
        /// <summary>
        /// Procedura genereaza situatia lunara unui angajat care a fost lichidat
        /// </summary>
        public void GenerareSituatieLunaraAngajatLichidat()
        {
            Salaries.Business.Angajat angajat = new Salaries.Business.Angajat();
            angajat.AngajatId = AngajatID;
            angajat.LoadAngajat();

            //este obtinuta prima zi a lunii active
            Salaries.Business.Luni luna       = new Salaries.Business.Luni(angajat.AngajatorId, settings);
            Salaries.Data.LunaData lunaActiva = luna.GetLunaActiva();

            Salaries.Business.PontajAngajat pontajAngajat = new Salaries.Business.PontajAngajat(this.AngajatID, settings);

            DataSet dsIntervaleAngajat = pontajAngajat.GetIntervaleAngajat(lunaActiva.LunaId);

            //daca nu au fost initializate orele unui angajat, se face aceasta initializare
            if (dsIntervaleAngajat.Tables[0].Rows.Count == 0)
            {
                //intervale angajat
                IntervaleAngajat intervAng = new IntervaleAngajat(AngajatID, settings);

                //sunt intializate orele lucrate de catre angajat
                intervAng.InitializeOreLucrateLunaAngajat(lunaActiva.Data, angajat.DataDeLa, angajat.DataLichidare);
            }

            //situatia lunara a unui angajat
            Salaries.Business.SituatieLunaraAngajat situatieLunaraAng = new Salaries.Business.SituatieLunaraAngajat(AngajatID, settings);

            //se genereaza situatia lunara a angajatului
            situatieLunaraAng.GenerareSituatieLunaraAngajatLichidat(lunaActiva.LunaId, angajat.AngajatorId);
        }
        /// <summary>
        /// Daca pagina de administrare a fost deschisa din AddAngajat cream functia care va face refresh la combo-ul cu categorii
        /// </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 categorii
            //initial se sterg toate intrarile din combo
            outStr += "<script> \r\n function RefreshAddAngajatPage() \r\n" +
                      "{ \r\n" +
                      "window.opener.DeleteCategoriiCombo(); \r\n" +
                      " FillCategoriiCombo(); \r\n" +
                      "} \r\n";

            //acum se creeaza functie care adauga categoriile din recordset
            //se foloseste o functie din AddAngajat ... FillTitluCombo
            Salaries.Business.Luni luni       = new Salaries.Business.Luni(Convert.ToInt32(Session["AngajatorID"]));
            Salaries.Data.LunaData lunaData   = luni.GetLunaActiva();
            DataSet objAdminCategoriiAngajati = new Salaries.Business.CategoriiAngajat().GetCategoriiAngajat(lunaData.LunaId);

            outStr += " function FillCategoriiCombo() \r\n" +
                      "{ \r\n";
            foreach (DataRow dataRow in objAdminCategoriiAngajati.Tables[0].Rows)
            {
                outStr += "window.opener.FillCategorieCombo('" +
                          dataRow["Denumire"].ToString() + "'," +
                          dataRow["CategorieID"].ToString() + ");";
            }

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

            Response.Write(outStr);
        }
        /// <summary>
        /// Salveaza datele unei categorii salariale
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSalveaza_Click(object sender, System.EventArgs e)
        {
            try
            {
                Salaries.Data.CategorieData categorieData = new Salaries.Data.CategorieData();
                Salaries.Business.Luni      luni          = new Salaries.Business.Luni(Convert.ToInt32(Session["AngajatorID"]));
                Salaries.Data.LunaData      lunaData      = luni.GetLunaActiva();

                categorieData.Denumire  = this.lblDenumire.Text;
                categorieData.Descriere = this.txtDescriere.Text;
                categorieData.DPB       = (chkPrimesteDPB.Checked) ? decimal.Parse(this.txtDPB.Text) : 0;
                categorieData.ScturieAsigSanAngajator = this.chkScutireAsigSanAngajator.Checked;
                categorieData.ScutireAsigSanAngajat   = this.chkScutireAsigSanAngajat.Checked;
                categorieData.ScutireCASAngajat       = this.chkScutireCASAngajat.Checked;
                categorieData.ScutireCASAngajator     = this.chkScutireCASAngajator.Checked;
                categorieData.ScutireImpozit          = this.chkScutireImpozit.Checked;
                categorieData.ScutireSomajAngajat     = this.chkScutireSomajAngajat.Checked;
                categorieData.ScutireSomajAngajator   = this.chkScutireSomajAngajator.Checked;
                categorieData.LunaId      = lunaData.LunaId;
                categorieData.CategorieId = int.Parse(txtCategorieID.Text);
                categorieData.PrimesteDPB = this.chkPrimesteDPB.Checked;

                if (new Salaries.Business.CategoriiAngajat().CheckIfCategoriiAngajatCanBeAdded(categorieData.CategorieId, categorieData.LunaId,
                                                                                               categorieData.Denumire, categorieData.Descriere, categorieData.DPB, categorieData.ScutireImpozit, categorieData.ScutireCASAngajat,
                                                                                               categorieData.ScutireCASAngajator, categorieData.ScutireSomajAngajat, categorieData.ScutireSomajAngajator,
                                                                                               categorieData.ScutireAsigSanAngajat, categorieData.ScturieAsigSanAngajator, categorieData.PrimesteDPB))
                {
                    if (txtCategorieID.Text == "0")
                    {
                        new Salaries.Business.CategoriiAngajat().InsertCategorie(categorieData);
                    }
                    else
                    {
                        new Salaries.Business.CategoriiAngajat().UpdateCategorie(categorieData);
                    }
                }
                else
                {
                    Response.Write("<script> alert('Mai exista o categorie cu aceste date!'); </script>");
                }

                ListCategorii();
                CreateRefreshFunctionForAddAngajat();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred x: <br>";
                litError.Text += ex.Message;
            }
        }
Example #5
0
        /// <summary>
        /// Este obtinuta lista lunilor(denumire, procent inflatie,..) pentru anul selectat in dropdownlist
        /// </summary>
        private void LoadInflatieList()
        {
            try
            {
                listTable.Rows.Clear();
                listTable.Attributes.Add("width", "100%");
                listTable.Style.Add("border", "1px solid #20b2aa");
                listTable.Attributes.Add("cellpadding", "0");
                listTable.Attributes.Add("cellspacing", "1");


                string[] arHeader = { "Denumire", "ProcentInflatie" };
                string[] arCols   = { "Denumire", "ProcentInflatie" };

                lunaId = this.GetCurrentMonth();                //id-ul lunii curente

                Salaries.Business.Luni luni = new Salaries.Business.Luni(this.AngajatorID, lunaId);

                //anul selectat de utilizator
                int an = int.Parse(drpAni.SelectedItem.Text);

                //returneaza lunile din anul dat ca parametru pentru care sunt calculate salariile
                //in baza de date
                //DataSet ds=luni.GetLuniSal_Salarii(an);
                DataSet ds = luni.GetLuniSal_Luni(an, this.AngajatorID);

                ListTable objListTable = new ListTable(listTable, ds, arHeader, arCols);
                objListTable.textForEmptyDataSet = "Nu exista date!";

                string[] ar_OnClickParam = { "Denumire", "ProcentInflatie" };

                string[] ar_OnClickParamType = new string[ar_OnClickParam.Length];
                for (int i = 0; i < ar_OnClickParamType.Length; i++)
                {
                    ar_OnClickParamType[i] = "dataset";
                }


                objListTable.OnclickParams     = ar_OnClickParam;
                objListTable.OnclickParamsType = ar_OnClickParamType;

                objListTable.DrawListTableWithDigits(4);
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        /// <summary>
        /// Afiseaza butoanele pentru genrearea situatiilor lunare in functie de luna activa
        /// </summary>
        /// <param name="val">Se afiseaza butoanele sau nu</param>
        private void EnableAngajatCurent(bool val)
        {
            this.angajatDDL.Visible         = val;
            this.labelAngajatCurent.Visible = val;
            this.ButtonGenerareSituatieLunaraAngajat.Visible       = val;
            this.ButtonGenerareSituatieLunaraTotiAngajatii.Visible = val;

            Salaries.Business.Luni luni     = new Salaries.Business.Luni(this.GetAngajator());
            Salaries.Data.LunaData lunaData = luni.GetLunaActiva();
            if (lunaData.LunaId != -1 && val)
            {
                this.ButtonGenerareSituatieLunaraAngajat.Visible       = this.GetCurrentMonth() == lunaData.LunaId;
                this.ButtonGenerareSituatieLunaraTotiAngajatii.Visible = this.GetCurrentMonth() == lunaData.LunaId;
            }
        }
Example #7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string script_text = "<script>var ctrlID = \"" + this.ClientID + "\"</script>";

            Response.Write(script_text);

            //id-ul angajatorului
            this.AngajatorID = this.GetAngajator();

            //luna activa a angajatorului
            Salaries.Business.Luni luni     = new Salaries.Business.Luni(this.GetAngajator());
            Salaries.Data.LunaData lunaData = luni.GetLunaActiva();
            //id-ul lunii active
            int lunaActivaID = lunaData.LunaId;

            if (!IsPostBack)
            {
                string procInflatie = luni.GetDetalii(lunaActivaID).ProcentInflatie.ToString();
                txtProcentInflatie.Text = procInflatie;

                string[] textTabs = { "Lista luni pe anul curent", "Modificare procent inflatie" };
                Utilities.CreateHeaderWithTabs(tableTabs, textTabs, "../", true);

                //anii din baza de date pentru care sunt calculate salariile
                DataSet dsAni = luni.GetAniSal_Salarii();
                if (dsAni.Tables[0].Rows.Count != 0)
                {
                    //populeaza dropdownlist-ul
                    foreach (DataRow row in dsAni.Tables["Ani"].Rows)
                    {
                        ListItem NewItem = new ListItem();
                        NewItem.Text = row["An"].ToString();
                        drpAni.Items.Add(NewItem);
                    }
                }
                else
                {
                    ListItem NewItem = new ListItem();
                    NewItem.Text = luni.GetLunaActiva().Data.Year.ToString();
                    drpAni.Items.Add(NewItem);
                }
            }
            else
            {
                string[] textTabs = { "Lista luni pentru anul selectat", "Modificare procent inflatie" };
                Utilities.CreateHeaderWithTabs(tableTabs, textTabs, "../", true);
            }
        }
Example #8
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

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

            if (lunaData.LunaId != -1)
            {
                bool enabled = this.GetCurrentMonth() == lunaData.LunaId;
                this.btnAdaugaProcentInfl.Enabled = enabled;

                this.tableTabs.Enabled = enabled;
            }

            this.LoadInflatieList();
        }
Example #9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string script_text = "<script>var ctrlID = \"" + this.ClientID + "\"</script>";

            Response.Write(script_text);
            Response.Write("<script>var txtBodyClient = \"" + this.txtBody.ClientID + "\"</script>");
            lunaID      = this.GetCurrentMonth();
            angajatorID = this.GetAngajator();

            actionTrimiteMailFluturasiLuna = ((System.Web.UI.HtmlControls.HtmlInputHidden)Page.FindControl("ActionTrimiteMailFluturasiLunaValue")).Value;
            mailFluturasiLuna = ((System.Web.UI.HtmlControls.HtmlInputHidden)Page.FindControl("mailFluturasiLunaValue")).Value;

            Salaries.Business.Luni salLuni = new Salaries.Business.Luni(angajatorID);
            lunaActiva = salLuni.GetLunaActiva().LunaId;

            HandleActions();
        }
Example #10
0
        /// <summary>
        /// Este adaugat procentul inflatiei pentru luna activa
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdaugaProcentInfl_Click(object sender, System.EventArgs e)
        {
            try
            {
                //luna curenta
                lunaId = this.GetCurrentMonth();

                //este setat procentul de inflatie
                Salaries.Business.Luni luni = new Salaries.Business.Luni(this.AngajatorID, lunaId);
                luni.ProcentInfl = float.Parse(txtProcentInflatie.Text);

                //se face update-ul
                luni.Update();
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }

            LoadInflatieList();
        }
Example #11
0
        /// <summary>
        /// Listarea valorilor pentru variabilele globale
        /// </summary>
        private void LoadVariabileGlobaleList()
        {
            try
            {
                list_form.Style.Add("display", "");
                add_form.Style.Add("display", "none");
                btnSalveaza.Visible        = false;
                btnInapoi.Visible          = false;
                txtVariabilaGlobalaID.Text = "0";

                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 variabile salarizare";
                myCell.Height          = new Unit(50);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);

                // lista de impozite 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[] arHeader = { "Tip constanta", "Valoare" };
                string[] arCols   = { "Denumire", "Valoare" };

                //id-ul lunii curente
                lunaId = this.GetCurrentMonth();

                Salaries.Business.Luni luni = new Salaries.Business.Luni(this.AngajatorID, lunaId);

                //anul selectat de utilizator
                int luna = int.Parse(drpPerioada.SelectedItem.Value);

                //returneaza lunile din anul dat ca parametru pentru care sunt calculate salariile
                Salaries.Business.VariabileGlobaleValori objVariabilaGlobala = new Salaries.Business.VariabileGlobaleValori();
                DataSet ds = objVariabilaGlobala.GetAllVariabileGlobaleValoriPeLuna(luna);

                ListTable objListTable = new ListTable(listTable, ds, arHeader, arCols);
                objListTable.textForEmptyDataSet = "Nu exista date!";

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

                objListTable.OnclickJSMethod   = "SelectVariabilaGlobala";
                objListTable.OnclickParams     = ar_OnClickParam;
                objListTable.OnclickParamsType = ar_OnClickParamType;
                objListTable.DrawListTableWithDigits();

                myCell.Controls.Add(listTable);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            GenerareaSituatieiLunare();

            string Option = this.Page.Request.Params["Option"];

            if (Option == null)
            {
                Option = "situatie_lunara";
            }

            switch (Option)
            {
            case "situatie_lunara":
                EnableAngajatCurent(true);
                //Se actualizeaza variabila care specifica modificarea situatiei lunare a unui angajat
                Session["ModificaSituatie"] = "";
                SituatieLunaraAngajati mySituatie = (SituatieLunaraAngajati)LoadControl("SituatieLunaraAngajati.ascx");
                this.Center.Controls.Add(mySituatie);
                break;

            case "initializare_luna":
                //luna activa a angajatorului
                Salaries.Business.Luni luni     = new Salaries.Business.Luni(this.GetAngajator());
                Salaries.Data.LunaData lunaData = luni.GetLunaActiva();

                //daca luna selectata de utilizator este luna activa atunci link-ul este activ, altfel acesta devine inactiv
                if (this.GetCurrentMonth() == lunaData.LunaId)
                {
                    EnableAngajatCurent(false);
                    InitializareLuna myInit = (InitializareLuna)LoadControl("InitializareLuna.ascx");
                    this.Center.Controls.Add(myInit);
                }
                else
                {
                    Response.Write("<script>alert(\"Luna selectata este inactiva! \\nInitializarea se poate face doar in luna activa! \");</script>");

                    EnableAngajatCurent(true);
                    SituatieLunaraAngajati mySituatie1 = (SituatieLunaraAngajati)LoadControl("SituatieLunaraAngajati.ascx");
                    this.Center.Controls.Add(mySituatie1);
                }
                break;

            case "pontaj_individual":
                EnableAngajatCurent(true);
                PontajModule myPontaj = (PontajModule)LoadControl("Pontaj/PontajModule.ascx");
                myPontaj.AngajatorID    = this.GetAngajator();
                myPontaj.CurrentMonthID = this.GetCurrentMonth();
                this.Center.Controls.Add(myPontaj);
                break;

            case "lichidare_angajat":
                try
                {
                    //luna activa a angajatorului
                    Salaries.Business.Luni luna       = new Salaries.Business.Luni(this.GetAngajator());
                    Salaries.Data.LunaData lunaActiva = luna.GetLunaActiva();

                    //daca luna selectata de utilizator este luna activa atunci link-ul este activ, altfel acesta devine inactiv
                    if (this.GetCurrentMonth() == lunaActiva.LunaId)
                    {
                        Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
                        objAngajat.AngajatId = GetAngajat();
                        objAngajat.LoadAngajat();

                        EnableAngajatCurent(true);
                        LichidareAngajat lichidare = (LichidareAngajat)LoadControl("LichidareAngajat.ascx");
                        lichidare.objAngajat = objAngajat;
                        this.Center.Controls.Add(lichidare);
                    }
                    else
                    {
                        Response.Write("<script>alert(\"Luna selectata este inactiva! \\nUn angajat poate fi lichidat numai in luna activa! \");</script>");

                        EnableAngajatCurent(true);
                        SituatieLunaraAngajati mySituatie1 = (SituatieLunaraAngajati)LoadControl("SituatieLunaraAngajati.ascx");
                        this.Center.Controls.Add(mySituatie1);
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error loading employee data: <br>");
                    Response.Write(ex.Message);
                    Response.End();
                }
                break;

            case "retineri_recurente_angajat":
                EnableAngajatCurent(true);
                RetineriAngajat myRetineri = (RetineriAngajat)LoadControl("RetineriAngajat.ascx");
                myRetineri.AngajatID = GetAngajat();
                this.Center.Controls.Add(myRetineri);
                break;

            case "import":
                EnableAngajatCurent(false);
                ImportPontaj myImport = (ImportPontaj)LoadControl("ImportPontaj.ascx");
                this.Center.Controls.Add(myImport);
                break;

            case "import_delegatii":
                EnableAngajatCurent(false);
                ImportDelegatii importDel = (ImportDelegatii)LoadControl("ImportDelegatii.ascx");
                this.Center.Controls.Add(importDel);
                break;

            case "trimitere_fluturasi":
                EnableAngajatCurent(false);
                TrimitereFluturasi trimFlut = (TrimitereFluturasi)LoadControl("TrimitereFluturasi.ascx");
                this.Center.Controls.Add(trimFlut);
                break;

            case "sincronizare_date_angajati":
                EnableAngajatCurent(false);
                SincronizareDateAngajati sinc = (SincronizareDateAngajati)LoadControl("SincronizareDateAngajati.ascx");
                //ImportSalarii myImport = (ImportSalarii) LoadControl("ImportSalarii.ascx");
                this.Center.Controls.Add(sinc);
                break;
            }

            //poate strica
            //Modificat:	Oprescu Claudia
            //Descriere:	Se seteaza un angajat numai daca exista in control date
            if (this.angajatDDL.Items.Count > 0)
            {
                this.SetAngajat(long.Parse(angajatDDL.SelectedValue));

                // Se calculeaza valoarea mediei zilnice si se scrie valoarea pe Javascript.
                CalculMedieZilnicaConcediuOdihna();
            }
        }
Example #13
0
        /// <summary>
        /// Procedura calculeaza nr de zile de CO disponibile pe an
        /// </summary>
        /// <param name="dataStart">Data de inceput</param>
        /// <param name="dataEnd">Data de sfarsit</param>
        /// <param name="angajatorID">Id-ul angajatorului</param>
        /// <returns>Returneaza nr de zile de CO disponibile</returns>
        public int GetAngajatNrZileCODisponibileAn(DateTime dataStart, DateTime dataEnd, int angajatorID)
        {
            try
            {
                Salaries.Business.Angajat angajat = new Salaries.Business.Angajat();
                angajat.AngajatId = angajatId;
                DataSet ds = angajat.GetDetaliiAngajat();

                if (dataStart.Year < ((DateTime)ds.Tables[0].Rows[0]["DataDeLa"]).Year)
                {
                    return(0);
                }
                else if (dataStart.Year == ((DateTime)ds.Tables[0].Rows[0]["DataDeLa"]).Year)
                {
                    dataStart = (DateTime)ds.Tables[0].Rows[0]["DataDeLa"];
                }

                if ((bool)ds.Tables[0].Rows[0]["Lichidat"])
                {
                    if (dataEnd.Year > ((DateTime)ds.Tables[0].Rows[0]["DataLichidare"]).Year)
                    {
                        return(0);
                    }
                    else if (dataEnd.Year == ((DateTime)ds.Tables[0].Rows[0]["DataLichidare"]).Year)
                    {
                        dataEnd = (DateTime)ds.Tables[0].Rows[0]["DataLichidare"];
                    }
                }

                float nrZileAngPerLuna  = 0;
                float nrZileDisponibile = 0;
                float nrZileCOAn        = float.Parse(ds.Tables[0].Rows[0]["NrZileCOAn"].ToString());
                float norma             = float.Parse(ds.Tables[0].Rows[0]["ProgramLucru"].ToString());


                for (int i = dataStart.Month; i <= dataEnd.Month; i++)
                {
                    int ziSt  = 1;
                    int ziEnd = DateTime.DaysInMonth(dataStart.Year, i);
                    if (dataStart.Month == i)
                    {
                        ziSt = dataStart.Day;
                    }

                    DateTime dt = new DateTime(dataStart.Year, i, ziSt);

                    Luni          luni     = new Luni(angajatorID);
                    int           lunaID   = luni.GetDetaliiByData(dt).LunaId;
                    Data.LunaData lunaData = luni.GetDetalii(lunaID);

                    Data.IntervaleSchimbariLuna [] interv = GetIntervalProgramLucru(lunaID);

                    if (interv.Length > 0)
                    {
                        for (int j = 0; j < interv.Length; j++)
                        {
                            norma = interv[j].ProgramLucru;
                            if (ziSt <= interv[j].DataEnd.Day)
                            {
                                if (ziSt <= interv[j].DataStart.Day)
                                {
                                    ziSt = interv[j].DataStart.Day;
                                }
                                ziEnd            = interv[j].DataEnd.Day;
                                nrZileAngPerLuna = GetAngajatNrZileCODisponibileLunaAn(dataStart.Year, i, ziSt, ziEnd);

                                //folosim varianta initala, deoarece la formula data de Sica, nr de zile disponibile creste cu 1 pt anumiti ani
                                nrZileDisponibile += (nrZileCOAn * 8 * nrZileAngPerLuna) / (12 * 8 * DateTime.DaysInMonth(dataStart.Year, i));
                            }
                        }
                    }
                    else
                    {
                        nrZileAngPerLuna = GetAngajatNrZileCODisponibileLunaAn(dataStart.Year, i, ziSt, ziEnd);

                        //folosim varianta initala, deoarece la formula data de Sica, nr de zile disponibile creste cu 1 pt anumiti ani
                        nrZileDisponibile += (nrZileCOAn * 8 * nrZileAngPerLuna) / (12 * 8 * DateTime.DaysInMonth(dataStart.Year, i));
                    }
                }

                if (nrZileDisponibile > nrZileCOAn)
                {
                    nrZileDisponibile = nrZileCOAn;
                }
                if (nrZileDisponibile % 1 < 0.5)
                {
                    return((int)nrZileDisponibile);
                }
                return((int)nrZileDisponibile + 1);
            }
            catch
            {
                return(0);
            }
        }
        /// <summary>
        /// Functie necesara pentru verificarea existentei datelor necesate functionarii pontajului.
        /// Daca aceste date nu sunt disponibile, atunci link-ul 'Pontaj' nu este accesibil
        /// </summary>
        /// <returns>Returneaza true daca datele sunt disponibile si false altfel</returns>
        public bool IsPontajAvailable()
        {
            DataSet ds;
            //Verificam daca exista intrari in nomenclator boli
            NomenclatorBoli nb = new NomenclatorBoli();

            ds = nb.GetBoli();
            if (ds.Tables[0].Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                ds.Clear();
            }

            //Verificam daca exista intrari in nomenclator tipurie ore lucrate
            NomenclatorTipOreLucrate ntol = new NomenclatorTipOreLucrate();

            ds = ntol.GetTipuriOreLucrate();
            if (ds.Tables[0].Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                ds.Clear();
            }

            //Verificam daca exista intrari in nomenclator tipuri absente
            NomenclatorTipAbsente nta = new NomenclatorTipAbsente();

            ds = nta.GetTipuriAbsente();
            if (ds.Tables[0].Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                ds.Clear();
            }

            //Verificam daca angajatorul curent are luna activa
            int idAngajator = int.Parse(Session["AngajatorID"].ToString());

            Salaries.Business.Luni objLuni = new Salaries.Business.Luni(idAngajator);
            DataSet myDs = objLuni.GetLunaActivaDataSet();

            string idLunaActiva;
            int    lunaID = 0;

            if (myDs.Tables[0].Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                idLunaActiva = myDs.Tables[0].Rows[0][0].ToString();
                lunaID       = int.Parse(myDs.Tables[0].Rows[0]["LunaID"].ToString());
                myDs.Clear();
            }

            //Verificam daca exista zile pt luna activa in table tm_zile
            objLuni.id = lunaID;
            myDs       = objLuni.ExistaZilePentruLunaActiva();
            if (myDs.Tables[0].Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                myDs.Clear();
            }

            //Verficicam daca exista angajati pt angajatorul curent
            //Pentru ca exista un singur angajator nu mai este necesar parametrul pentru idAngajator
            //Este suficient sa se selecteze toti angajatii pentru a verifica daca exista angajati la angajatorul curent
            Salaries.Business.Angajat angajat = new Salaries.Business.Angajat();
            myDs = angajat.GetAngajatIDAll();
            if (myDs.Tables[0].Rows.Count == 0)
            {
                return(false);
            }

            return(true);
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            Luni    l            = new Luni(int.Parse(Session["AngajatorID"].ToString()));
            int     LunaID       = GetCurrentMonth();
            DataSet dsRestraints = new TypesOfRestraints().GetLabels(LunaID);

            if (l.GetLunaActiva().LunaId == LunaID)
            {
                butSaveData.Visible = true;
            }
            else
            {
                butSaveData.Visible = false;
            }

            Table     restraintsTable = new Table();
            TableRow  tr = null;
            TableCell tc = null;

            System.Web.UI.Control ctl = null;

            int lunaActivaId = l.GetLunaActiva().LunaId;

            Salaries.Business.Luni lunaActiva = new Salaries.Business.Luni(this.GetAngajator(), lunaActivaId);
            DateTime dataStartLunaActiva      = lunaActiva.Data;
            DateTime dataEndLunaActiva        = dataStartLunaActiva.AddMonths(1).AddDays(-1);

            Center.Controls.Clear();
            foreach (DataRow dr in dsRestraints.Tables[0].Rows)
            {
                tr = new TableRow();

                ctl = new Label();
                ((Label)ctl).Text = dr[0].ToString();
                string tipRetinere = dr[0].ToString();
                ((Label)ctl).CssClass = "NormalGreenBold";
                ctl.ID = dr[0].ToString() + "Label";
                tc     = new TableCell();
                tc.Controls.Add(ctl);
                tr.Cells.Add(tc);

                ctl    = new TextBox();
                ctl.ID = dr[0].ToString() + ";" + LunaID;
                if (dr[1] != System.DBNull.Value)
                {
                    ((TextBox)ctl).Text = dr[1].ToString();
                }
                Salaries.Configuration.ModuleSettings  settings = Salaries.Configuration.ModuleConfig.GetSettings();
                Salaries.Data.RetineriRecurenteAngajat retineri = new Salaries.Data.RetineriRecurenteAngajat(settings.ConnectionString);
                int nr = retineri.VerificaIntersectieNrRetineri(0, tipRetinere, dataStartLunaActiva, dataEndLunaActiva);
                if (l.GetLunaActiva().LunaId != LunaID || nr != 0)
                {
                    ((TextBox)ctl).ReadOnly = true;
                }
                if (l.GetLunaActiva().LunaId == LunaID)
                {
                    ((TextBox)ctl).TextChanged += new System.EventHandler(this.TextBox_TextChanged);
                }
                tc = new TableCell();
                tc.Controls.Add(ctl);
                tr.Cells.Add(tc);

                restraintsTable.Rows.Add(tr);
                Center.Controls.Add(restraintsTable);
            }
        }
        /// <summary>
        /// Listeaza categoriile salariale
        /// </summary>
        private void ListCategorii()
        {
            try
            {
                this.mainTable.Rows.Clear();

                list_form.Style.Add("display", "");
                add_form.Style.Add("display", "none");
                btnSalveaza.Visible = false;
                btnSterge.Visible   = false;
                btnInapoi.Visible   = false;
                txtCategorieID.Text = "0";

                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 salariale existente";
                myCell.Height          = new Unit(50);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);

                // lista de impozite 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", "Descriere", "DPB", "Scutire Impozit", "Primeste DPB" };
                string[] tableCols   = { "Denumire", "Descriere", "DPB", "ScutireImpozit", "PrimesteDPB" };

                ListTable objListTable;
                if (Session["AdminCategoriiAngajati_AddAngajat"].ToString() == "0")
                {
                    objListTable = new ListTable(listTable, new Salaries.Business.CategoriiAngajat().GetCategoriiAngajat(Convert.ToInt32(Session["LunaCurenta"])), tableHeader, tableCols);
                }
                else
                {
                    Salaries.Business.Luni luni     = new Salaries.Business.Luni(Convert.ToInt32(Session["AngajatorID"]));
                    Salaries.Data.LunaData lunaData = luni.GetLunaActiva();
                    objListTable = new ListTable(listTable, new Salaries.Business.CategoriiAngajat().GetCategoriiAngajat(lunaData.LunaId), tableHeader, tableCols);
                }

                objListTable.textForEmptyDataSet = "Nu exista nici o categorie ptr. luna selectata!";

                string[] ar_OnClickParam     = { "CategorieID", "Denumire", "Descriere", "DPB", "ScutireImpozit", "ScutireCASAngajat", "ScutireCASAngajator", "ScutireSomajAngajat", "ScutireSomajAngajator", "ScutireAsigSanAngajat", "ScutireAsigSanAngajator", "PrimesteDPB" };
                string[] ar_OnClickParamType = { "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset", "dataset" };

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

                myCell.Controls.Add(listTable);
                myRow.Cells.Add(myCell);
                mainTable.Rows.Add(myRow);
            }
            catch (Exception ex)
            {
                litError.Text  = "The following error occurred: <br>";
                litError.Text += ex.Message;
            }
        }