Example #1
0
        private void Update_EXCEL_ElementHandler(object sender, RowUpdatedEventArgs e)
        {
            if ((e.Status == UpdateStatus.Continue) && (e.StatementType == StatementType.Insert))
            {
                //ArticleDS.SPELEMENTIRow row = (ArticleDS.SPELEMENTIRow)e.Row;
                CDCDS.CDC_EXCELRow row = (CDCDS.CDC_EXCELRow)e.Row;

                //ArticleDS.SPELEMENTIDataTable dt = row.Table as ArticleDS.SPELEMENTIDataTable;
                CDCDS.CDC_EXCELDataTable dt = row.Table as CDCDS.CDC_EXCELDataTable;

                //bool isIdentityReadOnly = dt.ID_SPELEMColumn.ReadOnly;
                bool isIdentityReadOnly = dt.IDEXCELColumn.ReadOnly;

                //dt.ID_SPELEMColumn.ReadOnly = false;
                dt.IDEXCELColumn.ReadOnly = false;

                try
                {
                    //row.ID_SPELEM = (long)RetrievePostUpdateID<decimal>(e.Command, row);
                    row.IDEXCEL = (long)RetrievePostUpdateID <decimal>(e.Command, row);
                }
                finally
                {
                    //dt.ID_SPELEMColumn.ReadOnly = isIdentityReadOnly;
                    dt.IDEXCELColumn.ReadOnly = isIdentityReadOnly;
                }
            }
        }
        public bool LeggiExcelCDC(CDCDS ds, string filePath, string utente, string brand, out string messaggioErrore)
        {
            messaggioErrore = string.Empty;
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                ds.CDC_DETTAGLIO.Clear();
                ds.CDC_EXCEL.Clear();

                decimal IDEXCEL;
                using (CDCMetalBusiness bCDCMetal = new CDCMetalBusiness())
                {
                    long ID = bCDCMetal.GetID();
                    IDEXCEL = (decimal)ID;
                }

                CDCDS.CDC_EXCELRow excelRow = ds.CDC_EXCEL.NewCDC_EXCELRow();
                excelRow.IDEXCEL          = IDEXCEL;
                excelRow.NOMEFILE         = filePath.Length > 200 ? filePath.Substring(0, 200) : filePath;
                excelRow.DATAACQUISIZIONE = DateTime.Today;
                excelRow.UTENTE           = utente.Length > 50 ? utente.Substring(0, 50) : utente;
                excelRow.AZIENDA          = brand;

                MemoryStream ms   = new MemoryStream();
                byte[]       dati = new byte[fs.Length];
                fs.Read(dati, 0, (int)fs.Length);
                excelRow.DATI = dati;

                ExcelHelper excel = new ExcelHelper();
                if (!excel.ReadCDC(fs, ds, IDEXCEL, utente, out messaggioErrore))
                {
                    ds.CDC_DETTAGLIO.Clear();
                    ds.CDC_EXCEL.Clear();
                    return(false);
                }

                if (ds.CDC_DETTAGLIO.Count > 0)
                {
                    string   data = ds.CDC_DETTAGLIO.FirstOrDefault().DATACOLLAUDO;
                    DateTime dt   = DateTime.ParseExact(data, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    excelRow.DATARIFERIMENTO = dt;
                    ds.CDC_EXCEL.AddCDC_EXCELRow(excelRow);
                    return(true);
                }
                else
                {
                    messaggioErrore = "Il file excel risulta essere vuoto";
                    return(false);
                }

                fs.Close();
            }
            return(false);
        }
Example #3
0
        public bool LeggiExcelCDC(CDCDS ds, string filePath, string utente, out string messaggioErrore)  //string brand,
        {
            messaggioErrore = string.Empty;
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                ds.CDC_DETTAGLIO_rel.Clear();
                ds.CDC_EXCEL.Clear();

                decimal IDEXCEL = 0;
                //using (CDCMetalBusiness bCDCMetal = new CDCMetalBusiness()) //JACOPO
                //{
                //    //////long ID = bCDCMetal.GetID(); //JACOPO
                //    long ID = bCDCMetal.GetSQLID(); //JACOPO
                //    IDEXCEL = (decimal)ID; //JACOPO
                //}

                CDCDS.CDC_EXCELRow excelRow = ds.CDC_EXCEL.NewCDC_EXCELRow();
                excelRow.IDEXCEL          = IDEXCEL;
                excelRow.NOMEFILE         = filePath.Length > 200 ? filePath.Substring(0, 200) : filePath;
                excelRow.DATAACQUISIZIONE = DateTime.Today;
                excelRow.UTENTE           = utente.Length > 50 ? utente.Substring(0, 50) : utente;
                //excelRow.AZIENDA = brand; //?????????????????

                MemoryStream ms   = new MemoryStream();
                byte[]       dati = new byte[fs.Length];
                fs.Read(dati, 0, (int)fs.Length);
                excelRow.DATI = dati;


                excelRow.DATARIFERIMENTO = DateTime.Today; //JACOPO -- poi la cambio con data Collaudo
                ds.CDC_EXCEL.AddCDC_EXCELRow(excelRow);    //aggiunta JACOPO


                ExcelHelper excel = new ExcelHelper();
                if (!excel.ReadCDC(fs, ds, IDEXCEL, utente, out messaggioErrore))
                {
                    ds.CDC_DETTAGLIO_rel.Clear();
                    ds.CDC_EXCEL.Clear();
                    return(false);
                }

                if (ds.CDC_DETTAGLIO_rel.Count > 0)
                {
                    string data = ds.CDC_DETTAGLIO_rel.FirstOrDefault().DATACOLLAUDO;

                    //agganciare riga di EXCEL giĆ  presente //JaCOPO

                    DateTime dt = DateTime.ParseExact(data, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    excelRow.DATARIFERIMENTO = dt;
                    //ds.CDC_EXCEL.AddCDC_EXCELRow(excelRow); // tolto JACOPO
                    return(true);
                }
                else
                {
                    messaggioErrore = "Il file excel risulta essere vuoto";
                    return(false);
                }

                fs.Close();
            }
            return(false);
        }