Beispiel #1
0
        /// <summary>
        /// Загружает cвойства настройки
        /// </summary>
        /// <param name="objSetting">настройка</param>
        public void LoadSettingProperties(CSetting objSetting)
        {
            m_bDisableEvents = true;
            if (objSetting == null)
            {
                return;
            }
            try
            {
                m_objSetting        = objSetting;
                lblSettingName.Text = m_objSetting.Name;

                tableLayoutPanel1.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.treeListParams)).BeginInit();

                treeListParams.Nodes.Clear();

                if (m_objSetting.xmldocAdvancedParamList != null)
                {
                    foreach (System.Xml.XmlNode objNode in m_objSetting.xmldocAdvancedParamList.ChildNodes)
                    {
                        AddNode(treeListParams, null, objNode);
                    }
                }

                //if (m_objSetting.ParamList != null)
                //{
                //    System.String strGroupName = "";
                //    DevExpress.XtraTreeList.Nodes.TreeListNode objGroupNode = null;
                //    foreach (CAdvancedParam objParam in m_objSetting.ParamList)
                //    {
                //        if ((objParam.GroupName != "") && (objParam.GroupName != strGroupName))
                //        {
                //            strGroupName = objParam.GroupName;
                //            objGroupNode = treeListParams.AppendNode(new object[] { strGroupName, null }, null);
                //        }
                //        treeListParams.AppendNode(new object[] { objParam.Name, objParam.Value }, objGroupNode).Tag = objParam;
                //    }
                //}
                treeListParams.ExpandAll();
                this.tableLayoutPanel1.ResumeLayout(false);
                ((System.ComponentModel.ISupportInitialize)(this.treeListParams)).EndInit();

                SetPropertiesModified(false);

                SetModeReadOnly(true);
                btnCancel.Enabled = true;
                btnCancel.Focus();
            }
            catch (System.Exception f)
            {
                SendMessageToLog("Ошибка редактирования описания настройки. Текст ошибки: " + f.Message);
            }
            finally
            {
                m_bDisableEvents = false;
            }
            return;
        }
Beispiel #2
0
        public ctrlSetting(UniXP.Common.CProfile objProfile, UniXP.Common.MENUITEM objMenuItem)
        {
            m_objProfile     = objProfile;
            m_objMenuItem    = objMenuItem;
            m_objSetting     = null;
            m_bIsChanged     = false;
            m_bDisableEvents = false;

            InitializeComponent();
        }
Beispiel #3
0
 /// <summary>
 /// Сохраняет в БД настройки для импорта данных в заказ
 /// </summary>
 /// <param name="objProfile">профайл</param>
 /// <param name="cmdSQL">SQL-команда</param>
 /// <param name="strErr">строка с сообщением об ошибке</param>
 /// <returns>true - успешное завершение операции; false - ошибка</returns>
 public System.Boolean SaveExportSetting(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                         ref System.String strErr)
 {
     System.Boolean bRet = false;
     try
     {
         bRet = CSetting.SaveSettingInDB(this.ID, this.XMLSettings.InnerXml, objProfile, cmdSQL, ref strErr);
     }
     catch (System.Exception f)
     {
         strErr += (f.Message);
     }
     finally
     {
     }
     return(bRet);
 }
Beispiel #4
0
        /// <summary>
        /// Сохраняет изменения в базе данных
        /// </summary>
        /// <returns>true - удачное завершение операции;false - ошибка</returns>
        private System.Boolean bSaveChanges()
        {
            System.Boolean bRet = false;

            try
            {
                //CAdvancedParam objAdvancedParam = null;
                CSetting objSettingForSave = new CSetting();
                objSettingForSave.Name = m_objSetting.Name;
                objSettingForSave.ID   = m_objSetting.ID;
                objSettingForSave.xmldocAdvancedParamList = m_objSetting.xmldocAdvancedParamList;
                objSettingForSave.ParamList = new List <CAdvancedParam>();
                if (objSettingForSave.xmldocAdvancedParamList != null)
                {
                    for (System.Int32 i = 0; i < objSettingForSave.xmldocAdvancedParamList.ChildNodes.Count; i++)
                    {
                        SetNode(objSettingForSave.xmldocAdvancedParamList.ChildNodes[i], treeListParams.Nodes[i]);
                    }
                }
                System.String strErr = "";
                if (objSettingForSave.SaveSettingInDB(m_objProfile, null, ref strErr) == true)
                {
                    m_objSetting.xmldocAdvancedParamList = objSettingForSave.xmldocAdvancedParamList;
                    bRet = true;
                }
                else
                {
                    SendMessageToLog("Ошибка сохранения изменений в описании настройки. Текст ошибки: " + strErr);
                }
            }
            catch (System.Exception f)
            {
                SendMessageToLog("Ошибка сохранения изменений в описании настройки. Текст ошибки: " + f.Message);
            }
            finally
            {
            }
            return(bRet);
        }
Beispiel #5
0
        /// <summary>
        /// Возвращает список настроек
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список настроек</returns>
        public static List <CSetting> GetSettingsList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CSetting> objList = new List <CSetting>();

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show(
                            "Не удалось получить соединение с базой данных.", "Внимание",
                            System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return(objList);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.CommandText = System.String.Format("[{0}].[dbo].[sp_GetSettings]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000));
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CSetting objSetting = null;
                    System.Xml.XmlDocument docInfoAboutParam = null;
                    CAdvancedParam         objParam          = null;
                    System.Xml.XmlNode     objRootNode       = null;
                    while (rs.Read())
                    {
                        objSetting           = new CSetting();
                        objSetting.ID        = (System.Guid)rs["Settings_Guid"];
                        objSetting.Name      = System.Convert.ToString(rs["Settings_Name"]);
                        objSetting.ParamList = new List <CAdvancedParam>();
                        if (rs["Settings_XML"] != System.DBNull.Value)
                        {
                            docInfoAboutParam = new System.Xml.XmlDocument();
                            docInfoAboutParam.LoadXml(System.Convert.ToString(rs["Settings_XML"]));
                            if ((docInfoAboutParam != null) && (docInfoAboutParam.ChildNodes.Count > 0))
                            {
                                objSetting.xmldocAdvancedParamList = docInfoAboutParam;
                                objRootNode = docInfoAboutParam.ChildNodes[0];
                                //objSetting.Name = objRootNode.Name;

                                foreach (System.Xml.XmlNode objNode in objRootNode.ChildNodes)
                                {
                                    //if (objNode.Name == "CommonParams")
                                    //{
                                    foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                                    {
                                        //if (objChildNode.Name == "Params")
                                        //{
                                        foreach (System.Xml.XmlAttribute objAttribute in objChildNode.Attributes)
                                        {
                                            objParam           = new CAdvancedParam(System.Guid.Empty, objAttribute.Name, "", new CParamDataType(0, ""));
                                            objParam.GroupName = objNode.Name;
                                            objParam.Value     = objAttribute.Value;
                                            objSetting.ParamList.Add(objParam);
                                        }
                                        //}
                                        //}
                                    }
                                }
                            }
                        }

                        objList.Add(objSetting);
                    }
                }
                rs.Dispose();

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Не удалось получить список настроек.\n\nТекст ошибки: " + f.Message, "Внимание",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(objList);
        }