Update() публичный Метод

public Update ( ) : void
Результат void
Пример #1
0
        private void OnEditOptionsExecute()
        {
            var placeOptVM = new PlaceOptionsViewModel(Place.Options);

            if (InsService.ShowDialog(placeOptVM) == true)
            {
                Place.Update();
            }
        }
Пример #2
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;
                revPlace.Visible = false;

                Place o = Place.GetPlaceById(id);

                if (placeId == null)
                {
                    revPlace.Visible = true;
                    return;
                }
                if (Place.GetPlaceById(int.Parse(placeId)) == null)
                {
                    revPlace.Visible = true;
                    return;
                }
                if (!correct())
                {
                    return;
                }
                if (nameExists(txtName.Text.Trim(), int.Parse(placeId)) && (o.Name != txtName.Text.Trim()))
                {
                    return;
                }

                o.Name       = txtName.Text.Trim();
                o.Code       = txtCode.Text;
                o.ParentId   = int.Parse(placeId);
                o.Leaf       = bool.Parse(rblLeaf.SelectedValue);
                o.Notes      = txtNotes.Text.Replace("'", @"''");
                o.IsActive   = bool.Parse(rblIsActive.SelectedValue);
                o.ModifiedOn = DateTime.Now;
                o.ModifiedBy = userId;
                if (ddlHealthFacility.SelectedIndex > 0)
                {
                    o.HealthFacilityId = int.Parse(ddlHealthFacility.SelectedValue);
                }
                else
                {
                    o.HealthFacilityId = null;
                }
                //if (healthFacilityId != null && (HealthFacility.GetHealthFacilityById(int.Parse(healthFacilityId)) != null))
                //    o.HealthFacilityId = int.Parse(healthFacilityId);
                if (id == 1)
                {
                    o.IsActive = true;
                }
                int i = Place.Update(o);

                if (i > 0)
                {
                    lblSuccess.Visible = true;
                    lblWarning.Visible = false;
                    lblError.Visible   = false;
                    lblInfo.Visible    = false;
                    // gridview_Databind(i);
                    ClearControls(this);
                    revPlace.Visible = false;
                    HttpContext.Current.Session["_successPlace"] = "1";
                    HttpContext.Current.Session["_lastPlace"]    = id;
                    Response.Redirect(Request.RawUrl);
                }
                else
                {
                    lblSuccess.Visible = false;
                    lblWarning.Visible = false;
                    lblError.Visible   = true;
                    lblInfo.Visible    = false;
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }