private void FillFormData() { using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString)) { LinqQueryForTrudoyomkost.FillInfProductsList(currentContext, ref FillTrudoyomkostDB.infProductList); LinqQueryForTrudoyomkost.FillLabourNormList(currentContext, ref FillTrudoyomkostDB.LabourNormList); LinqQueryForTrudoyomkost.FillWhereOperationUseList(currentContext, ref FillTrudoyomkostDB.WhereOperationUseList); _whereUseList = LinqQueryForTrudoyomkost.FillWhereUselst(currentContext); _depList = LinqQueryForTrudoyomkost.FillinfDeplst(currentContext); _infDetList = LinqQueryForTrudoyomkost.FillinfDetList(currentContext); FillTrudoyomkostDB.whereUseList = _whereUseList; FillTrudoyomkostDB.infDetList = _infDetList; LinqQueryForTrudoyomkost.FilldcInfProducts(currentContext, ref FillTrudoyomkostDB.DcInfProducts); _infProductsDc = FillTrudoyomkostDB.DcInfProducts; LinqQueryForTrudoyomkost.FilldcDetNumForProduct(ref dcIDDetNum, _infProductsDc.Values.First()); LinqQueryForTrudoyomkost.FilldtInfProf(currentContext, ref _dtInfProf); LinqQueryForTrudoyomkost.GetInfTariffList(currentContext, ref FillTrudoyomkostDB.tariffList); LinqQueryForTrudoyomkost.FillDictDepIDCode(currentContext, ref FillTrudoyomkostDB.DicDepCodeAndId); _detNumList.Clear(); foreach (var item in dcIDDetNum) { _detNumList.Add(item.Key); } }// }
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(); }
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(); }