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); } }
/// <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); } }