protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { proxyMtd = new AnagraficaDealerService(); } }
protected void Session_Start(object sender, EventArgs e) { if (Context.User.Identity.IsAuthenticated) { AnagraficaDealerService proxtCRMP = new AnagraficaDealerService(); string username = (Context.User.Identity.Name.Split(new Char[] { '\\' }))[1]; //proxtCRMP.WriteLogger("username" + username, "Info"); DataTable dt = proxtCRMP.GetUtente(username); if (dt != null && dt.Rows.Count != 0) { //proxtCRMP.WriteLogger("dt.Rows.Count:" + dt.Rows.Count, "Info"); //Trace.Write(" dt.Rows.Count " + dt.Rows.Count.ToString()); Session["user"] = username; Session["UserID"] = dt.Rows[0]["IDUsername"]; Session["NomeUtente"] = dt.Rows[0]["Nome"] + " " + dt.Rows[0]["Cognome"]; Session["IDProfilo"] = dt.Rows[0]["IDProfilo"]; Session["ProfiloUtente"] = dt.Rows[0]["NomeProfilo"]; Session["ArchivioDataBase"] = dt.Rows[0]["ArchivioDataBase"]; Session["ArchivioCruscotto"] = dt.Rows[0]["ArchivioCruscotto"]; Session["ReportAnomalie"] = dt.Rows[0]["ReportAnomalie"]; Session["ReportScarti"] = dt.Rows[0]["ReportScarti"]; Session["Amministrazione"] = dt.Rows[0]["Amministrazione"]; Session["RagioniSocialiCorrelate"] = dt.Rows[0]["RagioniSocialiCorrelate"]; Session["Eccezioni"] = dt.Rows[0]["Eccezioni"]; } } //Session["IDUtente"] = 1; Session["IDDealer"] = 0; //Session["IDProfiloLoggedInTest"] = 3; Session["DivNumSelected"] = 1; Session["retCode"] = String.Empty; }
private void PopupElimina_EliminaButtonClicked(object sender, EventArgs e) { try { Boolean attivo = false; string IDUtenteSelezionato = null; foreach (GridViewRow row in gvUtenti.Rows) { CheckBox chkSelected = (CheckBox)row.FindControl("cbSelected"); if (chkSelected.Checked) { attivo = ((CheckBox)row.FindControl("Attivo")).Checked; IDUtenteSelezionato = chkSelected.Attributes["key"]; } } int IDUtente = Convert.ToInt32(Session["IDUtente"].ToString()); AnagraficaDealerService proxyMtd = new AnagraficaDealerService(); proxyMtd.DeleteUtente(IDUtente); Session.Remove("IDUtente"); GestioneUtentiSubMenuControl.enableBtnModifica(false); GestioneUtentiSubMenuControl.enableBtnElimina(false); PopupElimina.Hide(); gvUtenti.DataSource = proxyMtd.GetAllUtenti(); gvUtenti.DataBind(); utenteUpdatePanel.Update(); } catch (Exception ex) { PopupMessaggio.ShowMsgBox(ex.Message, true); } }
private void PopupEliminaProfilo_EliminaButtonClicked(object sender, EventArgs e) { try { int IDProfilo = Convert.ToInt32(Session["IDProfilo"].ToString()); AnagraficaDealerService proxyMtd = new AnagraficaDealerService(); // proxyMtd.DeleteProfilo(IDProfilo); string error = proxyMtd.DeleteProfilo(IDProfilo); if (error != string.Empty) { PopupElimina.Hide(); throw new Exception(error); } Session.Remove("IDProfilo"); GestioneProfiliSubMenuControl.enableBtnModifica(false); GestioneProfiliSubMenuControl.enableBtnElimina(false); PopupElimina.Hide(); profiloGridView.DataSource = proxyMtd.GetAllProfili(); profiloGridView.DataBind(); profiliUpdatePanel.Update(); } catch (Exception ex) { PopupMessaggio.ShowMsgBox(ex.Message, true); } }
protected void Page_Load(object sender, EventArgs e) { PopupAggiungiRelazioneDealer.AggiungiButtonClicked += new UserControl.RagioniSocialiCorrelate.AggiungiRelazioneDealerEventHandler(PopupAggiungiRelazioneDealer_AggiungiButtonClicked); proxyADS = new AnagraficaDealerService(); if (!IsPostBack) { } }
protected void Page_Load(object sender, EventArgs e) { PopupElimina.EliminaButtonClicked += new UserControl.RagioniSocialiCorrelate.EliminaEventHandler(PopupElimina_EliminaButtonClicked); Page.ClientScript.GetPostBackEventReference(gvRelazioni, ""); proxyADS = new AnagraficaDealerService(); if (!IsPostBack) { RelazioniResults = null; } }
protected void Page_Load(object sender, EventArgs e) { PopupElimina.EliminaButtonClicked += new UserControl.RagioniSocialiCorrelate.EliminaEventHandler(PopupElimina_EliminaButtonClicked); if (!IsPostBack) { proxyMtd = new AnagraficaDealerService(); gvUtenti.DataSource = proxyMtd.GetAllUtenti(); gvUtenti.DataBind(); } }
private void LoadDealerBusiness(int IDDealerBusiness) { AnagraficaDealerService proxyMtd = new AnagraficaDealerService(); DataTable dt = proxyMtd.GetDealerBusiness(IDDealerBusiness); IDDealerBusinessHF.Value = dt.Rows[0]["IDDealerBusiness"].ToString(); txtCodiceDealer.Text = dt.Rows[0]["Codice"].ToString(); txtRagioneSociale.Text = dt.Rows[0]["Nome"].ToString(); txtIndirizzo.Text = dt.Rows[0]["Indirizzo"].ToString(); panelPopupModificheDealerBusiness.Update(); }
protected void Page_Load(object sender, EventArgs e) { PopupAggiungiEccezione.AggiungiButtonClicked += new UserControl.RagioniSocialiCorrelate.AggiungiEccezioneEventHandler(PopupAggiungiEccezione_AggiungiButtonClicked); PopupElimina.EliminaButtonClicked += new UserControl.RagioniSocialiCorrelate.EliminaEventHandler(PopupElimina_EliminaButtonClicked); proxyMtd = new AnagraficaDealerService(); if (!IsPostBack) { DealerTable = proxyMtd.GetAllDealerImport(); eccImportGridView.DataSource = DealerTable; eccImportGridView.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { PopupAggiungiTipoDealer.AggiungiButtonClicked += new UserControl.RagioniSocialiCorrelate.AggiungiTipoDealerEventHandler(PopupAggiungiTipoDealer_AggiungiButtonClicked); //PopupAggiungiProfiloAssociazioni.AggiungiButtonClicked += new UserControl.Popup.AggiungiAbilitazioneEventHandler(PopupAggiungiProfiloAbilitazioni_AggiungiButtonClicked); proxyMtd = new AnagraficaDealerService(); if (!IsPostBack) { IDProfiloHF.Value = IDProfilo.ToString(); if (IDProfilo != 0) { setProfilo(); } } }
protected void Page_Load(object sender, EventArgs e) { PopupAggiungiDealerBusiness.AggiungiButtonClicked += new UserControl.RagioniSocialiCorrelate.AggiungiDealerBusinessEventHandler(PopupAggiungiDealerBusiness_AggiungiButtonClicked); PopupElimina.EliminaButtonClicked += new UserControl.RagioniSocialiCorrelate.EliminaEventHandler(PopupElimina_EliminaButtonClicked); PopupModificheDealerBusiness.ModificaButtonClicked += new UserControl.RagioniSocialiCorrelate.ModificheDealerBusinessEventHandler(PopupModificheDealerBusiness_ModificaButtonClicked); proxyMtd = new AnagraficaDealerService(); if (!IsPostBack) { DealerTableBusiness = proxyMtd.GetAllDealerBusiness(); gvDealerBusiness.DataSource = DealerTableBusiness; gvDealerBusiness.DataBind(); gvDealerBusiness.SetPageIndex(0); } }
protected void Page_Load(object sender, EventArgs e) { proxyMtd = new AnagraficaDealerService(); if (!IsPostBack) { if (IDUtente != 0) { setUtente(); AggiungiUtenteButton.Visible = false; ModicaUtenteButton.Visible = true; } else { AggiungiUtenteButton.Visible = true; ModicaUtenteButton.Visible = false; } } }
private void LoadDettaglio(int IDRelazione, int tipoDealer) { AnagraficaDealerService proxyADS = new AnagraficaDealerService(); DataTable dt = proxyADS.GetDettaglioRelazione(IDRelazione, tipoDealer); lblCodiceDealer.Text = dt.Rows[0]["CodiceDealerConsumer"].ToString(); lblNome.Text = dt.Rows[0]["RagioneSocialeDealerConsumer"].ToString(); lblIndirizzo.Text = dt.Rows[0]["IndirizzoDealerConsumer"].ToString(); lblCanale.Text = dt.Rows[0]["CanaleDealerConsumer"].ToString(); lblStato.Text = dt.Rows[0]["StatoDealerConsumer"].ToString(); lblCodiceRelativo.Text = dt.Rows[0]["CodiceDealer"].ToString(); lblCanaleRelativo.Text = dt.Rows[0]["CanaleDealer"].ToString(); lblIndirizzoRelativo.Text = dt.Rows[0]["IndirizzoDealer"].ToString(); lblNomeRelativo.Text = dt.Rows[0]["RagioneSocialeDealer"].ToString(); lblStatoRelativo.Text = dt.Rows[0]["StatoDealer"].ToString(); //panelPopupDettaglioRelazioni.Update(); }
protected void Page_Load(object sender, EventArgs e) { proxyAds = new AnagraficaDealerService(); if (!IsPostBack) { ArchivioDatabaseGridView.DataSource = proxyAds.GetAllExport(1); ArchivioDatabaseGridView.DataBind(); } //if (!IsPostBack) //{ // DataTable table = new DataTable(); // DataColumn col1 = new DataColumn("Data"); // DataColumn col2 = new DataColumn("File"); // col1.DataType = System.Type.GetType("System.String"); // col2.DataType = System.Type.GetType("System.String"); // table.Columns.Add(col1); // table.Columns.Add(col2); // DataRow row1 = table.NewRow(); // row1[col1] = "06/05/2015"; // row1[col2] = "ReportAnomalie_06-05-2015.xlsx"; // table.Rows.Add(row1); // DataRow row2 = table.NewRow(); // row2[col1] = "07/05/2015"; // row2[col2] = "ReportAnomalie_07-05-2015.xlsx"; // table.Rows.Add(row2); // ArchivioDatabaseGridView.DataSource = table; // ArchivioDatabaseGridView.DataBind(); //} }
protected void Page_Load(object sender, EventArgs e) { proxyAds = new AnagraficaDealerService(); }
protected void Page_Load(object sender, EventArgs e) { PopupElimina.EliminaButtonClicked += new UserControl.RagioniSocialiCorrelate.EliminaEventHandler(PopupEliminaProfilo_EliminaButtonClicked); if (!IsPostBack) { proxyMtd = new AnagraficaDealerService(); profiloGridView.DataSource = proxyMtd.GetAllProfili(); profiloGridView.DataBind(); } }
protected void Page_Load(object sender, System.EventArgs e) { string queryExport = string.Empty; proxyMtd = new AnagraficaDealerClassLib.AnagraficaDealerService(); HttpContext.Current.Session["User"] = (Context.User.Identity.Name.Split(new Char[] { '\\' }))[1]; string user = HttpContext.Current.Session["User"].ToString(); #region SOLO TEST //SOLO PER TEST:ELIMINARE //string test_queryExport = "<XML><FIELD id='IDTipoDealer' value='1' typeDb='combo' IDTipoDealer='1'/><FIELD clientid='txtDealerCode' id='Codice' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtRagioneSociale' id='RagioneSociale' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtPIVA' id='PIVA' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtMasterDealerCode' id='MasterDealer' value='' typeDb='text' IDTipoDealer='2'/><FIELD clientid='txtLocalita' id='Localita' value='' typeDb='text' IDTipoDealer='1;2;3;5'/><FIELD clientid='txtZonaAssegnata' id='ZonaAssegnata' value='' typeDb='text' IDTipoDealer='3;4'/><FIELD clientid='txtFunzionario' id='Funzionario' value='' typeDb='text' IDTipoDealer='1;3;4;5'/><FIELD clientid='txtSupporti' id='Supporti' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCommittente' id='Cliente' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCFTitolare' id='CFTitolare' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCateneAM' id='DatiCateneAm' value='' typeDb='text' IDTipoDealer='5'/><FIELD clientid='txtCateneFunzionario' id='DatiCateneFunzionario' value='' typeDb='text' IDTipoDealer='5'/><FIELD clientid='txtInsegna' id='Insegna' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtDimensioneMQ' id='DimensioneAreaVendita' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtAffitto' id='ValoreAffitto' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtTOTPT' id='PT' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtTOTFT' id='FTE' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtDataDisdetta' id='DataDisdetta' value='' typeDb='data' IDTipoDealer='2;3'/><FIELD clientid='txtDataTerminePreavviso' id='DataTerminePreavviso' value='' typeDb='data' IDTipoDealer='1'/><FIELD clientid='txtNomeContatto' id='NomeContatto' value='' typeDb='text' IDTipoDealer='1'/><FIELD id='Operativita' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDRegione' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='IDProvincia' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='ModelloVendita' value='' typeDb='combo' IDTipoDealer='3;4'/><FIELD id='SegmentazioneCanale' value='' typeDb='combo' IDTipoDealer='1;5'/><FIELD id='ShopInStore' value='' typeDb='combo' IDTipoDealer='5'/><FIELD id='Cluster' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='CentroAssistenzaTecnica' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='Disdetta' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='AreaDiCompetenza' value='' typeDb='combo' IDTipoDealer='1;5'/><FIELD id='IDStato' value='2' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDCanale' value='6' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDArea' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDAreaManager' value='' typeDb='combo' IDTipoDealer='1;3;4;5'/><RETURNFIELD value='IDDealer,Codice,Canale,RagioneSociale,Stato,Area'/><EXPORTFIELDS value='IDDealer,Codice,Canale,RagioneSociale,Stato,Area'/></XML>"; //DataTable dt = CreateTestDT();//proxyMtd.RicercaDealer(queryExport, user); //queryExport = test_queryExport; //FINE TEST #endregion queryExport = HttpContext.Current.Session["ExportQuery"].ToString(); XmlDocument xmlExport = new XmlDocument(); xmlExport.LoadXml(queryExport); XmlDocument xmlExportTmp; List<DataTable> dtList = new List<DataTable>(); string[] tipoDealer = xmlExport.SelectSingleNode("//FIELD[@id='IDTipoDealer']/@value").InnerText.Split(','); foreach (var dealer in tipoDealer) { xmlExportTmp = new XmlDocument(); xmlExportTmp.LoadXml(queryExport); XmlNodeList t = xmlExportTmp.SelectNodes("//EXPFIELD[not(contains(@IDTipoDealer,'"+dealer.ToString()+"'))]"); foreach (XmlNode node in t) { xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").RemoveChild(node); string tmpName = node.Attributes["id"].Value; XmlNode expNode = xmlExportTmp.SelectSingleNode("//EXPFIELD[@id='" + tmpName + "']"); xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value = xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value.Replace(","+tmpName, "").Replace(",,", ","); } xmlExportTmp.SelectSingleNode("//RETURNFIELD").Attributes["value"].Value = xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value; xmlExportTmp.SelectSingleNode("//FIELD[@id='IDTipoDealer']").Attributes["value"].Value = dealer.ToString(); foreach(XmlNode f in xmlExportTmp.SelectNodes("//FIELD")) { f.Attributes["IDTipoDealer"].Value = dealer.ToString(); } DataTable dt = proxyMtd.RicercaDealer(xmlExportTmp.InnerXml, user); foreach (var col in colsToRemove) { if (dt.Columns.Contains(col.ToString())) { dt.Columns.Remove(col.ToString()); } } dtList.Add(dt); } xmlExport = null; xmlExportTmp = null; using (ExcelPackage pck = new ExcelPackage()) { ExcelWorksheet ws; int i = 0; foreach(DataTable dt in dtList) { string td = GetStringValue((TipoDealerDesc)Convert.ToInt32(tipoDealer[i])); ws = pck.Workbook.Worksheets.Add(td); ws.Cells["A1"].LoadFromDataTable(dt, true); ws.Cells[1, 1, 1, dt.Columns.Count].Style.Font.Color.SetColor(System.Drawing.Color.White); ws.Cells[1, 1, 1, dt.Columns.Count].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; ws.Cells[1, 1, 1, dt.Columns.Count].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red); ws.Cells[ws.Dimension.Address].AutoFitColumns(); i++; } //Create the worksheet #region SOLO TEST //ws = pck.Workbook.Worksheets.Add("Dealer POS"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws = pck.Workbook.Worksheets.Add("Dealer POS&POD"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws = pck.Workbook.Worksheets.Add("Agenti Committenti"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); #endregion Byte[] fileBytes = pck.GetAsByteArray(); Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=RicercaDealer.xlsx"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); Response.BinaryWrite(fileBytes); Response.End(); } }
protected void Page_Load(object sender, System.EventArgs e) { string queryExport = string.Empty; proxyMtd = new AnagraficaDealerClassLib.AnagraficaDealerService(); HttpContext.Current.Session["User"] = (Context.User.Identity.Name.Split(new Char[] { '\\' }))[1]; string user = HttpContext.Current.Session["User"].ToString(); #region SOLO TEST //SOLO PER TEST:ELIMINARE //string test_queryExport = "<XML><FIELD id='IDTipoDealer' value='1' typeDb='combo' IDTipoDealer='1'/><FIELD clientid='txtDealerCode' id='Codice' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtRagioneSociale' id='RagioneSociale' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtPIVA' id='PIVA' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtMasterDealerCode' id='MasterDealer' value='' typeDb='text' IDTipoDealer='2'/><FIELD clientid='txtLocalita' id='Localita' value='' typeDb='text' IDTipoDealer='1;2;3;5'/><FIELD clientid='txtZonaAssegnata' id='ZonaAssegnata' value='' typeDb='text' IDTipoDealer='3;4'/><FIELD clientid='txtFunzionario' id='Funzionario' value='' typeDb='text' IDTipoDealer='1;3;4;5'/><FIELD clientid='txtSupporti' id='Supporti' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCommittente' id='Cliente' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCFTitolare' id='CFTitolare' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtCateneAM' id='DatiCateneAm' value='' typeDb='text' IDTipoDealer='5'/><FIELD clientid='txtCateneFunzionario' id='DatiCateneFunzionario' value='' typeDb='text' IDTipoDealer='5'/><FIELD clientid='txtInsegna' id='Insegna' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtDimensioneMQ' id='DimensioneAreaVendita' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtAffitto' id='ValoreAffitto' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtTOTPT' id='PT' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtTOTFT' id='FTE' value='' typeDb='text' IDTipoDealer='1'/><FIELD clientid='txtDataDisdetta' id='DataDisdetta' value='' typeDb='data' IDTipoDealer='2;3'/><FIELD clientid='txtDataTerminePreavviso' id='DataTerminePreavviso' value='' typeDb='data' IDTipoDealer='1'/><FIELD clientid='txtNomeContatto' id='NomeContatto' value='' typeDb='text' IDTipoDealer='1'/><FIELD id='Operativita' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDRegione' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='IDProvincia' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='ModelloVendita' value='' typeDb='combo' IDTipoDealer='3;4'/><FIELD id='SegmentazioneCanale' value='' typeDb='combo' IDTipoDealer='1;5'/><FIELD id='ShopInStore' value='' typeDb='combo' IDTipoDealer='5'/><FIELD id='Cluster' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='CentroAssistenzaTecnica' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='Disdetta' value='' typeDb='combo' IDTipoDealer='1;2;3;5'/><FIELD id='AreaDiCompetenza' value='' typeDb='combo' IDTipoDealer='1;5'/><FIELD id='IDStato' value='2' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDCanale' value='6' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDArea' value='' typeDb='combo' IDTipoDealer='1'/><FIELD id='IDAreaManager' value='' typeDb='combo' IDTipoDealer='1;3;4;5'/><RETURNFIELD value='IDDealer,Codice,Canale,RagioneSociale,Stato,Area'/><EXPORTFIELDS value='IDDealer,Codice,Canale,RagioneSociale,Stato,Area'/></XML>"; //DataTable dt = CreateTestDT();//proxyMtd.RicercaDealer(queryExport, user); //queryExport = test_queryExport; //FINE TEST #endregion queryExport = HttpContext.Current.Session["ExportQuery"].ToString(); XmlDocument xmlExport = new XmlDocument(); xmlExport.LoadXml(queryExport); XmlDocument xmlExportTmp; List <DataTable> dtList = new List <DataTable>(); string[] tipoDealer = xmlExport.SelectSingleNode("//FIELD[@id='IDTipoDealer']/@value").InnerText.Split(','); foreach (var dealer in tipoDealer) { xmlExportTmp = new XmlDocument(); xmlExportTmp.LoadXml(queryExport); XmlNodeList t = xmlExportTmp.SelectNodes("//EXPFIELD[not(contains(@IDTipoDealer,'" + dealer.ToString() + "'))]"); foreach (XmlNode node in t) { xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").RemoveChild(node); string tmpName = node.Attributes["id"].Value; XmlNode expNode = xmlExportTmp.SelectSingleNode("//EXPFIELD[@id='" + tmpName + "']"); xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value = xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value.Replace("," + tmpName, "").Replace(",,", ","); } xmlExportTmp.SelectSingleNode("//RETURNFIELD").Attributes["value"].Value = xmlExportTmp.SelectSingleNode("//EXPORTFIELDS").Attributes["value"].Value; xmlExportTmp.SelectSingleNode("//FIELD[@id='IDTipoDealer']").Attributes["value"].Value = dealer.ToString(); foreach (XmlNode f in xmlExportTmp.SelectNodes("//FIELD")) { f.Attributes["IDTipoDealer"].Value = dealer.ToString(); } DataTable dt = proxyMtd.RicercaDealer(xmlExportTmp.InnerXml, user); foreach (var col in colsToRemove) { if (dt.Columns.Contains(col.ToString())) { dt.Columns.Remove(col.ToString()); } } dtList.Add(dt); } xmlExport = null; xmlExportTmp = null; using (ExcelPackage pck = new ExcelPackage()) { ExcelWorksheet ws; int i = 0; foreach (DataTable dt in dtList) { string td = GetStringValue((TipoDealerDesc)Convert.ToInt32(tipoDealer[i])); ws = pck.Workbook.Worksheets.Add(td); ws.Cells["A1"].LoadFromDataTable(dt, true); ws.Cells[1, 1, 1, dt.Columns.Count].Style.Font.Color.SetColor(System.Drawing.Color.White); ws.Cells[1, 1, 1, dt.Columns.Count].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; ws.Cells[1, 1, 1, dt.Columns.Count].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Red); ws.Cells[ws.Dimension.Address].AutoFitColumns(); i++; } //Create the worksheet #region SOLO TEST //ws = pck.Workbook.Worksheets.Add("Dealer POS"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws = pck.Workbook.Worksheets.Add("Dealer POS&POD"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws = pck.Workbook.Worksheets.Add("Agenti Committenti"); ////Load the datatable into the sheet, starting from cell A1. Print the column names on row 1 //ws.Cells["A1"].LoadFromDataTable(dt, true); ////ws.Cells[1, 1].Value = "UTENTE:"; ////ws.Cells[1, 2].Value = Session["User"].ToString(); //ws.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); //ws.Cells["B1"].Style.Font.Color.SetColor(System.Drawing.Color.White); //ws.Cells["B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray); #endregion Byte[] fileBytes = pck.GetAsByteArray(); Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=RicercaDealer.xlsx"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); Response.BinaryWrite(fileBytes); Response.End(); } }