Пример #1
0
        public bool SaveForm(ref string strResult)
        {
            STD_REGISTRY registry = null;

            if (string.IsNullOrEmpty(txtRegistryName.Text))
            {
                strResult = "<ul><li>Registry Name is Required</li></ul>";
            }
            else if (string.IsNullOrEmpty(txtRegistryCode.Text))
            {
                strResult = "<ul><li>Registry Code is Required</li></ul>";
            }
            else if (string.IsNullOrEmpty(txtRegistryDescription.Text))
            {
                strResult = "<ul><li>Description is Required</li></ul>";
            }
            else
            {
                int id = 0;
                if (!string.IsNullOrEmpty(hideRegistryId.Value))
                {
                    int.TryParse(hideRegistryId.Value, out id);
                }

                registry = ServiceInterfaceManager.STD_REGISTRY_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);
                if (registry == null)
                {
                    registry = new STD_REGISTRY();
                }

                registry.CREATEDBY        = registry.UPDATEDBY = HttpContext.Current.User.Identity.Name;
                registry.NAME             = txtRegistryName.Text;
                registry.CODE             = txtRegistryCode.Text.Trim();
                registry.DESCRIPTION_TEXT = txtRegistryDescription.Text;

                int userId = 0;
                int.TryParse(listRegistryOwner.SelectedValue, out userId);
                if (userId > 0)
                {
                    registry.REGISTRY_OWNER = userId;
                }
                else
                {
                    registry.REGISTRY_OWNER = null;
                }

                userId = 0;
                int.TryParse(listRegistryAdministrator.SelectedValue, out userId);
                if (userId > 0)
                {
                    registry.REGISTRY_ADMINISTRATOR = userId;
                }
                else
                {
                    registry.REGISTRY_ADMINISTRATOR = null;
                }

                userId = 0;
                int.TryParse(listSupportContact.SelectedValue, out userId);
                if (userId > 0)
                {
                    registry.REGISTRY_SUPPORT_CONTACT = userId;
                }
                else
                {
                    registry.REGISTRY_SUPPORT_CONTACT = null;
                }

                registry.ID = ServiceInterfaceManager.STD_REGISTRY_SAVE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, registry);
                if (registry.ID > 0)
                {
                    ApplicationSession.Refresh(false);

                    hideRegistryId.Value = registry.ID.ToString();
                    strResult            = "Save successful<br /><br />";
                    return(true);
                }
                else
                {
                    strResult = "Error saving Registry, please try again<br /><br />";
                }
            }

            return(false);
        }