Example #1
0
        private void SaveItem()
        {
            bool success = false;

            try {
                if (PassedValidation())
                {
                    ServerPort item = new ServerPort(int.Parse(hfItemID.Value));
                    SPA.User   user = new SPA.User(Context.User.Identity.Name);
                    item.ServerID = ServerID;
                    item.PortID   = int.Parse(ddlPort.SelectedValue);

                    item.ModifiedBy = user.UserName;
                    if (item.ID == 0)
                    {
                        item.CreatedBy = item.ModifiedBy;
                        if (item.Insert())
                        {
                            success = true;
                        }
                    }
                    else
                    {
                        if (item.Update())
                        {
                            success = true;
                        }
                    }
                    if (success)
                    {
                        Fill();
                    }
                }
                else
                {
                    // validation failed
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            Response.Redirect(string.Format("{0}/{1}?View=Edit&ID={2}&ServerID={2}&IsDlg=1Filter={3}", SPContext.Current.Web.Url, Pages.ServerItem.PAGE_URL, ServerID, Filter), false);
        }