Пример #1
0
 /// <summary>
 /// Загружает в m_objAllConstTypeList список типов констант
 /// </summary>
 /// <param name="objProfile">профайл</param>
 /// <param name="cmdSQL">SQL-команда</param>
 public void InitConstTypeList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
 {
     try
     {
         this.m_objAllConstTypeList = CConstType.GetConstTypeList(objProfile, cmdSQL);
         if ((this.m_objAllConstTypeList != null) && (this.m_objAllConstTypeList.Count > 0))
         {
             this.ConstType = this.m_objAllConstTypeList[0];
         }
     }
     catch (System.Exception f)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show(
             "Не удалось загрузить список типов констант.\n\nТекст ошибки: " + f.Message, "Внимание",
             System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
     return;
 }
Пример #2
0
        public static List <CConst> GetConstList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CConst> objList = new List <CConst>();

            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].[usp_GetConst]", 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)
                {
                    while (rs.Read())
                    {
                        objList.Add(new CConst()
                        {
                            ID           = (System.Guid)rs["Const_Guid"],
                            Name         = System.Convert.ToString(rs["Const_Name"]),
                            DataTypeName = System.Convert.ToString(rs["Const_DataTypeName"]),
                            Description  = ((rs["Const_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Const_Description"])),
                            Value        = System.Convert.ToString(rs["Const_Value"]),
                            ConstType    = new CConstType()
                            {
                                ID          = (System.Guid)rs["ConstType_Guid"],
                                Name        = System.Convert.ToString(rs["ConstType_Name"]),
                                Description = ((rs["ConstType_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["ConstType_Description"])),
                                IsActive    = System.Convert.ToBoolean(rs["ConstType_IsActive"])
                            }
                        });
                    }
                }
                rs.Dispose();

                List <CConstType> objConstTypeList = CConstType.GetConstTypeList(objProfile, cmd);

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
                // а это для выпадающих списков
                if (objConstTypeList != null)
                {
                    foreach (CConst objConst in objList)
                    {
                        objConst.m_objAllConstTypeList = objConstTypeList;
                    }
                }
            }
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Не удалось получить список констант.\n\nТекст ошибки: " + f.Message, "Внимание",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(objList);
        }