コード例 #1
0
        private void dgvDettaglio_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                lblMessaggio.Text = string.Empty;

                if (e.RowIndex == -1)
                {
                    return;
                }
                DataRow r           = _DS.CDC_DETTAGLIO.Rows[e.RowIndex];
                decimal IDDETTAGLIO = (decimal)r[0];
                _dettaglio = _DS.CDC_DETTAGLIO.Where(x => x.IDDETTAGLIO == IDDETTAGLIO).FirstOrDefault();

                ImpostaApplicazione(_dettaglio.COLORE, _dettaglio.PARTE);
                _dsServizio = new DataSet();

                CalcolaNumeroCampioni();

                CDCDS.CDC_GALVANICARow galvanica = _DS.CDC_GALVANICA.Where(x => x.IDDETTAGLIO == IDDETTAGLIO).FirstOrDefault();
                if (galvanica != null)
                {
                    CaricaCampioniMisuraPrecedente(galvanica);
                }
                else
                {
                    if (_dsServizio.Tables[tblMisure] != null)
                    {
                        _dsServizio.Tables.Remove(tblMisure);
                    }

                    DataTable dtDimensioni = _dsServizio.Tables.Add();
                    dtDimensioni.TableName = tblMisure;
                    dtDimensioni.Columns.Add("IDPRENOTAZIONE", Type.GetType("System.Decimal"));
                    dtDimensioni.Columns.Add("IDDETTAGLIO", Type.GetType("System.Decimal"));
                    dtDimensioni.Columns.Add("MISURA", Type.GetType("System.Int32"));

                    if (_dsServizio.Tables[tblAggregati] != null)
                    {
                        _dsServizio.Tables.Remove(tblAggregati);
                    }
                    DataTable dtAggregati = _dsServizio.Tables.Add();
                    dtAggregati.TableName = tblAggregati;
                    dtAggregati.Columns.Add("DATO", Type.GetType("System.String"));

                    mostradgvAggregati();
                    mostradgvMisure();
                }
                ImpostaSpessore(_dettaglio.PARTE, _dettaglio.COLORE);
            }
            catch (Exception ex)
            {
                MostraEccezione(ex, "Errore in dgvDettaglio_CellClick");
            }
        }
コード例 #2
0
        private void CaricaCampioniMisuraPrecedente(CDCDS.CDC_GALVANICARow galvanica)
        {
            List <CDCDS.CDC_MISURERow> misurePrecedenti = _DS.CDC_MISURE.Where(x => x.RowState != DataRowState.Deleted && x.IDGALVANICA == galvanica.IDGALVANICA).OrderBy(x => x.NMISURA).ThenBy(x => x.NCOLONNA).ToList();

            int numeroCampioni = (int)misurePrecedenti.Max(x => x.NMISURA) + 1;

            txtNumeroCampioni.Text = numeroCampioni.ToString();
            if (((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand == CDCBrands.YSL ||
                ((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand == CDCBrands.Balenciaga ||
                ((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand == CDCBrands.McQueen)

            {
                if (galvanica.MISURECAMPIONE > 0)
                {
                    int aux = numeroCampioni / (int)galvanica.MISURECAMPIONE;
                    txtNumeroCampioni.Text = aux.ToString();
                }
            }
            int numeroColonne = misurePrecedenti.Where(x => x.NMISURA == 1).Count();

            if (_dsServizio.Tables[tblMisure] != null)
            {
                _dsServizio.Tables.Remove(tblMisure);
            }

            DataTable dtDimensioni = _dsServizio.Tables.Add();

            dtDimensioni.TableName = tblMisure;
            dtDimensioni.Columns.Add("IDPRENOTAZIONE", Type.GetType("System.Decimal"));
            dtDimensioni.Columns.Add("IDDETTAGLIO", Type.GetType("System.Decimal"));
            dtDimensioni.Columns.Add("MISURA", Type.GetType("System.Int32"));

            if (_dsServizio.Tables[tblAggregati] != null)
            {
                _dsServizio.Tables.Remove(tblAggregati);
            }
            DataTable dtAggregati = _dsServizio.Tables.Add();

            dtAggregati.TableName = tblAggregati;
            dtAggregati.Columns.Add("DATO", Type.GetType("System.String"));

            foreach (CDCDS.CDC_MISURERow mColore in misurePrecedenti.Where(x => x.NMISURA == 1))
            {
                dtDimensioni.Columns.Add(mColore.TIPOMISURA, Type.GetType("System.Decimal"));
                dtAggregati.Columns.Add(mColore.TIPOMISURA, Type.GetType("System.String"));
            }

            for (int i = 0; i < numeroCampioni; i++)
            {
                DataRow riga = dtDimensioni.NewRow();
                riga[0] = _dettaglio.IDPRENOTAZIONE;
                riga[1] = _dettaglio.IDDETTAGLIO;
                riga[2] = i;

                for (int j = 0; j < numeroColonne; j++)
                {
                    CDCDS.CDC_MISURERow misura = misurePrecedenti.Where(x => x.NMISURA == i && x.NCOLONNA == j).FirstOrDefault();
                    if (misura != null)
                    {
                        riga[j + 3] = Decimal.Parse(misura.VALORE);
                    }
                }

                dtDimensioni.Rows.Add(riga);
            }

            mostradgvMisure();

            CalcolaValoriAggregati();
        }