コード例 #1
0
        private void lstReparti_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstReparti.SelectedIndex == -1)
            {
                return;
            }
            RepartoModel     repartoSelezionato     = (RepartoModel)lstReparti.SelectedItem;
            List <FaseModel> fasiRepartoSelezionato = _anagrafica.CreaListaFaseModel(repartoSelezionato.IdReparto);

            lstFasi.Items.Clear();
            lstFasi.Items.AddRange(fasiRepartoSelezionato.ToArray());
        }
コード例 #2
0
        private void dgvElementi_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                _disabilitaEdit = true;
                if (e.RowIndex > -1)
                {
                    decimal idElementoCosto = (decimal)dgvElementi.Rows[e.RowIndex].Cells[IdElementoCosto.Index].Value;
                    ElementoCostoPreventivoModel elementoCosto = _elementiCostoPreventivo.Where(x => x.IdElementoCosto == idElementoCosto).FirstOrDefault();
                    if (elementoCosto == null)
                    {
                        return;
                    }

                    RepartoModel reparto = elementoCosto.ElementoPreventivo.Reparto;
                    if (reparto == null || reparto.Codice == Reparti.Galvanica)
                    {
                        return;
                    }
                    if (e.ColumnIndex == PezziOrari.Index || e.ColumnIndex == Costo.Index || e.ColumnIndex == Ricarico.Index)
                    {
                        decimal margine       = (decimal)dgvElementi.Rows[e.RowIndex].Cells[Ricarico.Index].Value;
                        decimal costoOrario   = (decimal)dgvElementi.Rows[e.RowIndex].Cells[Costo.Index].Value;
                        decimal pezziOrari    = (decimal)dgvElementi.Rows[e.RowIndex].Cells[PezziOrari.Index].Value;
                        decimal costoPezzo    = pezziOrari == 0 ? 0 : costoOrario / pezziOrari;
                        decimal costoArticolo = (1 + margine / 100) * costoPezzo;
                        dgvElementi.Rows[e.RowIndex].Cells[colCostoArticolo.Index].Value = costoArticolo;

                        MPIntranet.Business.Articolo.RicalcolaCostoFigliListaElementiCostoPreventiviModel(_elementiCostoPreventivo);

                        RefreshGridViewElementi();
                    }

                    List <ElementoCostoPreventivoModel> radici = _elementiCostoPreventivo.Where(x => x.ElementoPreventivo.IdPadre == -1).ToList();
                    if (radici.Count == 1)
                    {
                        ElementoCostoPreventivoModel prodottofinito = radici[0];
                        txtCostoProdottoFinito.Text = prodottofinito.CostoCompleto.ToString();
                    }
                }
            }
            finally
            {
                _disabilitaEdit = false;
            }
        }
コード例 #3
0
        private void dgvElementi_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            if (dgvElementi.Rows[e.RowIndex].Cells[IdElementoCosto.Index].Value == null)
            {
                return;
            }

            decimal idElementoCosto = (decimal)dgvElementi.Rows[e.RowIndex].Cells[IdElementoCosto.Index].Value;
            ElementoCostoPreventivoModel elementoCosto = _elementiCostoPreventivo.Where(x => x.IdElementoCosto == idElementoCosto).FirstOrDefault();

            if (elementoCosto == null)
            {
                return;
            }

            dgvElementi.Rows[e.RowIndex].Cells[Articolo.Index].Value    = elementoCosto.ElementoPreventivo.Articolo;
            dgvElementi.Rows[e.RowIndex].Cells[Codice.Index].Value      = elementoCosto.ElementoPreventivo.Codice;
            dgvElementi.Rows[e.RowIndex].Cells[Descrizione.Index].Value = elementoCosto.ElementoPreventivo.Descrizione;

            dgvElementi.Rows[e.RowIndex].Cells[Processo.Index].Value   = elementoCosto.ElementoPreventivo.Processo;
            dgvElementi.Rows[e.RowIndex].Cells[Peso.Index].Value       = elementoCosto.ElementoPreventivo.Peso;
            dgvElementi.Rows[e.RowIndex].Cells[Superficie.Index].Value = elementoCosto.ElementoPreventivo.Superficie;
            dgvElementi.Rows[e.RowIndex].Cells[Quantita.Index].Value   = elementoCosto.ElementoPreventivo.Quantita;

            RepartoModel reparto = elementoCosto.ElementoPreventivo.Reparto;

            dgvElementi.Rows[e.RowIndex].Cells[Reparto.Index].Value = elementoCosto.ElementoPreventivo.Reparto;

            //if (reparto == null) return;
            //if (reparto.Codice == Reparti.Galvanica)
            //{
            //    dgvElementi.Rows[e.RowIndex].Cells[11].ReadOnly = true;
            //    dgvElementi.Rows[e.RowIndex].Cells[12].ReadOnly = true;
            //    dgvElementi.Rows[e.RowIndex].Cells[13].ReadOnly = true;

            //}

            //if (reparto == null) return;
            //GruppoRepartoModel grm = _gruppiRepartiModel.Where(x => x.Reparto.IdReparto == reparto.IdReparto).FirstOrDefault();
            //if (grm == null) return;
            //dgvElementi.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromName(grm.Gruppo.Colore);
            //dgvElementi.Rows[e.RowIndex].Cells[6].Value = grm.Gruppo.Codice;
        }
コード例 #4
0
        private void caricaGrigliaElementiPreventivo()
        {
            dgvElementi.AutoGenerateColumns = false;

            _source.DataSource     = _elementiPreventivo;
            dgvElementi.DataSource = _source;

            foreach (DataGridViewRow riga in dgvElementi.Rows)
            {
                if (riga.Cells["Reparto"].Value != null)
                {
                    RepartoModel reparto = (RepartoModel)riga.Cells["Reparto"].Value;

                    if (reparto.Codice == Reparti.Galvanica)
                    {
                        DataGridViewComboBoxCell cella = (DataGridViewComboBoxCell)riga.Cells["Processo"];
                        cella.Items.Clear();
                        cella.Items.AddRange(_processiGalvanici.Select(x => x.Descrizione).ToArray());
                    }
                }
            }
        }
コード例 #5
0
        private void btnAssocia_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvRepartiGruppi.SelectedRows.Count == 0)
                {
                    MessageBox.Show("Selezionare i reparti a cui si vuole associare il gruppo", "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (dgvGruppi.SelectedRows.Count == 0)
                {
                    MessageBox.Show("Selezionare il gruppo che si vuole associare ai reparti", "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                decimal idGruppo = (decimal)dgvGruppi.SelectedRows[0].Cells[0].Value;

                foreach (DataGridViewRow row in dgvRepartiGruppi.SelectedRows)
                {
                    decimal      idGruppoReparto = (decimal)row.Cells[0].Value;
                    RepartoModel reparto         = (RepartoModel)row.Cells[1].Value;
                    if (idGruppoReparto == -1)
                    {
                        _articolo.CreaGruppoReparto(reparto.IdReparto, idGruppo, _utenteConnesso);
                    }
                    else
                    {
                        _articolo.ModificaGruppoReparto(idGruppoReparto, idGruppo, _utenteConnesso);
                    }
                }
                BeginInvoke(new MethodInvoker(CaricaGrigliaReparti));
            }
            catch (Exception ex)
            {
                MostraEccezione("Errore in associa gruppo reparto", ex);
            }
        }