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
 private void tabProducts_Enter(object sender, EventArgs e)
 {
     using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
     {
         dgProducts.DataSource          = LinqQueryForTrudoyomkost.GetAllProducts(currentContext);
         dgProducts.Columns[0].ReadOnly = true;
     }
 }
Ejemplo n.º 3
0
 public void execute()
 {
     using (var currentContex = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
     {
         FillTrudoyomkostDB.WhereOperationUseList.Add(_whereOperUse);
         currentContex.WhereOperationUse.InsertOnSubmit(_whereOperUse);
         currentContex.SubmitChanges();
     }
 }
Ejemplo n.º 4
0
 public fmAuthentication(mainForm fm)
 {
     this.fm = fm;
     InitializeComponent();
     //tbLogin.Text = "admin";
     //tbPass.Text = "admin";
     using (var newLocalDb = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
     {
         _usersList = LinqQueryForTrudoyomkost.FillUsersList(newLocalDb);
     }
 }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 private void btDelProf_Click(object sender, EventArgs e)
 {
     if (
         MessageBox.Show("Вы уверены, что хотите удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         FillTrudoyomkostDB.InfProfessionTableAdapter.DeleteRow(_currentProfCode);
         using (
             var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
         {
             LinqQueryForTrudoyomkost.FilldtInfProf(currentContext, ref _dtInfProf);
         }
     }
 }
Ejemplo n.º 7
0
        public void execute()
        {
            var result = from currLabItem in FillTrudoyomkostDB.CurrentLabourNormList
                         join whOper in FillTrudoyomkostDB.WhereOperationUseList
                         on currLabItem.ID equals whOper.LabourNormID

                         select new
            {
                LabourId = currLabItem.ID,
                whOper.Id,
                whOper.InfProductsChipher,
                whOper.SeriaFrom,
                whOper.SeriaTo,
            } into res
            group res by res.LabourId
            into groupResult
                select new
            {
                Key   = groupResult.Key,
                Value = groupResult
            };

            using (var currentContex = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                foreach (var item in result)
                {
                    if (item.Value.Count() < 2)
                    {
                        var tempEl = item.Value.First();
                        if (tempEl.SeriaFrom >= _seriaFrom && tempEl.InfProductsChipher == _productCipher)
                        {
                            var el       = currentContex.WhereOperationUse.First(x => x.Id == tempEl.Id);
                            var memoryEl = FillTrudoyomkostDB.WhereOperationUseList.First(x => x.Id == tempEl.Id);

                            bool Visible = FillTrudoyomkostDB.WhereOperationUseList.Remove(memoryEl);
                            currentContex.WhereOperationUse.DeleteOnSubmit(el);
                        }
                        else if (tempEl.SeriaFrom < _seriaFrom && tempEl.SeriaTo >= _seriaFrom && tempEl.InfProductsChipher == _productCipher)
                        {
                            var el = currentContex.WhereOperationUse.First(x => x.Id == tempEl.Id);
                            el.SeriaTo = _seriaFrom - 1;
                            FillTrudoyomkostDB.WhereOperationUseList.First(x => x.Id == tempEl.Id).SeriaTo = _seriaFrom - 1;
                        }
                        currentContex.SubmitChanges();
                    }
                }
            }
        }
Ejemplo n.º 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
     {
         foreach (var item in currentContext.LabourNorm)
         {
             if (item.ItemCTN == 0 && item.PreparTimeCTN == 0 && item.ItemPayNorm == 0 && item.PreparTimePayNorm == 0)
             {
                 currentContext.LabourNorm.DeleteOnSubmit(item);
             }
             if (item.KindPay == "C")
             {
                 item.KindPay = "C";
             }
             currentContext.SubmitChanges();
         }
     }
 }
Ejemplo n.º 9
0
        private void dgProducts_RowValidated(object sender, DataGridViewCellEventArgs e)
        {
            short        cipher = 0;
            DataGridView tempDg;

            tempDg = sender as DataGridView;
            if (tempDg != null)
            {
                cipher = (short)tempDg.Rows[e.RowIndex].Cells[0].Value;
            }

            //tempDg.Rows[e.RowIndex].
            using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                var selectEntity = currentContext.InfProducts.Where(item => item.Cipher == cipher).First();

                selectEntity.Product      = tempDg.Rows[e.RowIndex].Cells[1].Value.ToString();
                selectEntity.Mask         = (byte)tempDg.Rows[e.RowIndex].Cells[3].Value;
                selectEntity.ProductTotal = tempDg.Rows[e.RowIndex].Cells[2].Value.ToString();
                currentContext.SubmitChanges();
            }
        }
Ejemplo n.º 10
0
 private void btProfAdd_Click_1(object sender, EventArgs e)
 {
     foreach (DataRow row in _dtInfProf.Rows)
     {
         if ((int)row[0] == int.Parse(vtbProfCode.ValueTxt))
         {
             return;
         }
     }
     if (checkValidateProfRow(gpEditProff))
     {
         using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
         {
             FillTrudoyomkostDB.InfProfessionTableAdapter.InsertQuery(int.Parse(vtbProfCode.ValueTxt),
                                                                      tbProfName.Text, tbProfKindWork.Text, 1049);
             LinqQueryForTrudoyomkost.FilldtInfProf(currentContext, ref _dtInfProf);
         }
         errorProv.SetError(gpEditProff, String.Empty);
     }
     else
     {
         errorProv.SetError(gpEditProff, "Заполните поля");
     }
 }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
0
        private void InitializeFormElement()
        {
            this.Location = new Point(_parentForm.Location.X, _parentForm.Location.Y);


            vtbOperNum.ValidateValue  = VtboxMethods.checkForNonEmpty;
            vtbTaskNum.ValidateValue  = VtboxMethods.checkForNonEmpty;
            vtbWorkRate.ValidateValue = VtboxMethods.checkWorkRate;
            vtbWorkRate.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;

            vtbItemCTN.ValidateValue = VtboxMethods.checkForDouble;
            vtbItemCTN.StringAutoCorrectionMethod       = VtboxMethods.correctForDouble;
            vtbPreparTimeCTN.ValidateValue              = VtboxMethods.checkForDouble;
            vtbPreparTimeCTN.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;
            vtbCoeffCTN.ValidateValue = VtboxMethods.checkForDouble;
            vtbCoeffCTN.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;

            vtbItemPayNorm.ValidateValue = VtboxMethods.checkForDouble;
            vtbItemPayNorm.StringAutoCorrectionMethod       = VtboxMethods.correctForDouble;
            vtbPreparTimePayNorm.ValidateValue              = VtboxMethods.checkForDouble;
            vtbPreparTimePayNorm.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;

            vtbLoverCoeff.ValidateValue = VtboxMethods.checkForDouble;
            vtbLoverCoeff.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;
            vtbDepRegion.ValidateValue = VtboxMethods.checkForDouble;
            vtbPreparTimePayNorm.StringAutoCorrectionMethod = VtboxMethods.correctForDouble;


            vtbSeriaFrom.StringAutoCorrectionMethod = VtboxMethods.correctForInt;
            vtbSeriaFrom.ValidateValue            = VtboxMethods.CheckSeria;
            vtbSeriaTo.StringAutoCorrectionMethod = VtboxMethods.correctForInt;
            vtbSeriaTo.ValidateValue  = VtboxMethods.CheckSeria;
            vtbProdName.ValidateValue = VtboxMethods.CheckProdNume;
            vtbProdName.StringAutoCorrectionMethod = VtboxMethods.correctForInt;

            using (var newLocalDb = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                LinqQueryForTrudoyomkost.FilldcInfProfession(newLocalDb, ref _dcShortInfProf, ref vcbProfCode);
                LinqQueryForTrudoyomkost.FilldcInfTariffInfo(newLocalDb, ref _dcInfTariffInfo);
            }
            vcbProfCode.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            vcbProfCode.AutoCompleteSource = AutoCompleteSource.ListItems;
            _autoComSourceForDocNum        = LinqQueryForTrudoyomkost.FillDocNumlst();
            foreach (var item in _autoComSourceForDocNum)
            {
                cbDocNum.Items.Add(item);
            }

            cbDocNum.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            cbDocNum.AutoCompleteSource       = AutoCompleteSource.ListItems;
            cbDocNum.AutoCompleteCustomSource = _autoComSourceForDocNum;

            dgOperApply.Columns[1].Width = 120;
            dgOperApply.Columns[2].Width = 120;
            vtbSeriaTo.ValueTxt          = " ";
            vtbLoverCoeff.ValueTxt       = "1";
            vtbCoeffCTN.ValueTxt         = "0";
            if (TrudoyomkostSettings.IsAggregateDep)
            {
                vtbTaskNum.Enabled = true;
            }
        }