Beispiel #1
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();
                  }
              }
            }
        }
Beispiel #2
0
 public void execute()
 {
     using (var currentContex = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
     {
         FillTrudoyomkostDB.WhereOperationUseList.Add(_whereOperUse);
         currentContex.WhereOperationUse.InsertOnSubmit(_whereOperUse);
         currentContex.SubmitChanges();
     }
 }
Beispiel #3
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();
                }
            }
        }
Beispiel #4
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();
            }
        }
        private void btSaveAndLimit_Click(object sender, EventArgs e)
        {
            CheckValidateForm(gbOperItems);
            if (!IsValidForm)
            {
                MessageBox.Show(_isValidateGbNotific);
                IsValidForm = true;
                return;
            }
            using (var currentContext = new TrudoyomkostDBContext(Properties.Settings.Default.TrudoyomkostDBConnectionString))
            {
                foreach (var item in _oldAndNewApplyDict)
                {
                    WhereOperationUse tempItem = new WhereOperationUse();
                    tempItem = FillTrudoyomkostDB.WhereOperationUseList.ToList().Find(currItem => (currItem.SeriaFrom == item.Key.SeriaFrom && currItem.SeriaTo == item.Key.SeriaTo && currItem.InfProductsChipher == item.Key.ProductChipher && currItem.LabourNormID == templabour.ID));
                    tempItem.SeriaTo = item.Value.SeriaFrom - 1;
                    FillTrudoyomkostDB.WhereOperationUseTableAdapter.UpdateSeriaTo(tempItem.SeriaTo, item.Key.ProductChipher, item.Key.SeriaFrom, templabour.ID);

                    FillTrudoyomkostDB.WhereOperationUseList.Add(item.Value);
                    currentContext.WhereOperationUse.InsertOnSubmit(item.Value);
                    currentContext.SubmitChanges();
                }

                templabour.ID = _newID;

                btSaveAndLimit.Enabled = false;
                UpdateLabourNorm(ref templabour, _timeInHour);

                FillTrudoyomkostDB.LabourNormTableAdapter.InsertQuery(templabour.InfDetID, templabour.OperNum, templabour.DepRegion, templabour.ProfCode, templabour.NameKindWork,
                    templabour.TariffNetNum, templabour.KindPay, templabour.WorkerRate, templabour.ItemCTN, templabour.PreparTimeCTN,
                    templabour.ItemPayNorm, templabour.PreparTimePayNorm, templabour.Valuation, templabour.ValPreparTime, templabour.CoeffCTN, templabour.DocNum, templabour.Date, templabour.TaskNumber);

                FillTrudoyomkostDB.LabourNormList.Add(templabour);
                templabour = new LabourNorm();

            }

            _parentForm.UpdateDataGrids();
            _newID++;
            btSaveAndLimit.Enabled = true;
        }