Exemplo n.º 1
0
        public static void InsertFromANTables(DataSet tableList)
        {
            using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                LinqQueryForTrudoyomkost.FilldcInfProducts(currentContext, ref DcInfProducts);
                LinqQueryForTrudoyomkost.FillDictDetNumID(currentContext, ref DicDetNumAndId);
                LinqQueryForTrudoyomkost.FillDictDepIDCode(currentContext, ref DicDepCodeAndId);

                Properties.Settings.Default.DetID = currentContext.InfDet.ToList().Count == 0 ? 0 : ++currentContext.InfDet.ToList().Last().ID;
            }

            if (int.Parse((tableList.Tables[0].Rows[0].Field <string>("CEH").Trim())) != Properties.Settings.Default.DepNum)
            {
                return;
            }

            _whereUseTableAdapter.DeleteAllQuery();
            foreach (DataTable itemTable in tableList.Tables)
            {
                foreach (DataRow itemRow in itemTable.Rows)
                {
                    string NDET = (string)itemRow["NDET"];
                    if (!DicDetNumAndId.ContainsKey(NDET))
                    {
                        var infDetItem = FillItemInfDet(itemRow);
                        FilltmpInfDetRow(ref infDetItem);

                        DicDetNumAndId.Add(NDET, Properties.Settings.Default.DetID);
                        Properties.Settings.Default.DetID++;
                    }
                    var itemWhereuse = FillItemWhereUse(itemRow);
                    FilltmpWhereUseRow(itemWhereuse);
                }
            }
            Properties.Settings.Default.Save();
            SqlCeBulkCopy bulkInsert    = new SqlCeBulkCopy(connString);
            DataTable     tmptbInfDet   = InfDetDataTable;
            DataTable     tmptbWhereUse = WhereUseDataTable;

            if (tmptbInfDet.Rows.Count > 0)
            {
                bulkInsert.DestinationTableName = "infDet";
                bulkInsert.WriteToServer(tmptbInfDet);
            }
            if (tmptbWhereUse.Rows.Count > 0)
            {
                bulkInsert.DestinationTableName = "whereUse";
                bulkInsert.WriteToServer(tmptbWhereUse);
            }

            WhereUseDataTable.Clear();
            InfDetDataTable.Clear();
            bulkInsert.Close();
        }
Exemplo n.º 2
0
        public static void InsertFromTNTables()
        {
            InfDetDataTable.Clear();
            using (var newLocalDb = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                LinqQueryForTrudoyomkost.FillDictDetNumID(newLocalDb, ref DicDetNumAndId);
                LinqQueryForTrudoyomkost.FillDictDepIDCode(newLocalDb, ref DicDepCodeAndId);
                LinqQueryForTrudoyomkost.FillDictInfProfession(newLocalDb, ref DictInfProfession);
            }


            int whereOperUseId = 1;

            foreach (var item in Tn148DataTable)
            {
                if (DicDetNumAndId.ContainsKey(item.NDET))
                {
                    LabourNorm itemlabourNorm = FillItemLabourNorm(item);
                    itemlabourNorm.ID = whereOperUseId;
                    FilltmpLabourNormRow(itemlabourNorm);

                    WhereOperationUse itemWhereOperUse = FillItemWhereOperationUse(item);
                    itemWhereOperUse.LabourNormID = whereOperUseId;
                    FilltmpWhereOperUseRow(itemWhereOperUse);

                    ListAllLabourNorm.Add(item.NDET);
                    whereOperUseId++;
                }
            }

            using (var newLocalDb = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                LinqQueryForTrudoyomkost.FillDictDetNumID(newLocalDb, ref DicDetNumAndId);
            }
            DicCheckRepeatTN.Clear();
            foreach (var item in Tn158DataTable)
            {
                if (DicDetNumAndId.ContainsKey(item.NDET))
                {
                    LabourNorm itemlabourNorm = FillItemLabourNorm(item);
                    itemlabourNorm.ID = whereOperUseId;
                    FilltmpLabourNormRow(itemlabourNorm);

                    WhereOperationUse itemWhereOperUse = FillItemWhereOperationUse(item);
                    itemWhereOperUse.LabourNormID = whereOperUseId;
                    FilltmpWhereOperUseRow(itemWhereOperUse);

                    ListAllLabourNorm.Add(item.NDET);
                    whereOperUseId++;
                }
            }
            Properties.Settings.Default.Save();
            SqlCeBulkCopy bulkInsert      = new SqlCeBulkCopy(connString);
            DataTable     tmptbLabourNorm = LabourNormDataTable;
            DataTable     tmpWhereOperUse = WhereOperationUseDataTable;

            if (tmptbLabourNorm.Rows.Count > 0)
            {
                bulkInsert.DestinationTableName = "LabourNorm";
                bulkInsert.WriteToServer(tmptbLabourNorm);
            }
            if (tmpWhereOperUse.Rows.Count > 0)
            {
                bulkInsert.DestinationTableName = "whereOperationUse";
                bulkInsert.WriteToServer(tmpWhereOperUse);
            }
            LabourNormDataTable.Clear();
            WhereOperationUseDataTable.Clear();
            bulkInsert.Close();
        }