/// <summary> /// Metoda care se apeleaza la apasarea butonului de salvare din fereastra de editare. /// Se selecteaza optiunea de Update sau Insert cu datele aferente. /// </summary> private void btnSalveaza_Click(object sender, System.EventArgs e) { try { this.VarExists = new Salaries.Business.NomenclatorTipAbsente().GetTipuriAbsente(int.Parse(this.txtTipAbsentaID.Text)).Tables[0].Rows.Count > 0; Salaries.Data.TipAbsente tipAbs = new Salaries.Data.TipAbsente(); tipAbs.TipAbsentaID = (this.VarExists) ? int.Parse(this.txtTipAbsentaID.Text) : -1; tipAbs.Denumire = this.txtDenumireTipAbsenta.Text; tipAbs.CodAbsenta = this.txtCodTipAbsenta.Text; tipAbs.Procent = float.Parse(this.txtProcentTipAbsenta.Text); tipAbs.Descriere = this.txtDescriereTipAbsenta.Text; tipAbs.Medical = this.cbMedicalTipAbsenta.Checked; tipAbs.Modificare = this.cbModificabilaTipAbsenta.Checked; tipAbs.Folosire = this.cbFolosireTipAbsenta.Checked; tipAbs.Lucratoare = this.cbAbsentaLucratoare.Checked; if (this.VarExists) { new Salaries.Business.NomenclatorTipAbsente().UpdateTipAbsenta(tipAbs); } else { new Salaries.Business.NomenclatorTipAbsente().InsertTipAbsenta(tipAbs); } this.EditMode = false; } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } }
/// <summary> /// Procedura actualizeaza un tip de absenta /// </summary> /// <param name="tipAbs">Obiectul actualizat</param> /// <returns>Returneaza true daca s-a facut actualizarea si false altfel</returns> public bool UpdateTipAbsenta(Salaries.Data.TipAbsente tipAbs) { return(new Salaries.Data.NomenclatorTipAbsente(settings.ConnectionString).UpdateTipAbsente(tipAbs)); }