/// <summary> /// Procedura verifica daca data este dupa luna activa /// </summary> /// <param name="data">Data verificata</param> /// <returns>Returneaza true daca e dupa luna activa si false altfel</returns> private bool DataDupaLunaCurenta( DateTime data ) { Luni l = new Luni( this.GetAngajator()); Salaries.Data.LunaData ld = l.GetLunaActiva(); DateTime dataUltimaZiLunaActiva = ld.Data.AddMonths( 1 ); return dataUltimaZiLunaActiva<=data; }
/// <summary> /// Salvarea unei valori pentru o variabile globala /// </summary> private void btnSalveaza_Click(object sender, System.EventArgs e) { try { //se selecteaza din baza de date informatiile despre variabila selectata VariabileGlobaleValori objVariabileGlobaleValori = new VariabileGlobaleValori(); this.VarExists = objVariabileGlobaleValori.GetVariabileGlobaleValoriInfo(int.Parse(this.txtVariabilaGlobalaID.Text)); //se determina luna curenta Luni luni = new Luni(this.GetAngajator()); lunaId = luni.GetLunaActiva().LunaId; //se completeaza controalele cu valorile existente objVariabileGlobaleValori.VariabilaGlobalaID = int.Parse(this.drpTipVariabila.SelectedValue); objVariabileGlobaleValori.Valoare = float.Parse(this.txtValoare.Text); objVariabileGlobaleValori.LunaID = lunaId; objVariabileGlobaleValori.ID = (this.VarExists) ? int.Parse(this.txtVariabilaGlobalaID.Text) : -1; //daca variabila exista deja atunci se actiualizeaza cu noile valori if (this.VarExists) { objVariabileGlobaleValori.Update(); } //daca variabila nu exista se adauga else { objVariabileGlobaleValori.Insert(); } this.EditMode = false; drpPerioada.Enabled = true; drpTipVariabila.Enabled = true; if (!EditMode) { //se determina lista cu tipuri de variabile care mai trebuie adaugate LoadTipVariabile(); //daca mai exista atunci ramane butonul pentru adaugare si se selecteaza primul tip de variabila if (drpTipVariabila.Items.Count > 0) { drpTipVariabila.SelectedIndex = 0; btnAdaugaVariabilaGlobala.Visible = true; } //daca nu mai exista variabile dispare butonul pentru adaugare else { btnAdaugaVariabilaGlobala.Visible = false; } } } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } }
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> /// Proceudra verifica daca o data este in luna curenta /// </summary> /// <param name="data">Date care se verifica</param> /// <returns>Returneaza true daca e in luna curenta si false altfel</returns> private bool DataInLunaCurenta( DateTime data ) { Luni l = new Luni( this.GetAngajator()); Salaries.Data.LunaData ld = l.GetLunaActiva(); return (ld.Data.Month == data.Month) && (ld.Data.Year == data.Year); }