예제 #1
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                int    id  = -1;
                string _id = Request.QueryString["id"].ToString();
                int.TryParse(_id, out id);
                int userId = CurrentEnvironment.LoggedUser.Id;

                AgeDefinitions o = AgeDefinitions.GetAgeDefinitionsById(id);
                if (nameExists(txtName.Text.Replace("'", @"''")) && (o.Name != txtName.Text.Trim()))
                {
                    return;
                }
                o.Name     = txtName.Text.Replace("'", @"''");
                o.Days     = int.Parse(txtDays.Text);
                o.IsActive = bool.Parse(rblIsActive.SelectedValue);
                o.Notes    = txtNotes.Text.Replace("'", @"''");

                int i = AgeDefinitions.Update(o);

                if (i > 0)
                {
                    lblSuccess.Visible = true;
                    lblWarning.Visible = false;
                    lblError.Visible   = false;
                    gvAgeDefinitions.DataBind();
                    ClearControls(this);
                }
                else
                {
                    lblSuccess.Visible = false;
                    lblWarning.Visible = false;
                    lblError.Visible   = true;
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }