Ejemplo n.º 1
0
        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);
                }
            }//
        }
Ejemplo n.º 2
0
        public void AddDoubleItems()
        {
            this.Enabled = false;



            var labourNormlist = LinqQueryForTrudoyomkost.FillLabournNormForDet(_destinationDetID);

            foreach (var item in labourNormlist)
            {
                var whereOperUselstdel = LinqQueryForTrudoyomkost.FillWhereOperationUseList(item.ID);

                if (whereOperUselstdel.Count() > 0)
                {
                    foreach (var applydel in whereOperUselstdel)
                    {
                        FillTrudoyomkostDB.WhereOperationUseList.Remove(applydel);
                    }
                }

                FillTrudoyomkostDB.LabourNormTableAdapter.DeleteQuery(item.ID);
                FillTrudoyomkostDB.WhereOperationUseTableAdapter.DeleteQuery(item.ID);
                FillTrudoyomkostDB.LabourNormList.Remove(item);
            }

            labourNormlist = LinqQueryForTrudoyomkost.FillLabournNormForDet(_sourceDetID);


            using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                int Id             = 0;
                int whereOperUseId = FillTrudoyomkostDB.WhereOperationUseList.Last().Id;
                Id = currentContext.LabourNorm.ToList().Max().ID;
                foreach (var item in labourNormlist)
                {
                    var whereOperUselst = LinqQueryForTrudoyomkost.FillWhereOperationUseList(item.ID);
                    if (whereOperUselst.Count() > 0)
                    {
                        Id++;
                        //FillTrudoyomkostDB.LabourNormTableAdapter.InsertQuery(_destinationDetID, item.OperNum, item.DepRegion, item.ProfCode, item.NameKindWork,
                        // item.TariffNetNum, item.KindPay, item.WorkerRate, item.ItemCTN, item.PreparTimeCTN,
                        //item.ItemPayNorm, item.PreparTimePayNorm, item.Valuation, item.ValPreparTime, item.CoeffCTN, item.DocNum, item.Date, item.TaskNumber);

                        FillTrudoyomkostDB.FilltmpLabourNormRow(new LabourNorm(Id, _destinationDetID, item.OperNum, item.DepRegion, item.ProfCode,
                                                                               item.NameKindWork, item.TariffNetNum, item.KindPay, item.WorkerRate, item.ItemCTN, item.PreparTimeCTN, item.ItemPayNorm, item.PreparTimePayNorm,
                                                                               item.Valuation, item.ValPreparTime, item.CoeffCTN, item.DocNum, DateTime.Now, item.TaskNumber));

                        FillTrudoyomkostDB.LabourNormList.Add(new LabourNorm(Id, _destinationDetID, item.OperNum, item.DepRegion, item.ProfCode,
                                                                             item.NameKindWork, item.TariffNetNum, item.KindPay, item.WorkerRate, item.ItemCTN, item.PreparTimeCTN, item.ItemPayNorm, item.PreparTimePayNorm,
                                                                             item.Valuation, item.ValPreparTime, item.CoeffCTN, item.DocNum, DateTime.Now, item.TaskNumber));


                        //currentContext.LabourNorm.InsertOnSubmit(new LabourNorm(Id, _destinationDetID, item.OperNum, item.DepRegion, item.ProfCode,
                        //  item.NameKindWork, item.TariffNetNum, item.KindPay, item.WorkerRate, item.ItemCTN, item.PreparTimeCTN, item.ItemPayNorm, item.PreparTimePayNorm,
                        //  item.Valuation, item.ValPreparTime, item.CoeffCTN, item.DocNum, DateTime.Now, item.TaskNumber));



                        foreach (var applyItem in whereOperUselst)
                        {
                            whereOperUseId++;

                            FillTrudoyomkostDB.FilltmpWhereOperUseRow(new WhereOperationUse(Id, applyItem.SeriaFrom, applyItem.SeriaTo, applyItem.InfProductsChipher));
                            FillTrudoyomkostDB.WhereOperationUseList.Add(new WhereOperationUse(Id, applyItem.SeriaFrom, applyItem.SeriaTo, applyItem.InfProductsChipher, whereOperUseId));
                            //currentContext.WhereOperationUse.InsertOnSubmit(new WhereOperationUse(Id, applyItem.SeriaFrom, applyItem.SeriaTo, applyItem.InfProductsChipher,whereOperUseId));

                            //FillTrudoyomkostDB.WhereOperationUseTableAdapter.InsertQuery(Id, applyItem.SeriaFrom, applyItem.SeriaTo, applyItem.InfProductsChipher);
                        }
                    }
                    //currentContext.SubmitChanges();
                }
                DataTable tmpWhereOperUse = FillTrudoyomkostDB.WhereOperationUseDataTable;
                DataTable tmpLabourNorm   = FillTrudoyomkostDB.LabourNormDataTable;

                SqlCeBulkCopy bulkInsert = new SqlCeBulkCopy(Properties.Settings.Default.TrudoyomkostDBConnectionString);
                if (tmpWhereOperUse.Rows.Count > 0)
                {
                    bulkInsert.DestinationTableName = "whereOperationUse";
                    bulkInsert.WriteToServer(tmpWhereOperUse);
                }
                if (tmpLabourNorm.Rows.Count > 0)
                {
                    bulkInsert.DestinationTableName = "LabourNorm";
                    bulkInsert.WriteToServer(tmpLabourNorm);
                }
                FillTrudoyomkostDB.LabourNormDataTable.Clear();
                FillTrudoyomkostDB.WhereOperationUseDataTable.Clear();
                bulkInsert.Close();
            }

            this.Enabled = true;
        }