public HttpResponseMessage ExportArea() { var sts = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 2); List <string> data = ExcelBLL.GetAreaColumn(); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } for (int i = 0; i < sts.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = sts[i]._id; dr[1] = Dict.Area.GetVal(sts[i].area); dr[2] = sts[i].pnm; dr[3] = sts[i].ph; dr[4] = sts[i].em; dr[5] = sts[i].qq; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
public HttpResponseMessage ExportPaperExcel([FromBody] ExportPaper m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } var filter = new BsonDocument(); filter.Add("eid", eInfo._id); if (!string.IsNullOrEmpty(m.School)) { int id = -1; if (int.TryParse(m.School, out id)) { filter.Add("sid", m.School); } else { filter.Add("snm", m.School); } } var sts = MongoDbHelper.GetPagedList1 <Pp_Nm, string>(DbName.Pp_Nm, 0, 0, filter, w => w.sid); List <string> data = ExcelBLL.GetPaperColumn(eInfo); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } for (int i = 0; i < sts.Count; i++) { DataRow dr = dt.NewRow(); var count = 0; dr[0] = sts[i].sid; dr[1] = sts[i].snm; for (int j = 0; j < eInfo.sbs.Count; j++) { var pp = sts[i].sbnms.Where(w => w.sbnm == eInfo.sbs[j].sbnm).FirstOrDefault(); if (pp != null) { dr[3 + j] = pp.sct; count += pp.sct; } else { dr[3 + j] = 0; } } dr[2] = count; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
private void btnApriFile_Click(object sender, EventArgs e) { try { lblMessage.Text = string.Empty; if (string.IsNullOrEmpty(txtFilePath.Text)) { lblMessage.Text = "Selezionare un file"; return; } if (!File.Exists(txtFilePath.Text)) { lblMessage.Text = "Il file specificato non esiste"; return; } ExcelBLL bll = new ExcelBLL(); CDCBLL cdcBll = new CDCBLL(); string messaggioErrore; if (!bll.LeggiExcelAnalisiPiombo(_DS, txtFilePath.Text, Contesto.Utente.FULLNAMEUSER, out messaggioErrore)) { string messaggio = string.Format("Errore nel caricamento del file excel. Errore: {0}", messaggioErrore); MessageBox.Show(messaggio, "ERRORE LETTURA FILE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lblNumeroRigheExcel.Text = _DS.CDC_CERTIFICATIPIOMBO.Count.ToString(); if (_DS.CDC_CERTIFICATIPIOMBO.Count == 0) { lblMessage.Text = "Il file è vuoto"; return; } dgvExcelCaricato.AutoGenerateColumns = true; dgvExcelCaricato.DataSource = _DS; dgvExcelCaricato.DataMember = _DS.CDC_CERTIFICATIPIOMBO.TableName; dgvExcelCaricato.Columns["IDCERTIFICATIPIOMBO"].Visible = false; dgvExcelCaricato.Columns["UTENTE"].Visible = false; dgvExcelCaricato.Columns["DATAINSERIMENTO"].Visible = false; foreach (DataGridViewRow riga in dgvExcelCaricato.Rows) { decimal nPd = (decimal)riga.Cells["PBPPM"].Value; Color colore; riga.Cells["ESITO"].Value = cdcBll.CalcolaEsitoAnalisiPiombo(nPd, out colore); riga.Cells["ESITO"].Style.BackColor = colore; } } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN APRI FILE EXCEL", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } }
public HttpResponseMessage ExportTchExcel([FromBody] ExportTchInfo m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } var filter = new BsonDocument(); filter.Add("eid", eInfo._id); if (!string.IsNullOrEmpty(m.School)) { int id = -1; if (int.TryParse(m.School, out id)) { filter.Add("sid", m.School); } else { filter.Add("snm", m.School); } } if (!string.IsNullOrEmpty(m.Subject)) { filter.Add("sb", m.Subject); } if (!string.IsNullOrEmpty(m.Name)) { filter.Add("nm", m.Name); } var tchs = MongoDbHelper.GetPagedList1 <Tch_Info, string>(DbName.Tch_Info, 0, 0, filter, w => w.nm); List <string> data = ExcelBLL.GetTchColumn(); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } for (int i = 0; i < tchs.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = tchs[i].sid; dr[1] = tchs[i].snm; dr[2] = tchs[i].sb; dr[3] = tchs[i].nm; dr[4] = tchs[i].sx == 0 ? "女" : "男"; dr[5] = tchs[i].zc; dr[6] = tchs[i].ph; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
private void btnSalvaDB_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; lblMessage.Text = string.Empty; ExcelBLL bll = new ExcelBLL(); List <decimal> IDPRENOTAZIONE_DUPLICATO = bll.VerificaExcelCaricato(_DS); if (IDPRENOTAZIONE_DUPLICATO.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Ci sono righe che sono già state salvate sul database (doppioni)."); sb.AppendLine("Le righe duplicate NON saranno salvate."); MessageBox.Show(sb.ToString(), "RIGHE DUPLICATE", MessageBoxButtons.OK, MessageBoxIcon.Warning); List <CDCDS.CDC_DETTAGLIORow> daCancellare = _DS.CDC_DETTAGLIO.Where(x => x.RowState != DataRowState.Deleted && IDPRENOTAZIONE_DUPLICATO.Contains(x.IDPRENOTAZIONE)).ToList(); foreach (CDCDS.CDC_DETTAGLIORow dettaglio in daCancellare) { dettaglio.Delete(); } _DS.CDC_DETTAGLIO.AcceptChanges(); } bll.Salva(_DS); lblMessage.Text = "Salvataggio riuscito"; ddlBrand.SelectedIndex = -1; string message = "operazione riuscita"; MessageBox.Show(message, "INFORMAZIONE", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN APRI FILE EXCEL", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } finally { Cursor.Current = Cursors.Default; } }
private void btnExportar_Click(object sender, RoutedEventArgs e) { if (dgTarefas.Items.Count > 0) { SaveFileDialog dialogo = new SaveFileDialog() { DefaultExt = "xls", Title = "Salvar relatório - Produsis", AddExtension = true }; if (dialogo.ShowDialog() == true) { ExcelBLL exporta = new ExcelBLL(); exporta.ExportarRelatorio(source, dialogo.FileName); } } }
public HttpResponseMessage BuildStuExcel([FromBody] ExamID m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } List <string> data = ExcelBLL.GetStuColumn(eInfo); List <string> col = new List <string>(); foreach (var item in eInfo.stps) { col.Add(item.tp); } string file = BLL.ExcelBLL.BuildStuExcel(data, col); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
public HttpResponseMessage ImportStuExcel(string ExamID, string SchoolID = "SchoolID") { lock (_locker) { try { var exam = MongoDbHelper.FindOne <E_Info>(ExamID, DbName.E_Info); if (CommonHelper.Function.ConvertDateI(DateTime.Now) < exam.sst) { return(ResultHelper.Failed("还未到录入时间,请等待")); } HttpPostedFile file = HttpContext.Current.Request.Files[0]; if (!Directory.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Excel\\" + DateTime.Now.ToString("yyyy-MM-dd"))) { Directory.CreateDirectory(System.AppDomain.CurrentDomain.BaseDirectory + "Excel\\" + DateTime.Now.ToString("yyyy-MM-dd")); } string path = System.AppDomain.CurrentDomain.BaseDirectory + "Excel\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\stu-" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(file.FileName); file.SaveAs(path); string msg = ""; int errnum = 0; msg = ExcelBLL.ImportStuExcel(path, exam, SchoolID, out errnum); if (msg != "") { if (msg == "表格格式错误,请重新下载模板") { return(ResultHelper.Failed(msg)); } string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + msg; return(ResultHelper.Failed("导入失败" + errnum + "条--" + url)); } return(ResultHelper.OK()); } catch (Exception) { return(ResultHelper.Failed("导入失败")); } } }
private void btnApriFile_Click(object sender, EventArgs e) { try { btnSalvaDB.Enabled = false; lblMessage.Text = string.Empty; if (string.IsNullOrEmpty(txtFilePath.Text)) { lblMessage.Text = "Selezionare un file"; return; } if (!File.Exists(txtFilePath.Text)) { lblMessage.Text = "Il file specificato non esiste"; return; } if (ddlBrand.SelectedIndex == -1) { lblMessage.Text = "Selezionare il brand a cui si riferisce il file EXCEL."; return; } string brand = (string)ddlBrand.SelectedItem; ExcelBLL bll = new ExcelBLL(); string messaggioErrore; if (!bll.LeggiExcelCDC(_DS, txtFilePath.Text, Contesto.Utente.FULLNAMEUSER, brand, out messaggioErrore)) { string messaggio = string.Format("Errore nel caricamento del file excel. Errore: {0}", messaggioErrore); MessageBox.Show(messaggio, "ERRORE LETTURA FILE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lblNumeroRigheExcel.Text = _DS.CDC_DETTAGLIO.Count.ToString(); if (_DS.CDC_DETTAGLIO.Count > 0) { lblDataExcel.Text = _DS.CDC_DETTAGLIO.FirstOrDefault().DATACOLLAUDO; } else { lblMessage.Text = "Il file è vuoto"; return; } btnSalvaDB.Enabled = true; dgvExcelCaricato.AutoGenerateColumns = true; dgvExcelCaricato.DataSource = _DS; dgvExcelCaricato.DataMember = _DS.CDC_DETTAGLIO.TableName; dgvExcelCaricato.Columns["IDDETTAGLIO"].Visible = false; dgvExcelCaricato.Columns["IDEXCEL"].Visible = false; List <decimal> IDPRENOTAZIONE_DUPLICATO = bll.VerificaExcelCaricato(_DS); if (IDPRENOTAZIONE_DUPLICATO.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Sono state individuate delle righe il cui ID PRENOTAZIONE è già stato acquisito. Si tratta di righe duplicate."); sb.AppendLine("Di seguito gli ID PRENOTAZIONE duplicati:"); foreach (decimal id in IDPRENOTAZIONE_DUPLICATO) { sb.AppendLine(id.ToString()); } MessageBox.Show(sb.ToString(), "RIGHE DUPLICATE", MessageBoxButtons.OK, MessageBoxIcon.Warning); } foreach (DataGridViewRow riga in dgvExcelCaricato.Rows) { decimal IDPRENOTAZIONE = (decimal)riga.Cells["IDPRENOTAZIONE"].Value; if (IDPRENOTAZIONE_DUPLICATO.Contains(IDPRENOTAZIONE)) { riga.Cells["IDPRENOTAZIONE"].Style.BackColor = Color.Yellow; } } } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN APRI FILE EXCEL", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } }
public HttpResponseMessage ExportStuExcel([FromBody] ExportStuInfo m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } var filter = new BsonDocument(); filter.Add("eid", eInfo._id); if (!string.IsNullOrEmpty(m.School)) { int id = -1; if (int.TryParse(m.School, out id)) { filter.Add("sid", m.School); } else { filter.Add("snm", m.School); } } if (!string.IsNullOrEmpty(m.StudentID)) { filter.Add("stid", m.StudentID); } if (!string.IsNullOrEmpty(m.StudentName)) { filter.Add("nm", m.StudentName); } var sts = MongoDbHelper.GetPagedList1 <St_Info, string>(DbName.St_Info, 0, 0, filter, w => w.stid); List <string> data = ExcelBLL.GetStuColumn(eInfo); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } for (int i = 0; i < sts.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = sts[i].sid; dr[1] = sts[i].snm; dr[2] = sts[i].stid; dr[3] = sts[i].cls; dr[4] = sts[i].nm; for (int j = 0; j < eInfo.sbs.Count; j++) { var sb = sts[i].subEs.Where(w => w.sbnm == eInfo.sbs[j].sbnm).FirstOrDefault(); if (sb != null) { dr[5 + j * 3] = sb.sbrm; dr[6 + j * 3] = sb.sbst; dr[7 + j * 3] = sb.sbtch; } else { dr[5 + j * 3] = null; dr[6 + j * 3] = null; dr[7 + j * 3] = null; } } dr[5 + eInfo.sbs.Count * 3] = sts[i].idcd; dr[6 + eInfo.sbs.Count * 3] = sts[i].tp; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
public HttpResponseMessage ExportScore([FromBody] ExportScore m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } var filter = new BsonDocument(); filter.Add("eid", eInfo._id); if (!string.IsNullOrEmpty(m.School)) { filter.Add("sid", m.School); } if (!string.IsNullOrEmpty(m.StudentID)) { filter.Add("stid", m.StudentID); } if (!string.IsNullOrEmpty(m.Name)) { filter.Add("nm", m.Name); } var stSc = MongoDbHelper.GetPagedList1 <St_Sc, string>(DbName.St_Sc, 0, 0, filter, w => w.nm); List <string> data = ExcelBLL.GetScoreColumn(eInfo); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } Type t = typeof(St_Sc); List <PropertyInfo> p = t.GetProperties().ToList(); Dictionary <string, PropertyInfo> dic = new Dictionary <string, PropertyInfo>(); List <string> sbs = eInfo.sbs.Select(w => "s" + w._id).ToList(); p.ForEach(w => { if (sbs.Contains(w.Name)) { dic.Add(w.Name, w); } }); for (int i = 0; i < stSc.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = stSc[i].stid; dr[1] = stSc[i].cls; dr[2] = stSc[i].nm; dr[3] = stSc[i].idcd; for (int j = 0; j < sbs.Count; j++) { PropertyInfo pro = dic[sbs[j]]; string value = pro.GetValue(stSc[i], null).ToString(); dr[4 + j] = value == "-1"?"-":value; } dr[4 + sbs.Count] = stSc[i].sc; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
public ActionResult InsertRSNData(HttpPostedFileBase filebase, string IsRsnOrDict, string primaryKey, string TC_PROJ_ID)//zlt HttpPostedFileBase { try { if (string.IsNullOrEmpty(primaryKey) || string.IsNullOrEmpty(TC_PROJ_ID)) { var result = new Tuple <string, string>("catch", "病种id或项目id为空"); return(Content(result.ToJson())); } DataTable error = null; var id = int.Parse(primaryKey); var projId = int.Parse(TC_PROJ_ID); //var connStr = ConfigurationManager.ConnectionStrings["connStr"].ToString(); var sdInfo = _sdService.Get(r => r.SD_ID == id) ?? new SD_INFO(); var dbConfig = _dbConfService.Get(r => r.TC_PROJ_ID == projId && r.DB_CONF_TYPE == 2) ?? new PDP_DB_CONF(); //if (sdInfo.TC_PROJ_ID == ProjectProvider.Instance.Current.TC_PROJ_ID) //{ var connStr = $"Data Source='" + dbConfig.SERVER_NAME + "';Initial Catalog='" + dbConfig.DB_NAME + "';User ID='" + dbConfig.DB_USER + "';Password='******'"; //var connStr = $"Data Source='" + ProjectProvider.Instance.Current.UNIT_DATA_SOURCE + "';Initial Catalog='" + ProjectProvider.Instance.Current.UNIT_INITIAL_CATALOG + "';User ID='" + ProjectProvider.Instance.Current.UNIT_USER_ID + "';Password='******'"; var sdCode = sdInfo.SD_CODE; var filePath = Server.MapPath(string.Format("~/{0}", "File")); var fullPath = Path.Combine(filePath, filebase.FileName); filebase.SaveAs(fullPath); var excelBll = new ExcelBLL(connStr, primaryKey, sdCode); DataSet ds = ExcelOperater.Read(fullPath); if (IsRsnOrDict == "0") { if (IsPossible(ds)) { DataTable dtKpiInfo = new DataTable(); dtKpiInfo.Columns.Add("SD_EKPI_ID"); dtKpiInfo.Columns.Add("SD_EKPI_NAME"); var kpiInfoList = _kpiService.GetManay(r => r.SD_ID == id).ToList(); if (kpiInfoList != null && kpiInfoList.Count > 0) { foreach (var kpiInfo in kpiInfoList) { DataRow dr = dtKpiInfo.NewRow(); dr["SD_EKPI_ID"] = kpiInfo.SD_EKPI_ID; dr["SD_EKPI_NAME"] = kpiInfo.SD_EKPI_NAME; dtKpiInfo.Rows.Add(dr); } _sdService.ClearData(primaryKey, IsRsnOrDict); error = excelBll.InsertRSNData(ds, OperatorProvider.Instance.Current.RealName, dtKpiInfo); } else { var result = new Tuple <string, string>("catch", "该病种下无KPI数据!"); return(Content(result.ToJson())); } } else { var result = new Tuple <string, string>("catch", "导入的excel文件模板有问题!"); return(Content(result.ToJson())); } } else { var result = new Tuple <string, string>("catch", "该功能暂时未实现!"); return(Content(result.ToJson())); } //} //else //{ // var result = new Tuple<string, string>("catch", "请切换该项目为当前项目!"); // return Content(result.ToJson()); //} if (error != null && error.Rows.Count > 0) { var res = error.ToJson().Replace("\r\n", "").Replace(" ", "").Replace(" ", "").Replace("\"", "'"); var guid = Guid.NewGuid().ToString(); var result = new Tuple <string, string>("error", guid); ImportResult.Add(result, res); return(Content(result.ToJson())); } else { var result = new Tuple <string, string>("success", null); return(Content(result.ToJson())); } } catch (Exception ex) { var result = new Tuple <string, string>("catch", ex.Message); return(Content(result.ToJson())); } }
public HttpResponseMessage ExportSchool([FromBody] GetSchool m) { List <U_Info> sts = new List <U_Info>(); var filter = new BsonDocument(); ObjectId objectid = new ObjectId(); if (ObjectId.TryParse(m.ExamID, out objectid)) { filter.Add("eid", objectid); if (!string.IsNullOrEmpty(m.School)) { int id = -1; if (int.TryParse(m.School, out id)) { filter.Add("sid", m.School); } else { filter.Add("snm", m.School); } } if (m.Area != 0) { filter.Add("area", m.Area); } if (m.IsSend != 0) { filter.Add("state", m.IsSend); } var schsc1 = MongoDbHelper.GetPagedList1 <Sch_Sc, string>(DbName.Sch_Sc, 0, 10000, filter, w => w._id).ToList(); var schsc = schsc1.Select(s => s.sid).ToList(); sts = MongoDbHelper.GetPagedList <U_Info, string>(DbName.U_Info, 0, 10000, w => schsc.Contains(w._id), o => o._id); } else { if (!string.IsNullOrEmpty(m.School)) { int id = -1; if (int.TryParse(m.School, out id)) { filter.Add("_id", m.School); } else { filter.Add("snm", m.School); } } if (m.Area != 0) { filter.Add("area", m.Area); } sts = MongoDbHelper.GetPagedList1 <U_Info, string>(DbName.U_Info, 0, 10000, filter, w => w._id).ToList(); } //var sts = MongoDbHelper.QueryBy<U_Info>(DbName.U_Info, w => w.tp == 1); List <string> data = ExcelBLL.GetSchColumn(); DataTable dt = new DataTable(); for (int j = 0; j < data.Count; j++) { dt.Columns.Add(data[j]); } for (int i = 0; i < sts.Count; i++) { DataRow dr = dt.NewRow(); dr[0] = sts[i]._id; dr[1] = sts[i].snm; dr[2] = Dict.Area.GetVal(sts[i].area); dr[3] = sts[i].pnm; dr[4] = sts[i].ph; dr[5] = sts[i].em; dr[6] = sts[i].qq; dt.Rows.Add(dr); } string file = ExcelBLL.BuildExcel1(data.ToArray(), dt); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
private void btnApriFile_Click(object sender, EventArgs e) { try { btnSalvaDB.Enabled = false; lblMessage.Text = string.Empty; if (string.IsNullOrEmpty(txtFilePath.Text)) { lblMessage.Text = "Selezionare un file"; return; } if (!File.Exists(txtFilePath.Text)) { lblMessage.Text = "Il file specificato non esiste"; return; } ExcelBLL bll = new ExcelBLL(); string messaggioErrore; if (!bll.LeggiExcelCDC(_DS, txtFilePath.Text, Contesto.Utente.FULLNAMEUSER, out messaggioErrore)) //brand, { string messaggio = string.Format("Errore nel caricamento del file excel. Errore: {0}", messaggioErrore); MessageBox.Show(messaggio, "ERRORE LETTURA FILE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lblNumeroRigheExcel.Text = _DS.CDC_DETTAGLIO_rel.Count.ToString(); if (_DS.CDC_DETTAGLIO_rel.Count > 0) { lblDataExcel.Text = _DS.CDC_DETTAGLIO_rel.FirstOrDefault().DATACOLLAUDO; } else { lblMessage.Text = "Il file è vuoto"; return; } btnSalvaDB.Enabled = true; dgvExcelCaricato.AutoGenerateColumns = true; dgvExcelCaricato.DataSource = _DS; dgvExcelCaricato.DataMember = _DS.CDC_DETTAGLIO_rel.TableName; dgvExcelCaricato.Columns["IDDETTAGLIO"].Visible = false; dgvExcelCaricato.Columns["IDEXCEL"].Visible = false; dgvExcelCaricato.Columns["IDBRAND"].Visible = false; dgvExcelCaricato.ReadOnly = false; foreach (DataGridViewColumn col in dgvExcelCaricato.Columns) { col.ReadOnly = true; } if (dgvExcelCaricato.Columns.Contains("BRAND")) { dgvExcelCaricato.Columns.Remove("BRAND"); } var comboCol = new DataGridViewComboBoxColumn(); comboCol.HeaderText = "BRAND"; comboCol.Name = "BRAND"; comboCol.DataPropertyName = "IDBRAND"; comboCol.AutoComplete = true; comboCol.Width = 100; comboCol.DropDownWidth = 100; comboCol.DataSource = _DS.CDC_BRANDS; comboCol.DisplayMember = "CODICE"; comboCol.ValueMember = "IDBRAND"; comboCol.ReadOnly = false; dgvExcelCaricato.Columns.Add(comboCol); List <decimal> IDPRENOTAZIONE_DUPLICATO = bll.VerificaExcelCaricato(_DS); List <decimal> IDPRENOTAZIONE_NOBRAND = bll.VerificaExcelCaricatoBrand(_DS).ToList(); if (IDPRENOTAZIONE_DUPLICATO.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Sono state individuate delle righe il cui ID PRENOTAZIONE è già stato acquisito. Si tratta di righe duplicate."); sb.AppendLine("Di seguito gli ID PRENOTAZIONE duplicati:"); foreach (decimal id in IDPRENOTAZIONE_DUPLICATO) { sb.AppendLine(id.ToString()); } MessageBox.Show(sb.ToString(), "RIGHE DUPLICATE", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (IDPRENOTAZIONE_NOBRAND.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Sono state individuate delle righe per le quali non è stato possibile attribuire il BRAND."); sb.AppendLine("Di seguito gli ID PRENOTAZIONE:"); foreach (decimal id in IDPRENOTAZIONE_NOBRAND) { sb.AppendLine(id.ToString()); } MessageBox.Show(sb.ToString(), "RIGHE SENZA BRAND", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ///ALLA FINE foreach (DataGridViewRow riga in dgvExcelCaricato.Rows) { decimal IDPRENOTAZIONE = (decimal)riga.Cells["IDPRENOTAZIONE"].Value; if (IDPRENOTAZIONE_NOBRAND.Contains(IDPRENOTAZIONE)) { riga.Cells["IDPRENOTAZIONE"].Style.BackColor = Color.Orange; } if (IDPRENOTAZIONE_DUPLICATO.Contains(IDPRENOTAZIONE)) { riga.Cells["IDPRENOTAZIONE"].Style.BackColor = Color.Yellow; } } } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN APRI FILE EXCEL", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } }