Ejemplo n.º 1
0
    static void ShowWindow()
    {
        Rect          wr     = new Rect(0, 0, 500, 500);
        SettingEditor window = (SettingEditor)EditorWindow.GetWindowWithRect(typeof(SettingEditor), wr, true, "Setting");

        window.Show();
    }
        private void DoSave()
        {
            //bool hasErrors = false;
            string message = "";

            foreach (GridViewRow row in gv.Rows)
            {
                SettingEditor e = (SettingEditor)row.FindControl("uxSettingEditor");

                var s = new DAL.SRPSettings();
                s       = s.GetSRPSettings(int.Parse(e.SID));
                s.Value = e.Value;
                try
                {
                    if (s.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        s.Update();
                    }
                    else
                    {
                        message = message + String.Format("Setting \"{0}\" has errors: {1}", s.Name, "<ul>");
                        foreach (BusinessRulesValidationMessage m in s.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                    }
                }
                catch (Exception ex)
                {
                    message = message + String.Format("Setting \"{0}\" has errors: <ul><li>{1}</li></ul>", s.Name, ex.Message);
                }
            }
            if (message.Length > 0)
            {
                MasterPage.PageError = message;
            }
            else
            {
                MasterPage.PageMessage = SRPResources.SaveAllOK;
            }
        }