예제 #1
0
        public void ClearPosition()
        {
            Cases caseAccessory = this as Cases;

            if (caseAccessory != null)
            {
                Status = TypesOfLampsStatus.Storage;
                caseAccessory.Position = 0;
                caseAccessory.Map      = 0;
                caseAccessory.Register = 0;
            }
        }
예제 #2
0
        /// <summary>ВСтановити статус комплектующего</summary>
        /// <param name="accessory">Тип комплектуючого</param>
        /// <param name="barcode">Штихкод</param>
        /// <param name="state">Новий статус</param>
        public static void SetNewState(TypeOfAccessories accessory, string barcode, TypesOfLampsStatus state)
        {
            if (accessory == TypeOfAccessories.Case)
            {
                Cases.ChangeLighterState(barcode, state, true);
            }

            string command = string.Format(
                "UPDATE {0}s SET Status=@{1} WHERE RTRIM({2})=RTRIM(@{2})",
                accessory, dbSynchronizer.PARAMETER, BARCODE_NAME);

            using (SqlCeCommand query = dbWorker.NewQuery(command))
            {
                query.AddParameter(BARCODE_NAME, barcode);
                query.AddParameter(dbSynchronizer.PARAMETER, state);
                query.ExecuteNonQuery();
            }
        }
예제 #3
0
        /// <summary>Копіювати без посилань на комплектуюче</summary>
        /// <returns>Нове комплектуюче (ще без ІД)</returns>
        public Accessory CopyWithoutLinks()
        {
            dbObject copyObj = base.Copy();

            Accessory accessoryCopy = (copyObj as Accessory);

            if (accessoryCopy != null)
            {
                accessoryCopy.Id      = 0;
                accessoryCopy.BarCode = string.Empty;
            }

            Cases caseObj = copyObj as Cases;

            //BarCode = string.Empty;

            if (caseObj != null)
            {
                caseObj.Lamp           = 0;
                caseObj.ElectronicUnit = 0;

                return(caseObj);
            }

            ElectronicUnits unitObj = copyObj as ElectronicUnits;

            if (unitObj != null)
            {
                unitObj.Case = 0;
                return(unitObj);
            }

            Lamps lampObj = copyObj as Lamps;

            if (lampObj != null)
            {
                lampObj.Case = 0;
                return(lampObj);
            }

            return((Accessory)copyObj);
        }
예제 #4
0
        public override void OnBarcode(string barcode)
        {
            if (barcode.IsValidBarcode())
                {
                long id = Cases.GetIdByBarcode(barcode);
                if (id == 0)
                    {
                    ShowMessage("Не знайдено корпусу з таким штрих-кодом!");
                    return;
                    }

                Cases _case = new Cases();
                _case.Read(id);
                _case.Map = map;
                _case.Register = register;
                _case.Position = position;
                _case.IsSynced = false;
                _case.Status = TypesOfLampsStatus.IsWorking;
                _case.Write();

                leaveProcess();
                }
        }
예제 #5
0
        /// <summary>Получить визуальное представление (с информацией о элементах на которые возможны переходы)</summary>
        /// <param name="id">ID комплектующего</param>
        /// <param name="typeOfAccessories">Тип комплектующего</param>
        /// <param name="topic">Заголовок</param>
        /// <param name="listOfDetail">Словарь єлементов с детальной информацией</param>
        /// <returns>Список ...</returns>
        public static List <LabelForConstructor> GetVisualPresenter(long id, TypeOfAccessories typeOfAccessories, out string topic, out Dictionary <string, KeyValuePair <Type, object> > listOfDetail)
        {
            Accessory accessory = null;

            switch (typeOfAccessories)
            {
            case TypeOfAccessories.Lamp:
                accessory = new Lamps();
                accessory.Read <Lamps>(id);
                break;

            case TypeOfAccessories.Case:
                accessory = new Cases();
                accessory.Read <Cases>(id);
                break;

            case TypeOfAccessories.ElectronicUnit:
                accessory = new ElectronicUnits();
                accessory.Read <ElectronicUnits>(id);
                break;
            }

            return(GetVisualPresenter(typeOfAccessories, accessory, out topic, out listOfDetail));
        }
예제 #6
0
파일: Cases.cs 프로젝트: AramisIT/Lamps
        /// <summary>Отримати назву таблиці комплектуючого за типом</summary>
        /// <param name="type">Тип комплектуючого</param>
        /// <returns>Назва таблиці комплектуючого</returns>
        public static string GetTableNameForAccessory(TypeOfAccessories type)
            {
            Accessory accessory = null;

            switch (type)
                {
                case TypeOfAccessories.Lamp:
                    accessory = new Lamps();
                    break;
                case TypeOfAccessories.ElectronicUnit:
                    accessory = new ElectronicUnits();
                    break;
                case TypeOfAccessories.Case:
                    accessory = new Cases();
                    break;
                }

            if (accessory == null)
                {
                throw new Exception("Не знайдено тип комплектуючого!");
                }

            return accessory.GetType().Name;
            }
예제 #7
0
        /// <summary>�������� ���������� ������������� (� ����������� � ��������� �� ������� �������� ��������)</summary>
        /// <param name="barcode">��������</param>
        /// <param name="topic">���������</param>
        /// <param name="listOfDetail">������� ��������� � ��������� �����������</param>
        /// <returns>������ ...</returns>
        public static List<LabelForConstructor> GetVisualPresenter(string barcode, out string topic, out Dictionary<string, KeyValuePair<Type, object>> listOfDetail)
        {
            TypeOfAccessories typeOfAccessories = BarcodeWorker.GetTypeOfAccessoriesByBarcode(barcode);
            Accessory accessory = null;

            switch (typeOfAccessories)
                {
                case TypeOfAccessories.Lamp:
                    accessory = new Lamps();
                    accessory.Read<Lamps>(barcode);
                    break;
                case TypeOfAccessories.Case:
                    accessory = new Cases();
                    accessory.Read<Cases>(barcode);
                    break;
                case TypeOfAccessories.ElectronicUnit:
                    accessory = new ElectronicUnits();
                    accessory.Read<ElectronicUnits>(barcode);
                    break;
                }

            return GetVisualPresenter(typeOfAccessories, accessory, out topic, out listOfDetail);
        }
예제 #8
0
        private void startGroupRegistration()
        {
            currentCase = accessory as Cases;

            if (currentCase.Lamp == 0 || currentCase.ElectronicUnit == 0)
                {
                ShowMessage("����� ��������� ����� � ��. ����!");
                return;
                }

            if (!(accessory is Cases))
                {
                return;
                }

            currentLamp = new Lamps();
            currentLamp.Read(currentCase.Lamp);

            currentUnit = new ElectronicUnits();
            currentUnit.Read(currentCase.ElectronicUnit);

            if (!string.IsNullOrEmpty(currentLamp.BarCode) || !string.IsNullOrEmpty(currentUnit.BarCode))
                {
                ShowMessage("��� ������� ��������� ����� �� ���� ����� ���� ��� �����-����");
                return;
                }

            if (isMainDataEntered && warrantlyDataIsValid())
                {
                accessory.Write();
                }
            else
                {
                showWriteErrorMessage();
                return;
                }

            groupRegistration = true;

            currentCase = new Cases();
            currentCase.Read(accessory.Id);

            groupRegistrationButton.Hide();
            groupSizeLabel = MainProcess.CreateLabel("", 5, 283, 230,
                                        MobileFontSize.Normal, MobileFontPosition.Left, MobileFontColors.Info, FontStyle.Bold);
            groupSize = 0;
        }
예제 #9
0
        /// <summary>Получить визуальное представление (с информацией о элементах на которые возможны переходы)</summary>
        /// <param name="typeOfAccessories">Тип комплектующего</param>
        /// <param name="accessory">Объект</param>
        /// <param name="topic">Заголовок</param>
        /// <param name="listOfDetail">Словарь єлементов с детальной информацией</param>
        /// <returns>Список ...</returns>
        public static List <LabelForConstructor> GetVisualPresenter(TypeOfAccessories typeOfAccessories, Accessory accessory, out string topic, out Dictionary <string, KeyValuePair <Type, object> > listOfDetail)
        {
            topic        = Cases.GetDescriptionOfAccessory(typeOfAccessories);
            listOfDetail = new Dictionary <string, KeyValuePair <Type, object> >();
            List <LabelForConstructor> list = new List <LabelForConstructor>();

            bool notCase = (typeOfAccessories == TypeOfAccessories.ElectronicUnit ||
                            typeOfAccessories == TypeOfAccessories.Lamp);

            if (accessory != null)
            {
                Type           type   = accessory.GetType();
                PropertyInfo[] fields = type.GetProperties();

                if (notCase)
                {
                    listOfDetail.Add("Корпус", new KeyValuePair <Type, object>(typeof(Cases), CatalogHelper.FindCaseId(accessory.Id, typeOfAccessories)));
                }

                foreach (PropertyInfo field in fields)
                {
                    if (notCase && field.Name == "Case")
                    {
                        continue;
                    }
                    Attribute[] attributes = Attribute.GetCustomAttributes(field);

                    foreach (Attribute a in attributes)
                    {
                        dbFieldAtt attribute = a as dbFieldAtt;

                        if (attribute != null)
                        {
                            if (attribute.NeedDetailInfo)
                            {
                                object value = field.GetValue(accessory, null);
                                listOfDetail.Add(attribute.Description, new KeyValuePair <Type, object>(attribute.dbObjectType, value));
                            }
                            else if (!attribute.NotShowInForm || attribute.ShowEmbadedInfo)
                            {
                                object value = field.GetValue(accessory, null);

                                if (attribute.dbObjectType == null)
                                {
                                    if (field.PropertyType == typeof(DateTime))
                                    {
                                        DateTime dateValue = (DateTime)value;

                                        value = dateValue != SqlDateTime.MinValue.Value
                                                    ? String.Format("{0:dd.MM.yyyy}", dateValue)
                                                    : string.Empty;
                                    }
                                    else if (field.PropertyType.IsEnum)
                                    {
                                        value = EnumWorker.GetDescription(field.PropertyType, Convert.ToInt32(value));
                                    }
                                    else if (field.PropertyType == typeof(bool))
                                    {
                                        value = (bool)value ? "+" : "-";
                                    }
                                }
                                else
                                {
                                    if (attribute.ShowEmbadedInfo)
                                    {
                                        dbObject detailObject = (dbObject)Activator.CreateInstance(attribute.dbObjectType);
                                        detailObject = (dbObject)detailObject.Read(attribute.dbObjectType, value, IDENTIFIER_NAME);
                                        Dictionary <string, KeyValuePair <Type, object> > subListOfDetail;
                                        List <LabelForConstructor> subList = GetSingleVisualPresenter(
                                            attribute.dbObjectType, out subListOfDetail, detailObject, false);

                                        list.AddRange(subList);
                                    }

                                    if (!attribute.NotShowInForm)
                                    {
                                        value = ReadDescription(attribute.dbObjectType, value);
                                    }
                                }

                                string data = String.Format("{0}: {1}", attribute.Description, value);

                                list.Add(new LabelForConstructor(data, ControlsStyle.LabelSmall, false));
                                break;
                            }
                        }
                    }
                }
            }

            return(list);
        }
예제 #10
0
파일: Cases.cs 프로젝트: AramisIT/Lamps
        /// <summary>�������� ����� ������� �������������� �� �����</summary>
        /// <param name="type">��� ��������������</param>
        /// <returns>����� ������� ��������������</returns>
        public static string GetTableNameForAccessory(TypeOfAccessories type)
        {
            Accessory accessory = null;

            switch (type)
                {
                case TypeOfAccessories.Lamp:
                    accessory = new Lamps();
                    break;
                case TypeOfAccessories.ElectronicUnit:
                    accessory = new ElectronicUnits();
                    break;
                case TypeOfAccessories.Case:
                    accessory = new Cases();
                    break;
                }

            if (accessory == null)
                {
                throw new Exception("�� �������� ��� ��������������!");
                }

            return accessory.GetType().Name;
        }