Beispiel #1
0
        public CreateDefectContentPage(int cIsso, int cGrConstr, string description, IReadOnlyList <object> args)
        {
            InitializeComponent();
            Title = $"{description}. Выбор параметров дефекта.";
            var defectModel = new CreateDefectModel
            {
                CIsso          = cIsso,
                CGrConstr      = cGrConstr,
                Description    = description,
                CDefect        = (int)args[0],
                NDefect        = (string)args[1],
                ParentTreeNode = ((Ais7DefectItem)args[2]).Parent
            };

            defectModel.DefectParameters = Ais7DefectParamValue.ReturnDefectParameters(defectModel.CDefect, defectModel.CGrConstr);
            BindingContext = _vm = new CreateDefectViewModel(defectModel);

            // Прописываем, какие индексы у страниц для удобства
            _indexAdvanced = CarouselView.ItemsSource.Cast <ContentView>().IndexOf(page => page is AdditionalDefectParametersContentView);
            _indexSummary  = CarouselView.ItemsSource.Cast <ContentView>().IndexOf(page => page is SummaryDefectContentView);
            _indexQuality  = CarouselView.ItemsSource.Cast <ContentView>().IndexOf(page => page is QualityParametersTreeView);
            _indexQuantity = CarouselView.ItemsSource.Cast <ContentView>().IndexOf(page => page is QuantityParametersContentPage);

            // Последнему разрешаем работу с кнопкой с самого начала
            _interactors = new List <bool>(new bool[_indexSummary + 1])
            {
                [_indexSummary] = true
            };
            MessagingCenter.Subscribe <Tuple <DefectType, bool> >(this, "InteractionChanged", (interact) => InteractionChanged(interact, EventArgs.Empty));
            ButtonForward.IsEnabled = false;
        }
        /// <summary>
        /// Получить экземпляры этого класса для определенного типа дефекта
        /// </summary>
        /// <param name="cDefect"></param>
        /// <param name="cGrConstr"></param>
        /// <returns></returns>
        internal static List <Ais7DefectParamValue> ReturnDefectParameters(int cDefect, int cGrConstr)
        {
            // Запрос получения списка параметров дефекта
            var query =
                "select * from s_defparamvalue " +
                "left outer join s_defparam on s_defparam.c_defparam=s_defparamvalue.c_defparam " +
                "left outer join s_unit_dimension on s_unit_dimension.c_unit_dimen=s_defparamvalue.c_unit_dimen " +
                $"where c_defect={cDefect} and c_gr_constr={cGrConstr} " +
                "order by c_unit_dimen, n";
            // Получения таблицы
            var reader           = SqliteReader.SelectQueryReader(query, out var conn);
            var defectParameters = new List <Ais7DefectParamValue>();

            // Пока есть строки - читаем
            if (reader != null && reader.HasRows)
            {
                while (reader.Read())
                {
                    var parameter = new Ais7DefectParamValue
                    {
                        Name     = reader.GetString(reader.GetOrdinal("N_DEFPARAM")),
                        Category = !reader.IsDBNull(reader.GetOrdinal("CATEGORY"))
                                                ? reader.GetInt16(reader.GetOrdinal("CATEGORY"))
                                                : (short)(-1),
                        CDefParam  = reader.GetInt16(reader.GetOrdinal("C_DEFPARAM")),
                        IsQual     = reader.IsDBNull(reader.GetOrdinal("C_UNIT_DIMEN")),
                        B          = !reader.IsDBNull(reader.GetOrdinal("B")) ? reader.GetInt16(reader.GetOrdinal("B")) : (short)-1,
                        D          = !reader.IsDBNull(reader.GetOrdinal("D")) ? reader.GetInt16(reader.GetOrdinal("D")) : (short)-1,
                        R          = !reader.IsDBNull(reader.GetOrdinal("R")) ? reader.GetInt16(reader.GetOrdinal("R")) : (short)-1,
                        G          = !reader.IsDBNull(reader.GetOrdinal("B")) && reader.GetBoolean(reader.GetOrdinal("B")),
                        ValueStart = !reader.IsDBNull(reader.GetOrdinal("MIN_VALUE"))
                                                ? reader.GetDouble(reader.GetOrdinal("MIN_VALUE"))
                                                : double.NaN,
                        ValueEnd = !reader.IsDBNull(reader.GetOrdinal("MAX_VALUE"))
                                                ? reader.GetDouble(reader.GetOrdinal("MAX_VALUE"))
                                                : double.NaN,
                        MinParamValue = !reader.IsDBNull(reader.GetOrdinal("MIN_V"))
                                                ? reader.GetDouble(reader.GetOrdinal("MIN_V"))
                                                : 0,
                        MaxParamValue = !reader.IsDBNull(reader.GetOrdinal("MAX_V"))
                                                ? reader.GetDouble(reader.GetOrdinal("MAX_V"))
                                                : double.MaxValue,
                        SnUnit = !reader.IsDBNull(reader.GetOrdinal("SN_UNIT_DIME"))
                                                ? reader.GetString(reader.GetOrdinal("SN_UNIT_DIME"))
                                                : null
                    };
                    parameter.B1 = parameter.B;
                    parameter.D1 = parameter.D;
                    parameter.R1 = parameter.R;
                    parameter.G1 = parameter.G;


                    defectParameters.Add(parameter);
                }
            }
            // Закрываем подключение к БД
            reader?.Close();
            conn.Close();
            return(defectParameters);
        }