/// <summary> /// Modifica o persoana in intretinere /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModificaPersoana_Click(object sender, System.EventArgs e) { try { int id = int.Parse(persID.Value); Salaries.Business.PersoanaInIntretinere pers = new Salaries.Business.PersoanaInIntretinere(id); pers.Nume = this.txtNume.Text; pers.Prenume = this.txtPrenume.Text; pers.CNP = long.Parse(this.txtCNP.Text); // Modificat: Anca Holostencu pers.TipID = short.Parse(ddlTipPersoana.SelectedValue); pers.InvaliditateID = int.Parse(ddlInvaliditate.SelectedValue); pers.Activ = chkActiv.Checked; if (pers.CheckIfPersoanaIntretinereCanBeAdded(id, pers.CNP)) { pers.Update(); } else { Response.Write("<script>alert( 'Exista deja o persoana cu acest CNP in baza de date!' );</script>"); } } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } LoadPersoaneList(); }
/// <summary> /// Adauga o persoana in intretinere /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdaugaPersInIntretinere_Click(object sender, System.EventArgs e) { try { Salaries.Business.PersoanaInIntretinere pers = new Salaries.Business.PersoanaInIntretinere(); string Nume = this.txtNume.Text; string Prenume = this.txtPrenume.Text; long CNP = long.Parse(this.txtCNP.Text); // Modifcat: Anca Holostencu int TipID = int.Parse(ddlTipPersoana.SelectedValue); int InvaliditateID = int.Parse(ddlInvaliditate.SelectedValue); bool activ = chkActiv.Checked; if (pers.CheckIfPersoanaIntretinereCanBeAdded(-1, CNP)) { pers.Create((int)AngajatID, Nume, Prenume, CNP, TipID, InvaliditateID, activ); } else { Response.Write("<script>alert( 'Exista deja o persoana cu acest CNP in baza de date!' );</script>"); } } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } LoadPersoaneList(); }
/// <summary> /// Sterge o persoana in intretinere /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStergePersoana_Click(object sender, System.EventArgs e) { try { int id = int.Parse(persID.Value); Salaries.Business.PersoanaInIntretinere pers = new Salaries.Business.PersoanaInIntretinere(id); pers.Delete(); } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } LoadPersoaneList(); }