コード例 #1
0
        /// <summary>
        /// Определение возраста изделия (количество лет с момента продажи/выпуска).
        /// </summary>
        public int GetAge()
        {
            int      Age             = 0;
            CardData CurrentPassport = CardScript.Session.CardManager.GetCardData(new Guid(this.WarePassportID));
            RowData  LoadDate        = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = 'Дата отправки'");

            if (LoadDate.GetDateTime("Value") != null)
            {
                TimeSpan T = DateTime.Today - ((DateTime)LoadDate.GetDateTime("Value"));
                Age = (int)(T.Days / 365);
            }
            else
            {
                RowData DeviceYear = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = '/Год прибора'");
                Age = DateTime.Today.Year - (int)DeviceYear.GetInt32("Value");
            }
            return(Age);
        }
コード例 #2
0
        /// <summary>
        /// Конструктор формы заполнения журнала условий калибровки.
        /// </summary>
        /// <param name="Session">Пользовательская сессия DV.</param>
        /// <param name="Context">Объектный контекст.</param>
        /// <param name="JournalItemType">Тип справочника.</param>
        /// <param name="CurrentItem">Текущая строка справочника.</param>
        /// <param name="CabinetNumber">Номер кабинета.</param>
        public JournalForm(UserSession Session, ObjectContext Context, BaseUniversalItemType JournalItemType, BaseUniversalItem CurrentItem, Int32 CabinetNumber)
        {
            InitializeComponent();
            this.Session = Session;
            this.Context = Context;
            IBaseUniversalService baseUniversalService = Context.GetService <IBaseUniversalService>();

            staffEmployee = Context.GetCurrentEmployee();
            itemCard      = baseUniversalService.OpenOrCreateItemCard(CurrentItem);
            CardData    itemCardData = Session.CardManager.GetCardData(Context.GetObjectRef <BaseUniversalItemCard>(itemCard).Id);
            SectionData CalibrationConditionsSection = itemCardData.Sections[itemCardData.Type.Sections["CalibrationConditions"].Id];
            RowData     CalibrationConditionsRow     = CalibrationConditionsSection.FirstRow;

            this.Text          = "Каб. №" + (CabinetNumber == 237 ? 226 : 228) + ". Условия на " + DateTime.Today.ToShortDateString();
            this.Date.DateTime = (DateTime?)CalibrationConditionsRow.GetDateTime("Date") ?? DateTime.Today;
            this.Employee.Text = CalibrationConditionsRow.GetString("Employee") != null?Context.GetEmployeeDisplay(new Guid(CalibrationConditionsRow.GetString("Employee"))) : staffEmployee.DisplayString;

            this.Temperature.Value = (decimal?)CalibrationConditionsRow.GetDecimal("Temperature") ?? 0;
            this.Humidity.Value    = (decimal?)CalibrationConditionsRow.GetDecimal("Humidity") ?? 0;
            this.Pressure.Value    = (decimal?)CalibrationConditionsRow.GetDecimal("Pressure") ?? 0;
        }