Esempio n. 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;

                ItemCategory o = ItemCategory.GetItemCategoryById(id);

                o.Name       = txtName.Text.Replace("'", @"''");
                o.Code       = txtCode.Text.Replace("'", @"''");
                o.IsActive   = bool.Parse(rblIsActive.SelectedValue);
                o.Notes      = txtNotes.Text.Replace("'", @"''");
                o.ModifiedOn = DateTime.Now;
                o.ModifiedBy = userId;
                if (id == 1 || id == 2 || id == 3)
                {
                    o.IsActive = true;
                }
                int i = ItemCategory.Update(o);

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