Esempio n. 1
0
        /// <summary>Комплектующее отсканировано, нужно начать редактирование</summary>
        /// <param name="Barcode">ШтрихКод</param>
        public override sealed void OnBarcode(string barcode)
        {
            //Если это штрих-код комплектующего
            if (barcode.IsValidBarcode())
            {
                if (groupRegistration)
                {
                    groupRegistrationOnBarcode(barcode);
                    return;
                }
                MainProcess.ClearControls();
                this.barcode = barcode;
                bool accesoryIsExist = !string.IsNullOrEmpty(barcode) && BarcodeWorker.IsBarcodeExist(barcode);

                //Если в системе уже существует штрихкод
                if (!existMode && accesoryIsExist)
                {
                    //Тип комплектующего штрихкода
                    TypeOfAccessories typesOfAccessories = BarcodeWorker.GetTypeOfAccessoriesByBarcode(barcode);
                    //Является ли тип комплектующего (существующий) = типу который нужно отредактировать (отсканированный)
                    bool isTypeLikeCurrent = typesOfAccessories.ToString() + 's' != currentType.Name;

                    //Если типы не совпадают - "Выход"
                    if (isTypeLikeCurrent)
                    {
                        ShowMessage("Штрихкод уже используется в другом типе комплектующего!");
                        OnHotKey(KeyAction.Esc);
                        return;
                    }
                }

                showData(accesoryIsExist, barcode);
            }
            //Если это штрих-код позиции
            else if (barcode.IsValidPositionBarcode())
            {
                Cases cases = accessory as Cases;

                if (cases != null)
                {
                    long map;
                    int  register;
                    int  position;
                    BarcodeWorker.GetPositionData(barcode, out map, out register, out position);

                    cases.Map      = map;
                    cases.Register = register;
                    cases.Position = position;
                    cases.Status   = TypesOfLampsStatus.IsWorking;
                    MainProcess.ClearControls();
                    showData(cases.Id == 0, cases.BarCode);
                }
            }
            //Во всех других случаях
            else
            {
                ShowMessage("Невірний формат штрихкоду!");
                OnHotKey(KeyAction.Esc);
            }
        }
Esempio n. 2
0
        public override void OnBarcode(string Barcode)
        {
            if (Barcode.IsValidBarcode())
            {
                //Тип отсканированого комплектующего
                TypeOfAccessories type = BarcodeWorker.GetTypeOfAccessoriesByBarcode(Barcode);

                switch (type)
                {
                //Лампа - установка/замена лампы
                case TypeOfAccessories.Lamp:
                    MainProcess.ClearControls();
                    MainProcess.Process = new ReplacingAccessory(
                        MainProcess, CaseBarcode, Barcode,
                        Cases.IsCaseHaveAccessory(CaseBarcode, TypeOfAccessories.Lamp),
                        TypeOfAccessories.Lamp);
                    break;

                //Корпус - установка/замена корпуса
                case TypeOfAccessories.Case:
                    MainProcess.ClearControls();
                    MainProcess.Process = new ReplaceLights_SelectNew(MainProcess, Barcode, CaseBarcode);
                    break;

                //Ел.блок - установка/замена блока
                case TypeOfAccessories.ElectronicUnit:
                    MainProcess.ClearControls();
                    MainProcess.Process = new ReplacingAccessory(
                        MainProcess, CaseBarcode, Barcode,
                        Cases.IsCaseHaveAccessory(CaseBarcode, TypeOfAccessories.ElectronicUnit),
                        TypeOfAccessories.ElectronicUnit);
                    break;
                }
            }
        }
Esempio n. 3
0
        /// <summary>Завершення заміни</summary>
        private void finishingReplaceLamps()
        {
            object[] result = null;
            using (
                SqlCeCommand query =
                    dbWorker.NewQuery(
                        @"SELECT Map, Register, Position, Status, SyncRef FROM Cases WHERE RTRIM(BarCode)=RTRIM(@Old)"))
            {
                query.AddParameter("Old", ExistLampBarCode);
                result = query.SelectArray();
            }

            if (result != null)
            {
                int map      = Convert.ToInt32(result[0]);
                int register = Convert.ToInt32(result[1]);
                int position = Convert.ToInt32(result[2]);

                Cases.ChangeLighterState(NewLampBarCode, TypesOfLampsStatus.IsWorking, false, map, register,
                                         position);
                Cases.ChangeLighterState(ExistLampBarCode, TypesOfLampsStatus.Storage, true);

                //Внесение записи в "Перемещение"
                string newLampRef = BarcodeWorker.GetRefByBarcode(typeof(Cases), NewLampBarCode);
                Movement.RegisterLighter(ExistLampBarCode, result[4].ToString(), OperationsWithLighters.Removing,
                                         map, register, position);
                Movement.RegisterLighter(NewLampBarCode, newLampRef, OperationsWithLighters.Installing,
                                         map, register, position);
            }
        }
Esempio n. 4
0
        private void groupRegistrationOnBarcode(string barcode)
        {
            bool barcodeExists = BarcodeWorker.IsBarcodeExist(barcode);

            if (barcodeExists)
            {
                ShowMessage("Даний штрих-код вже використовується");
                return;
            }

            Lamps newLamp = currentLamp.CopyWithoutLinks() as Lamps;

            newLamp.Write();

            ElectronicUnits newElectronicUnit = currentUnit.CopyWithoutLinks() as ElectronicUnits;

            newElectronicUnit.Write();

            Cases newCase = currentCase.CopyWithoutLinks() as Cases;

            newCase.BarCode        = barcode;
            newCase.Lamp           = newLamp.Id;
            newCase.ElectronicUnit = newElectronicUnit.Id;
            newCase.Write();

            Movement.RegisterLighter(newCase.BarCode, newCase.SyncRef, OperationsWithLighters.Registration);

            groupSize++;
        }
Esempio n. 5
0
        public override void OnBarcode(string Barcode)
        {
            if (Barcode.IsValidBarcode())
            {
                TypeOfAccessories type = BarcodeWorker.GetTypeOfAccessoriesByBarcode(Barcode);

                switch (type)
                {
                case TypeOfAccessories.Lamp:
                    MainProcess.ClearControls();
                    MainProcess.Process = new ReplacingAccessory(MainProcess, CaseBarcode, Barcode,
                                                                 Cases.IsCaseHaveAccessory(CaseBarcode, type),
                                                                 TypeOfAccessories.Lamp);
                    break;

                case TypeOfAccessories.Case:
                    break;

                case TypeOfAccessories.ElectronicUnit:
                    MainProcess.ClearControls();
                    MainProcess.Process = new ReplacingAccessory(MainProcess, CaseBarcode, Barcode,
                                                                 Cases.IsCaseHaveAccessory(CaseBarcode, type),
                                                                 TypeOfAccessories.ElectronicUnit);
                    break;
                }
            }
        }
Esempio n. 6
0
        /// <summary>Обновить связанные свойства</summary>
        private void updateDeferredProperties()
        {
            dbObject lastObject = null;

            foreach (DataAboutDeferredProperty propertyData in deferredProperty)
            {
                if (lastObject == null ||
                    lastObject.GetType() != propertyData.AccessoryType ||
                    lastObject.Id != propertyData.Id)
                {
                    lastObject = (dbObject)Activator.CreateInstance(propertyData.AccessoryType);
                    lastObject.Read(propertyData.Id);
                }

                if (lastObject.Id != 0)
                {
                    object idValue = BarcodeWorker.GetIdByRef(
                        propertyData.PropertyType,
                        propertyData.Value.ToString());
                    long id = Convert.ToInt64(idValue);

                    if (!id.Equals(0L))
                    {
                        lastObject.SetValue(propertyData.PropertyName, idValue);
                        lastObject.Sync();
                    }
                }
            }
        }
Esempio n. 7
0
 private void addCaseParameters(SqlCeCommand query, DataRow row)
 {
     query.AddParameter("ElectronicUnit", BarcodeWorker.GetIdByRef(typeof(ElectronicUnits), row["ElectronicUnit"] as string));
     query.AddParameter("Lamp", BarcodeWorker.GetIdByRef(typeof(db.Lamps), row["Lamp"] as string));
     query.AddParameter("Map", CatalogHelper.GetModelId <Maps>(row["Map"]));
     query.AddParameter("Position", Convert.ToInt32(row["Position"]));
     query.AddParameter("Register", Convert.ToInt32(row["Register"]));
 }
Esempio n. 8
0
        /// <summary>Синхронизировать изменения по док "Отправить на .." на ТСД</summary>
        /// <typeparam name="T">Документ</typeparam>
        /// <typeparam name="S">Таблица</typeparam>
        private void SyncInSending <T, S>(SyncModes mode)
            where T : Sending
            where S : SubSending
        {
            string docName   = typeof(T).Name;
            string tableName = typeof(S).Name;

            PerformQuery("GetSendingDocs", docName, tableName, (int)mode);

            if (IsExistParameters)
            {
                DataTable table = ResultParameters[0] as DataTable;

                if (table != null)
                {
                    T newDoc = null;

                    foreach (DataRow row in table.Rows)
                    {
                        int currId = Convert.ToInt32(row["Id"]);

                        if (newDoc == null || newDoc.Id != currId)
                        {
                            newDoc                 = (T)Activator.CreateInstance(typeof(T));
                            newDoc.Contractor      = Convert.ToInt32(row["Contractor"]);
                            newDoc.Date            = Convert.ToDateTime(row["Date"]);
                            newDoc.TypeOfAccessory = (TypeOfAccessories)Convert.ToInt32(row["TypeOfAccessories"]);
                            newDoc.BarCode         = currId.ToString();
                            newDoc.IsSynced        = true;
                            newDoc.Sync <T>();
                        }

                        S newSubDoc = (S)Activator.CreateInstance(typeof(S));
                        newSubDoc.TypeOfAccessory = newDoc.TypeOfAccessory;
                        newSubDoc.Id       = currId;
                        newSubDoc.IsSynced = true;

                        switch (mode)
                        {
                        case SyncModes.StandartToX:
                            newSubDoc.Document = row["Document"].ToString();
                            break;

                        case SyncModes.SendingToExchange:
                            string syncRef = row["Nomenclature"].ToString();
                            object modelId = BarcodeWorker.GetIdByRef(typeof(Models), syncRef);

                            newSubDoc.SetValue("Nomenclature", modelId);
                            break;
                        }

                        newSubDoc.Sync <S>();
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>Синхронизировать документы "Приемка нового компл." с сервера</summary>
        private void SyncAccepmentsDocFromServer()
        {
            DataTable acceptedDoc    = AcceptanceOfNewComponents.GetAcceptedDocuments();
            DataTable notAcceptedDoc = AcceptanceOfNewComponents.GetNotAcceptedDocuments();

            PerformQuery("GetAcceptDocs", acceptedDoc, notAcceptedDoc);

            if (IsExistParameters)
            {
                AcceptanceOfNewComponents.ClearAcceptedDocuments();
                DataTable table = ResultParameters[0] as DataTable;

                if (table != null)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        string contractorBarcode = row["Contractor"].ToString();
                        string partyRef          = row["InvoiceNumber"].ToString();
                        string caseModelRef      = row["CaseModel"].ToString();
                        string lampModelRef      = row["LampModel"].ToString();
                        string unitModelRef      = row["UnitModel"].ToString();
                        object contractorObj     = BarcodeWorker.GetIdByBarcode(typeof(Contractors), contractorBarcode);
                        object partyObj          = BarcodeWorker.GetIdByRef(typeof(Party), partyRef);
                        object caseModelObj      = BarcodeWorker.GetIdByRef(typeof(Models), caseModelRef);
                        object lampModelObj      = BarcodeWorker.GetIdByRef(typeof(Models), lampModelRef);
                        object unitModelObj      = BarcodeWorker.GetIdByRef(typeof(Models), unitModelRef);

                        AcceptanceOfNewComponents doc = new AcceptanceOfNewComponents
                        {
                            Id               = Convert.ToInt64(row["Id"]),
                            Contractor       = Convert.ToInt64(contractorObj),
                            Date             = Convert.ToDateTime(row["Date"]),
                            InvoiceDate      = Convert.ToDateTime(row["InvoiceDate"]),
                            InvoiceNumber    = Convert.ToInt64(partyObj),
                            MarkForDeleting  = false,
                            CaseModel        = Convert.ToInt64(caseModelObj),
                            LampModel        = Convert.ToInt64(lampModelObj),
                            UnitModel        = Convert.ToInt64(unitModelObj),
                            TypesOfWarrantly = (TypesOfLampsWarrantly)
                                               Convert.ToInt32(row["TypesOfWarrantly"]),
                            TypeOfAccessories = (TypeOfAccessories)
                                                Convert.ToInt32(row["TypeOfAccessories"]),
                            WarrantlyHours = Convert.ToInt32(row["WarrantlyHours"]),
                            WarrantlyYears = Convert.ToInt32(row["WarrantlyYears"]),
                            State          = (TypesOfLampsStatus)Convert.ToInt32(row["State"])
                        };
                        doc.Sync <AcceptanceOfNewComponents>();
                    }
                }
            }
        }
Esempio n. 10
0
        private void ok_Click()
        {
            object caseId = BarcodeWorker.GetIdByBarcode(CaseBarcode);
            //Статус корпуса, в который запихиваем новое комплектующее
            TypesOfLampsStatus status = Accessory.GetState(TypeOfAccessories.Case, CaseBarcode.ToString());
            bool   isLamp             = accessoryTable == typeof(db.Lamps).Name;
            object accessoryId        = BarcodeWorker.GetIdByBarcode(NewAccessoryBarcode.ToString());

            string command = string.Format(
                "UPDATE {0} SET Status=@IsWorking,[Case]=@Case,{1}=0,DateOfActuality=@Date{2} WHERE RTRIM(BarCode)=@Barcode",
                accessoryTable,
                dbObject.IS_SYNCED,
                isLamp ? ",Barcode=@NewBarCode" : string.Empty);

            using (SqlCeCommand query = dbWorker.NewQuery(command))
            {
                query.AddParameter("Barcode", NewAccessoryBarcode);
                query.AddParameter("NewBarCode", string.Empty);
                query.AddParameter("Case", caseId);
                query.AddParameter("IsWorking", status);
                query.AddParameter("Date", DateTime.Now);
                query.ExecuteNonQuery();
            }

            using (SqlCeCommand query = dbWorker.NewQuery(string.Format(
                                                              "UPDATE Cases SET {0}=@Id,{1}=0,DateOfActuality=@Date WHERE RTRIM(BarCode)=@Case",
                                                              accessoryField,
                                                              dbObject.IS_SYNCED)))
            {
                query.AddParameter("Case", CaseBarcode);
                query.AddParameter("Id", accessoryId);
                query.AddParameter("Date", DateTime.Now);
                query.ExecuteNonQuery();
            }
            //query = dbWorker.NewQuery(string.Format(
            //    "UPDATE {0} SET Status=@IsWorking,[Case]=@Id,{1}=0,DateOfActuality=@Date WHERE {2}=@Id",
            //    accessoryTable,
            //    dbObject.IS_SYNCED,
            //    dbObject.IDENTIFIER_NAME));
            //query.AddParameter("Id", caseId);
            //query.AddParameter(dbObject.IDENTIFIER_NAME, accessoryId);
            //query.AddParameter("Date", DateTime.Now);
            //query.ExecuteNonQuery();

            //string caseBarcode = CaseBarcode.ToString();
            //installMovement(caseBarcode);
            OnHotKey(KeyAction.Esc);
        }
Esempio n. 11
0
        /// <summary>Отсканировано комплектующее для приемки</summary>
        public override void OnBarcode(string Barcode)
        {
            if (Barcode.IsValidBarcode())
            {
                if (newComponents.ContainsKey(Barcode) || BarcodeWorker.IsBarcodeExist(Barcode))
                {
                    ShowMessage("Данный штрих-код вже існує у системі!");
                }
                else
                {
                    newComponents.Add(Barcode, selectedModelRef);

                    int currCount = Convert.ToInt32(labelOfCount.Text);
                    labelOfCount.Text = (++currCount).ToString();
                }
            }
        }
Esempio n. 12
0
        internal static long GetModelId <T>(object syncRef) where T : CatalogObject
        {
            string strSyncRef = ((syncRef ?? string.Empty) as string).TrimEnd();

            if (string.IsNullOrEmpty(strSyncRef))
            {
                return(0);
            }

            long id;

            SyncRefsDict itemsCache = getItemsCache <T>();

            if (!itemsCache.TryGetValue(strSyncRef, out id))
            {
                id = Convert.ToInt64(BarcodeWorker.GetIdByRef(typeof(T), strSyncRef));
                itemsCache.Add(strSyncRef, id);
            }

            return(id);
        }
Esempio n. 13
0
        /// <summary>Скан штрихкода для Эл.блока/Лампы</summary>
        /// <param name="Barcode">Штрихкод</param>
        public override void OnBarcode(string Barcode)
        {
            if (Barcode.IsValidBarcode())
            {
                //Скан ел.блоків?
                if (stage == Stages.ScanUnitBarcode)
                {
                    TypeOfAccessories accessory = BarcodeWorker.GetTypeOfAccessoriesByBarcode(Barcode);

                    //Чи використовується цей штрихкод?
                    if (accessory == TypeOfAccessories.None)
                    {
                        unitBarcode = Barcode;
                        stage       = Stages.ExtractionElectricUnit;
                        DrawControls();
                    }
                    else
                    {
                        MessageBox.Show("Штрихкод уже используеться!");
                    }
                }
                //Скан ламп?
                else if (stage == Stages.ScanLampBarcode)
                {
                    TypeOfAccessories accessory = BarcodeWorker.GetTypeOfAccessoriesByBarcode(Barcode);

                    //Чи використовується цей штрихкод?
                    if (accessory == TypeOfAccessories.None)
                    {
                        lampBarcode = Barcode;
                        stage       = Stages.ExtractionLamp;
                        DrawControls();
                    }
                    else
                    {
                        MessageBox.Show("Штрихкод уже используеться!");
                    }
                }
            }
        }
Esempio n. 14
0
 public override void OnBarcode(string Barcode)
 {
     if (Barcode.IsValidBarcode())
     {
         if (BarcodeWorker.IsBarcodeExist(Barcode))
         {
             ShowMessage("Штрихкод уже используется!");
         }
         else
         {
             if (stage == Stages.Lamp)
             {
                 lampBarcode = Barcode;
                 goToNextStage();
             }
             else if (stage == Stages.Unit)
             {
                 unitBarcode = Barcode;
                 goToNextStage();
             }
         }
     }
 }
Esempio n. 15
0
        public override void OnBarcode(string barcode)
        {
            if (barcode.Equals(AcceptingAfterFixing.START_ACCEPTING_AFTER_FIXING_BARCODE))
            {
                MainProcess.ClearControls();
                MainProcess.Process = new AcceptingAfterFixing(MainProcess);
            }
            else if (barcode.IsValidPositionBarcode())
            {
                tryPlacingLight(barcode);
            }
            else if (barcode.IsValidBarcode())
            {
                //Тип комплектуючого визначений за штрихкодом (якщо ШК відсутній, то тип = None)
                TypeOfAccessories type = BarcodeWorker.GetTypeOfAccessoriesByBarcode(barcode);

                //Перехід на відповідний процес відповідно до типу комплектуючого
                switch (type)
                {
                case TypeOfAccessories.Lamp:
                    lampProcess(barcode);
                    break;

                case TypeOfAccessories.ElectronicUnit:
                    unitProcess(barcode);
                    break;

                case TypeOfAccessories.Case:
                    caseProcess(barcode);
                    break;

                default:
                    ShowMessage("Не існує комплектуюче з таким штрихкодом!");
                    break;
                }
            }
        }
Esempio n. 16
0
        private void finish(bool isForExchange)
        {
            object[] result = null;
            //Штрихкод установленной лампы
            using (SqlCeCommand query = dbWorker.NewQuery(string.Format(@"
SELECT a.Barcode, a.SyncRef
FROM Cases c
LEFT JOIN {0} a ON a.Id=c.{1}
WHERE RTRIM(c.BarCode)=@BarCode", accessoryTable, accessoryTable.Substring(0, accessoryTable.Length - 1))))
            {
                query.AddParameter("BarCode", CaseBarcode);
                result = query.SelectArray();
            }

            if (result != null && result.Length == 2)
            {
                object oldLampBarcode = result[0];
                object accessoryRef   = result[1];
                object caseId         = BarcodeWorker.GetIdByBarcode(CaseBarcode);
                object newAccessoryId = BarcodeWorker.GetIdByBarcode(NewAccessoryBarcode);
                bool   isLamp         = accessoryTable == typeof(db.Lamps).Name;

                string partOfCommand = string.Format(
                    "UPDATE {0} SET Status=@Status{1},[Case]=@Case,{2}=0,DateOfActuality=@Date{3} WHERE ",
                    accessoryTable,
                    type != TypeOfAccessories.ElectronicUnit
                        ? ", Barcode=@NewBarcode "
                        : string.Empty,
                    dbObject.IS_SYNCED,
                    "{0}");

                //Статус комплектующего, которое меняем
                TypesOfLampsStatus status = Accessory.GetState(TypeOfAccessories.Lamp, oldLampBarcode.ToString());

                //Старое комплектующее
                using (SqlCeCommand query = dbWorker.NewQuery(string.Concat(
                                                                  string.Format(partOfCommand, ",DrawdownDate=@DrawdownDate"),
                                                                  " RTRIM(SyncRef)=RTRIM(@SyncRef)")))
                {
                    query.AddParameter("Status",
                                       isForExchange ? TypesOfLampsStatus.ToRepair : TypesOfLampsStatus.Storage);
                    query.AddParameter("Case", 0);
                    query.AddParameter("LampBarcode", oldLampBarcode);
                    query.AddParameter("NewBarcode", isLamp ? NewAccessoryBarcode : oldLampBarcode);
                    query.AddParameter(dbObject.SYNCREF_NAME, accessoryRef);
                    query.AddParameter("Date", DateTime.Now);
                    query.AddParameter("DrawdownDate", DateTime.Now);
                    query.ExecuteNonQuery();
                }

                //Новое комплектующее
                using (
                    SqlCeCommand query =
                        dbWorker.NewQuery(string.Concat(string.Format(partOfCommand, string.Empty), " Id=@Id")))
                {
                    query.AddParameter("Status", status);
                    query.AddParameter("Case", caseId);
                    query.AddParameter("Id", newAccessoryId);
                    query.AddParameter("NewBarcode", isLamp ? string.Empty : oldLampBarcode);
                    query.AddParameter("Date", DateTime.Now);
                    query.ExecuteNonQuery();
                }

                //Замена комплектующего в светильнике
                using (SqlCeCommand query = dbWorker.NewQuery(string.Format(
                                                                  "UPDATE CASES SET {0}=@NewAccessoryId,{1}=0,DateOfActuality=@Date WHERE RTRIM(BarCode)=RTRIM(@CaseBarcode)",
                                                                  accessoryField,
                                                                  dbObject.IS_SYNCED)))
                {
                    query.AddParameter("CaseBarcode", CaseBarcode);
                    query.AddParameter("NewAccessoryId", newAccessoryId);
                    query.AddParameter("Date", DateTime.Now);
                    query.ExecuteNonQuery();
                }
                //Завершение
                //string caseBarcode = CaseBarcode.ToString();
                //installMovement(caseBarcode);
                //removeMovement(oldLampBarcode.ToString(), caseBarcode);
                OnHotKey(KeyAction.Esc);
            }
        }
Esempio n. 17
0
        /// <summary>Создание объектов синхронизации</summary>
        /// <param name="table">Данные о объектах</param>
        /// <param name="skipExists">Пропустить существующие</param>
        /// <param name="deferredProperty">Список отложеных свойств</param>
        /// <param name="updId">Нужно обновить ID</param>
        private static void CreateSyncObject <T>(CatalogSynchronizer synchronizer, DataTable table, bool skipExists, ref List <DataAboutDeferredProperty> deferredProperty, bool updId) where T : dbObject
        {
            if (synchronizer != null)
            {
                int rowsCount = table.Rows.Count;
                for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++)
                {
                    DataRow row = table.Rows[rowIndex];
                    synchronizer.Merge(row);

                    //if (rowIndex % 10 == 0)
                    {
                        Trace.WriteLine(string.Format("{1} %, rowIndex = {0} from {2}", rowIndex, (int)(100 * rowIndex / rowsCount), rowsCount));
                    }

                    //if (rowIndex % 500 == 0)
                    //    {
                    //    GC.Collect();
                    //    GC.WaitForPendingFinalizers();
                    //    }
                }
                return;
            }

            Type type = typeof(T);

            PropertyInfo[] properties        = type.GetProperties();
            string         syncRef           = string.Empty;
            string         syncRefName       = dbObject.SYNCREF_NAME.ToLower();
            int            lastDeferredIndex = deferredProperty.Count;

            foreach (DataRow row in table.Rows)
            {
                object newObj       = Activator.CreateInstance(typeof(T));
                T      newObject    = (T)newObj;
                bool   needDeferred = false;

                foreach (PropertyInfo property in properties)
                {
                    dbFieldAtt attribute = Attribute.GetCustomAttribute(property, typeof(dbFieldAtt)) as dbFieldAtt;

                    if (attribute != null && table.Columns.Contains(property.Name))
                    {
                        object value = row[property.Name];

                        //Не существует ли елемент с такой ссылкой?
                        if (property.Name.ToLower().Equals(syncRefName))
                        {
                            if (BarcodeWorker.IsRefExist(type, value.ToString()))
                            {
                                if (skipExists)
                                {
                                    break;
                                }

                                newObject.SetNotNew();
                            }

                            syncRef = value.ToString();
                        }
                        else if (updId && property.Name.ToLower().Equals(dbObject.IDENTIFIER_NAME))
                        {
                            continue;
                        }

                        if (property.PropertyType == typeof(int))
                        {
                            value = string.IsNullOrEmpty(value.ToString()) ? 0 : Convert.ToInt32(value);
                        }
                        else if (property.PropertyType == typeof(double))
                        {
                            value = string.IsNullOrEmpty(value.ToString()) ? 0D : Convert.ToDouble(value);
                        }
                        else if (property.PropertyType == typeof(long))
                        {
                            if (attribute.dbObjectType == null)
                            {
                                value = string.IsNullOrEmpty(value.ToString()) ? 0L : Convert.ToInt64(value);
                            }
                            else
                            {
                                if (value != null && !string.IsNullOrEmpty(value.ToString()))
                                {
                                    DataAboutDeferredProperty data = new DataAboutDeferredProperty(type, attribute.dbObjectType, property.Name, value);
                                    deferredProperty.Add(data);
                                    needDeferred = true;
                                }

                                value = 0L;
                            }
                        }
                        else if (property.PropertyType == typeof(bool))
                        {
                            value = Convert.ToBoolean(value);
                        }
                        else if (property.PropertyType == typeof(DateTime))
                        {
                            value = StringParser.ParseDateTime(value);
                        }
                        else if (property.PropertyType.IsEnum)
                        {
                            value = Enum.Parse(property.PropertyType, value.ToString(), false);
                        }
                        else if (property.PropertyType == typeof(string))
                        {
                            string fullValue = value.ToString();
                            value = value.ToString();

                            if (property.Name != CatalogObject.DESCRIPTION)
                            {
                                int length = attribute.StrLength == 0
                                                 ? dbFieldAtt.DEFAULT_STR_LENGTH
                                                 : attribute.StrLength;

                                if (fullValue.Length > length)
                                {
                                    value = fullValue.Substring(0, length);
                                }
                            }
                        }

                        property.SetValue(newObject, value, null);
                    }
                }

                ISynced syncObject = newObject as ISynced;

                if (syncObject != null)
                {
                    syncObject.IsSynced = true;
                }

                if (updId && !skipExists && !string.IsNullOrEmpty(syncRef))
                {
                    newObject.Id = Convert.ToInt64(BarcodeWorker.GetIdByRef(type, syncRef));
                }

                CatalogObject catalog = newObject as CatalogObject;

                if (catalog != null)
                {
                    dbElementAtt attribute = Attribute.GetCustomAttribute(newObject.GetType(), typeof(dbElementAtt)) as dbElementAtt;
                    int          length    = attribute == null || attribute.DescriptionLength == 0
                                     ? dbElementAtt.DEFAULT_DES_LENGTH
                                     : attribute.DescriptionLength;

                    if (catalog.Description.Length > length)
                    {
                        catalog.Description = catalog.Description.Substring(0, length);
                    }
                }

                newObject.Sync <T>(updId);

                if (needDeferred)
                {
                    for (int i = lastDeferredIndex; i < deferredProperty.Count; i++)
                    {
                        deferredProperty[i].Id = newObject.Id;
                    }

                    lastDeferredIndex = deferredProperty.Count;
                }
            }
        }