예제 #1
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                bool isUpdate = (IView == ItemView.Edit);
                item      = (isUpdate) ? new GroupType(ItemID) : new GroupType();
                item.Name = txtName.Text.Trim();
                if (!Common.IsNumeric(txtDisplayIndex.Text.Trim()))
                {
                    txtDisplayIndex.Text = "1";
                }
                item.DisplayIndex = int.Parse(txtDisplayIndex.Text.Trim());
                item.IsActive     = cbIsActive.Checked;
                item.ModifiedBy   = CurrentUser.DisplayName;

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }