protected void grdFornitori_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "SCHEDA": { clsParameter pParameter = new clsParameter(); string DCID = grdFornitori.DataKeys[e.Item.ItemIndex].ToString(); string URL = "PrintScheda.aspx?FORCODICE=" + DCID + "&ANNO=" + cboAnno.SelectedValue + "&MESE=" + cboMese.SelectedValue + ""; ((System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("PRINTReport")).Attributes.Add("src", URL); break; } case "DETTAGLI": { string DCID = grdFornitori.DataKeys[e.Item.ItemIndex].ToString(); lblTitle.Text = "Scheda Fornitore - VISUALIZZAZIONE DEI SERVIZI"; ViewState["SCHEDA"] = "NO"; ViewState["DCIDSELFILTRO"] = DCID; RWTotaliServizi.Visible = true; CaricaServiziCollegati("", DCID); break; } } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtAccount.Text = gridData.Items[e.Item.ItemIndex].Cells[1].Text.Replace(" ", "").Trim(); txtNome.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtCognome.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); txtLogin.Text = gridData.Items[e.Item.ItemIndex].Cells[4].Text.Replace(" ", "").Trim(); txtPassword.Text = gridData.Items[e.Item.ItemIndex].Cells[5].Text.Replace(" ", "").Trim(); for (int i = 0; i <= cboColore.Items.Count - 1; i++) { if (cboColore.Items[i].Value == gridData.Items[e.Item.ItemIndex].Cells[6].Text) { cboColore.SelectedIndex = i; break; } } ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtAccount, this.Page); Link_Load_Collegati(gridData.DataKeys[e.Item.ItemIndex].ToString()); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ADMIN_UTENTI WHERE IDUTENTE=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "DELETE FROM Admin_UtentiGruppi WHERE IDUTENTE=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
protected void cboColore_SelectedIndexChanged(object sender, EventArgs e) { //CAMBIO COLORE UTENTE clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", ((clsSession)Session["GreenApple"]).IDUtente, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLORE", cboColore.SelectedValue, SqlDbType.Int, ParameterDirection.Input)); string sql = "UPDATE ADMIN_UTENTI " + " SET COLORE = @COLORE " + " WHERE IDUTENTE = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); Response.Redirect("Home.aspx"); }
protected void lnkSerAggiorna_Click(object sender, EventArgs e) { //AGGIORNAMENTO DEL SERVIZIO bool ShowError = false; clsParameter pParameter = new clsParameter(); //pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SRfatturafor", txtSerFatturaFor.Text, SqlDbType.NVarChar, ParameterDirection.Input)); //if (txtSerDataFatturaFor.Text != "") //{ // pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SRdatafatturafor", txtSerDataFatturaFor.Text, SqlDbType.DateTime, ParameterDirection.Input)); //} //else //{ // pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SRdatafatturafor", System.DBNull.Value, SqlDbType.DateTime, ParameterDirection.Input)); //} pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SRAnnoFatt", cboSerAnno.SelectedValue, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SRMeseFatt", cboSerMese.SelectedValue, SqlDbType.SmallInt, ParameterDirection.Input)); ShowError = false; sql = @"UPDATE Servizi SET SRAnnoFatt = @SRAnnoFatt, SRMeseFatt = @SRMeseFatt WHERE SRcodice = " + ViewState["SERSEL"].ToString() + @" "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaServizioVisible = false; CaricaServiziCollegati(""); grdServizi.SelectedIndex = -1; RWANNULLASCHEDA.Visible = true; grdServizi.Visible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Dettaglio; }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtCodice.Text = gridData.Items[e.Item.ItemIndex].Cells[1].Text.Replace(" ", "").Trim(); txtDescrizione.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtNumRate.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); txtGiorni.Text = gridData.Items[e.Item.ItemIndex].Cells[4].Text.Replace(" ", "").Trim(); chkFM.Checked = Convert.ToBoolean(gridData.Items[e.Item.ItemIndex].Cells[5].Text); chkRIBA.Checked = Convert.ToBoolean(gridData.Items[e.Item.ItemIndex].Cells[6].Text); chkBB.Checked = Convert.ToBoolean(gridData.Items[e.Item.ItemIndex].Cells[7].Text); chkRD.Checked = Convert.ToBoolean(gridData.Items[e.Item.ItemIndex].Cells[8].Text); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtDescrizione, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ModalitaPagamento WHERE IDModalita=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); break; } } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RAGSOC", txtRAGSOC.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@INDIRIZZO", txtINDIRIZZO.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@CAP", txtCAP.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@LOCALITA", txtLOCALITA.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NAZIONE", txtNAZIONE.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@PIVA", txtPIVA.Text, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@AliquotaIVA", txtIVAAPPLICATA.Text, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE Admin_DatiAnagrifici " + " SET RAGSOC = @RAGSOC " + ",INDIRIZZO = @INDIRIZZO " + ",CAP = @CAP " + ",LOCALITA = @LOCALITA " + ",NAZIONE = @NAZIONE " + ",AliquotaIVA = @AliquotaIVA " + ",PIVA = @PIVA "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); //togliere automatismo per IVA //sql = "UPDATE fornitori " //+ " SET forperciva = @AliquotaIVA "; //clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE clienti " + " SET cliperciva = @AliquotaIVA "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtID.Text = gridData.Items[e.Item.ItemIndex].Cells[0].Text.Replace(" ", "").Trim(); txtNazione.Text = gridData.Items[e.Item.ItemIndex].Cells[1].Text.Replace(" ", "").Trim(); txtIVA.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtMessaggio.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtMessaggio, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.NVarChar, ParameterDirection.Input)); } sql = "DELETE FROM " + TABLENAME + " WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
public IHttpActionResult addProductToCart([FromUri] clsParameter contents) { try { string dbconn = ConfigurationManager.ConnectionStrings["DBconnection"].ConnectionString; SqlConnection sqlconn = new SqlConnection(dbconn); string sqlquery = "[AddProductToCart]"; sqlconn.Open(); SqlCommand sqlcmd = new SqlCommand(sqlquery, sqlconn); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add(new SqlParameter("@ProductID", contents.ID)); sqlcmd.Parameters.Add(new SqlParameter("@UnitsAdded", contents.unitsAdded)); SqlDataReader sdr = sqlcmd.ExecuteReader(); } catch (Exception e) { return(Ok("Error" + e.Message)); } return(Ok("success")); }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtGruppo.Text = gridData.Items[e.Item.ItemIndex].Cells[1].Text.Replace(" ", "").Trim(); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtGruppo, this.Page); Link_Load_Collegati(gridData.DataKeys[e.Item.ItemIndex].ToString()); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ADMIN_GRUPPI WHERE IDGRUPPO=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "DELETE FROM Admin_UtentiGruppi WHERE IDGRUPPO=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "DELETE FROM Admin_GruppiMenu WHERE IDGRUPPO=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtNome.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); txtDescrizione.Text = gridData.Items[e.Item.ItemIndex].Cells[4].Text.Replace(" ", "").Trim(); if (gridData.Items[e.Item.ItemIndex].Cells[1].Text.Contains("icoConfirm")) { //NEWS APERTA chkChiusa.Checked = false; } else { //NEWS CHIUSA chkChiusa.Checked = true; } ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtNome, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ADMIN_NEWS WHERE IDNEWS=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "DOWN": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE ADMIN_NEWS SET POSIZIONE = POSIZIONE + 1 WHERE IDNEWS = @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_NEWS SET POSIZIONE = POSIZIONE - 1 "; sql += "WHERE POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_NEWS WHERE IDNEWS = @COLUMNID) AND IDNEWS <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "UP": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE ADMIN_NEWS SET POSIZIONE = POSIZIONE - 1 WHERE IDNEWS = @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_NEWS SET POSIZIONE = POSIZIONE + 1 "; sql += "WHERE POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_NEWS WHERE IDNEWS = @COLUMNID) AND IDNEWS <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Nome = txtNome.Text.Trim(); string Descrizione = txtDescrizione.Text.Trim(); bool Chiusa = chkChiusa.Checked; switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM ADMIN_NEWS WHERE TITOLO = '" + Nome + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DATA", DateTime.Now, SqlDbType.DateTime, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@CHIUSA", Chiusa, SqlDbType.Bit, ParameterDirection.Input)); sql = "INSERT INTO ADMIN_NEWS (TITOLO,DESCRIZIONE,DATA,CHIUSA) " + " VALUES(@NOME,@DESCRIZIONE,@DATA,@CHIUSA) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_NEWS " + " SET POSIZIONE = (SELECT ISNULL(MAX(POSIZIONE)+1,1) FROM ADMIN_NEWS) WHERE TITOLO = '" + Nome + "' "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; sql = "SELECT * FROM ADMIN_NEWS WHERE TITOLO = '" + Nome + "' "; sql += " AND IDNEWS <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DATA", DateTime.Now, SqlDbType.DateTime, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@CHIUSA", Chiusa, SqlDbType.Bit, ParameterDirection.Input)); sql = "UPDATE ADMIN_NEWS " + " SET TITOLO = @NOME " + ",DESCRIZIONE = @DESCRIZIONE " + ",DATA = @DATA " + ",CHIUSA = @CHIUSA " + " WHERE IDNEWS = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già una News con lo stesso titolo."; lblError.Visible = true; } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ViewState["INMODIFICA"] = "SI"; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtElemento.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtPosizione.Text = gridData.Items[e.Item.ItemIndex].Cells[1].Text.Replace(" ", "").Trim(); txtPercCompenso.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); chkDifferita.Checked = bool.Parse(gridData.Items[e.Item.ItemIndex].Cells[4].Text); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtElemento, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.NVarChar, ParameterDirection.Input)); } sql = "DELETE FROM " + TABLENAME + " WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); break; } case "DOWN": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE " + TABLENAME + " SET " + COLUMNORDER + " = " + COLUMNORDER + "+1 WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE " + TABLENAME + " SET " + COLUMNORDER + " = " + COLUMNORDER + " - 1 "; sql += "WHERE " + COLUMNORDER + " IN (SELECT " + COLUMNORDER + " FROM " + TABLENAME + " WHERE " + COLUMNID + " = @COLUMNID) AND " + COLUMNID + " <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); break; } case "UP": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE " + TABLENAME + " SET " + COLUMNORDER + " = " + COLUMNORDER + "-1 WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE " + TABLENAME + " SET " + COLUMNORDER + " = " + COLUMNORDER + " + 1 "; sql += "WHERE " + COLUMNORDER + " IN (SELECT " + COLUMNORDER + " FROM " + TABLENAME + " WHERE " + COLUMNID + " = @COLUMNID) AND " + COLUMNID + " <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); break; } } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Elemento = txtElemento.Text.Trim(); string Posizione = txtPosizione.Text.Trim(); string Compenso = txtPercCompenso.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM " + TABLENAME + " WHERE " + COLUMNDESCR + "='" + Elemento + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ELEMENTO", Elemento, SqlDbType.NVarChar, ParameterDirection.Input)); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.NVarChar, ParameterDirection.Input)); } pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COMPENSO", Compenso, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@FatturaRifferita", chkDifferita.Checked, SqlDbType.Bit, ParameterDirection.Input)); sql = "INSERT INTO " + TABLENAME + "(" + COLUMNDESCR + "," + COLUMNORDER + "," + COLPERCCOMPENSO + ",FatturaRifferita) " + " VALUES(@ELEMENTO,@POSIZIONE,@COMPENSO,@FatturaRifferita) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; gridData.SelectedIndex = -1; CaricaDati(); } else { ShowError = true; } break; } } if (ViewState["INMODIFICA"].ToString() == "SI") { ShowError = false; if (CheckUnivocita) { sql = "SELECT * FROM " + TABLENAME + " WHERE " + COLUMNDESCR + "='" + Elemento + "' "; sql += " AND " + COLUMNID + " <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ELEMENTO", Elemento, SqlDbType.NVarChar, ParameterDirection.Input)); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); } if (NvarcharPOS == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.NVarChar, ParameterDirection.Input)); } pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COMPENSO", Compenso, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@FatturaRifferita", chkDifferita.Checked, SqlDbType.Bit, ParameterDirection.Input)); sql = "UPDATE " + TABLENAME + " " + " SET " + COLUMNDESCR + " = @ELEMENTO " + "," + COLUMNORDER + " = @POSIZIONE " + "," + COLPERCCOMPENSO + " = @COMPENSO " + ",FatturaRifferita=@FatturaRifferita " + " WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ViewState["INMODIFICA"] = "NO"; ModificaVisible = false; gridData.SelectedIndex = -1; CaricaDati(); } } if (ShowError) { lblError.Text = "Esite già un " + NOMEOGGETTO + " con lo stesso nome."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Account = txtAccount.Text.Trim(); string Nome = txtNome.Text.Trim(); string Cognome = txtCognome.Text.Trim(); string Login = txtLogin.Text.Trim(); string Password = txtPassword.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { if (Account != "") { sql = "SELECT * FROM ADMIN_UTENTI WHERE ACCOUNT = '" + Account + "' "; } else { sql = "SELECT * FROM ADMIN_UTENTI WHERE LOGIN = '******' "; } DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ACCOUNT", Account, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COGNOME", Cognome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@LOGIN", Login, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@PASSWORD", Password, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLORE", cboColore.SelectedValue, SqlDbType.Int, ParameterDirection.Input)); sql = "INSERT INTO ADMIN_UTENTI (ACCOUNT,NOME,COGNOME,LOGIN,PASSWORD,COLORE) " + " VALUES(@ACCOUNT,@NOME,@COGNOME,@LOGIN,@PASSWORD,@COLORE) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; if (Account != "") { sql = "SELECT * FROM ADMIN_UTENTI WHERE ACCOUNT = '" + Account + "' "; sql += " AND IDUTENTE <> " + gridData.DataKeys[gridData.SelectedIndex]; } else { sql = "SELECT * FROM ADMIN_UTENTI WHERE LOGIN = '******' "; sql += " AND IDUTENTE <> " + gridData.DataKeys[gridData.SelectedIndex]; } DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ACCOUNT", Account, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COGNOME", Cognome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@LOGIN", Login, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@PASSWORD", Password, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLORE", cboColore.SelectedValue, SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE ADMIN_UTENTI " + " SET ACCOUNT = @ACCOUNT " + ",NOME = @NOME " + ",COGNOME = @COGNOME " + ",LOGIN = @LOGIN " + ",PASSWORD = @PASSWORD " + ",COLORE = @COLORE " + " WHERE IDUTENTE = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); Save_Link_Load_Collegati(gridData.DataKeys[gridData.SelectedIndex].ToString()); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già un Utente con lo stesso account."; lblError.Visible = true; } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtVoce.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtGruppo.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); txtSimpleList.Checked = bool.Parse(gridData.Items[e.Item.ItemIndex].Cells[4].Text); txtTabella.Text = gridData.Items[e.Item.ItemIndex].Cells[5].Text.Replace(" ", "").Trim(); txtPagina.Text = gridData.Items[e.Item.ItemIndex].Cells[6].Text.Replace(" ", "").Trim(); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtVoce, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ADMIN_MENU WHERE IDMENU=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "DOWN": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", e.Item.Cells[3].Text, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE ADMIN_MENU SET POSIZIONE = POSIZIONE+1 WHERE IDMENU=@COLUMNID AND GRUPPO=@GRUPPO"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_MENU SET POSIZIONE = POSIZIONE - 1 "; sql += "WHERE GRUPPO=@GRUPPO AND POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_MENU WHERE IDMENU = @COLUMNID) AND IDMENU <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "UP": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", e.Item.Cells[3].Text, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE ADMIN_MENU SET POSIZIONE = POSIZIONE-1 WHERE IDMENU=@COLUMNID AND GRUPPO=@GRUPPO"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_MENU SET POSIZIONE = POSIZIONE + 1 "; sql += "WHERE GRUPPO=@GRUPPO AND POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_MENU WHERE IDMENU = @COLUMNID) AND IDMENU <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Gruppo = txtGruppo.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM ADMIN_GRUPPI WHERE GRUPPO = '" + Gruppo + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", Gruppo, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "INSERT INTO ADMIN_GRUPPI (GRUPPO) " + " VALUES(@GRUPPO) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; sql = "SELECT * FROM ADMIN_GRUPPI WHERE GRUPPO ='" + Gruppo + "' "; sql += " AND IDGRUPPO <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", Gruppo, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE ADMIN_GRUPPI " + " SET GRUPPO = @GRUPPO " + " WHERE IDGRUPPO = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); Save_Link_Load_Collegati(gridData.DataKeys[gridData.SelectedIndex].ToString()); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già un Gruppo con lo stesso account."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Nome = txtNome.Text.Trim(); string Descrizione = txtDescrizione.Text.Trim(); string Query = txtQuery.Text.Trim(); string myDataColumn = txtColumnData.Text; string Righe = txtRighe.Text; if (Righe == "") { Righe = "100"; } switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM ADMIN_REPORT WHERE NOME = '" + Nome + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@QUERY", Query, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DATACOLUMN", myDataColumn, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RowPerPage", Righe, SqlDbType.Int, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ExportFile", chkExport.Checked, SqlDbType.Bit, ParameterDirection.Input)); sql = "INSERT INTO ADMIN_REPORT (NOME,DESCRIZIONE,QUERY,DATACOLUMN,RowPerPage,ExportFile) " + " VALUES(@NOME,@DESCRIZIONE,@QUERY,@DATACOLUMN,@RowPerPage,@ExportFile) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_REPORT " + " SET POSIZIONE = (SELECT ISNULL(MAX(POSIZIONE)+1,1) FROM ADMIN_REPORT) WHERE NOME = '" + Nome + "' "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; sql = "SELECT * FROM ADMIN_REPORT WHERE NOME = '" + Nome + "' "; sql += " AND IDREPORT <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NOME", Nome, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@QUERY", Query, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DATACOLUMN", myDataColumn, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RowPerPage", Righe, SqlDbType.Int, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ExportFile", chkExport.Checked, SqlDbType.Bit, ParameterDirection.Input)); sql = "UPDATE ADMIN_REPORT " + " SET NOME = @NOME " + ",DESCRIZIONE = @DESCRIZIONE " + ",QUERY = @QUERY " + ",DATACOLUMN = @DATACOLUMN " + ",RowPerPage = @RowPerPage " + ",ExportFile = @ExportFile " + " WHERE IDREPORT = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); Save_Link_Load_Collegati(gridData.DataKeys[gridData.SelectedIndex].ToString()); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già un Report con lo stesso nome."; lblError.Visible = true; } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; txtNome.Text = gridData.Items[e.Item.ItemIndex].Cells[2].Text.Replace(" ", "").Trim(); txtDescrizione.Text = gridData.Items[e.Item.ItemIndex].Cells[3].Text.Replace(" ", "").Trim(); txtQuery.Text = gridData.Items[e.Item.ItemIndex].Cells[4].Text.Replace(" ", "").Trim(); txtColumnData.Text = gridData.Items[e.Item.ItemIndex].Cells[5].Text.Replace(" ", "").Trim(); txtRighe.Text = gridData.Items[e.Item.ItemIndex].Cells[6].Text.Replace(" ", "").Trim(); bool EXPORTF = false; try { EXPORTF = Convert.ToBoolean(gridData.Items[e.Item.ItemIndex].Cells[7].Text.Replace(" ", "").Trim()); } catch { } chkExport.Checked = EXPORTF; Link_Load_Collegati(gridData.DataKeys[e.Item.ItemIndex].ToString()); ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtNome, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM ADMIN_REPORT WHERE IDREPORT=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "DOWN": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE ADMIN_REPORT SET POSIZIONE = POSIZIONE+1 WHERE IDREPORT=@COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_REPORT SET POSIZIONE = POSIZIONE - 1 "; sql += "WHERE POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_REPORT WHERE IDREPORT = @COLUMNID) AND IDREPORT <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } case "UP": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "UPDATE ADMIN_REPORT SET POSIZIONE = POSIZIONE-1 WHERE IDREPORT=@COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_REPORT SET POSIZIONE = POSIZIONE + 1 "; sql += "WHERE POSIZIONE IN (SELECT POSIZIONE FROM ADMIN_REPORT WHERE IDREPORT = @COLUMNID) AND IDREPORT <> @COLUMNID "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; break; } } }
protected void gridData_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "MODIFICA": { ViewState["MODFORN"] = "SI"; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; gridData.SelectedIndex = e.Item.ItemIndex; string IDCliente = gridData.DataKeys[e.Item.ItemIndex].ToString(); sql = "SELECT * FROM FORNITORI "; sql += " WHERE Forcodice = '" + IDCliente + "' "; DataTable DTResult = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "RESULT", ref DTResult, true); ViewState["IDMOD"] = IDCliente.ToString(); if (DTResult.Rows.Count > 0) { DataRow myRow = DTResult.Rows[0]; txtForprenome.Text = "" + myRow["Forprenome"].ToString(); txtForragsoc.Text = "" + myRow["Forragsoc"].ToString(); txtForindirizzo.Text = "" + myRow["Forindirizzo"].ToString(); txtForlocalita.Text = "" + myRow["Forlocalita"].ToString(); txtForprovincia.Text = "" + myRow["Forprovincia"].ToString(); txtForCAP.Text = "" + myRow["ForCAP"].ToString(); txtForNazione.Text = myRow["ForNazione"].ToString(); txtForpostaragsoc.Text = "" + myRow["Forpostaragsoc"].ToString(); txtForpostaind.Text = "" + myRow["Forpostaind"].ToString(); txtForpostaloc.Text = "" + myRow["Forpostaloc"].ToString(); txtForpostCAP.Text = "" + myRow["ForpostCAP"].ToString(); txtForPostaNazione.Text = "" + myRow["ForPostaNazione"].ToString(); txtForPostaProv.Text = "" + myRow["ForPostaProv"].ToString(); txtFortelef.Text = "" + myRow["Fortelef"].ToString(); txtForEmail.Text = "" + myRow["ForEmail"].ToString(); txtForNote.Text = "" + myRow["GANote"].ToString(); txtForfax.Text = "" + myRow["Forfax"].ToString(); txtForIVA.Text = "" + myRow["ForIVA"].ToString(); txtForCF.Text = "" + myRow["ForCF"].ToString(); txtFordatanascita.Text = "" + myRow["Fordatanascita"].ToString(); txtForluogonascita.Text = "" + myRow["Forluogonascita"].ToString(); txtForpagamento.Text = "" + myRow["Forpagamento"].ToString(); txtForbanca.Text = "" + myRow["Forbanca"].ToString(); txtForPiazza.Text = "" + myRow["ForPiazza"].ToString(); txtForpercIVA.Text = "" + myRow["ForpercIVA"].ToString(); txtForpercritenuta.Text = "" + myRow["Forpercritenuta"].ToString(); txtForpercacconto.Text = "" + myRow["Forpercacconto"].ToString(); txtForpercsuacconto.Text = "" + myRow["Forpercsuacconto"].ToString(); txtForperc1.Text = "" + myRow["Forperc1"].ToString(); txtForperc2.Text = "" + myRow["Forperc2"].ToString(); txtForperc3.Text = "" + myRow["Forperc3"].ToString(); txtForperc4.Text = "" + myRow["Forperc4"].ToString(); txtForperc5.Text = "" + myRow["Forperc5"].ToString(); txtForperc6.Text = "" + myRow["Forperc6"].ToString(); txtForcat1.Text = "" + myRow["Forcat1"].ToString(); txtForcat2.Text = "" + myRow["Forcat2"].ToString(); txtForcat3.Text = "" + myRow["Forcat3"].ToString(); txtForcat4.Text = "" + myRow["Forcat4"].ToString(); txtForcat5.Text = "" + myRow["Forcat5"].ToString(); txtForcat6.Text = "" + myRow["Forcat6"].ToString(); txtForIBAN.Text = "" + myRow["ForIBAN"].ToString(); txtForPctRivPrev.Text = "" + myRow["ForPctRivPrev"].ToString(); txtForPagCodice.Text = "" + myRow["ForPagCodice"].ToString(); if (myRow["ForInUso"] != System.DBNull.Value) { txtForInUso.Checked = Convert.ToBoolean(myRow["ForInUso"]); } if (myRow["ForEsenzioneIvaArt15"] != System.DBNull.Value) { txtForEsenzioneIvaArt15.Checked = Convert.ToBoolean(myRow["ForEsenzioneIvaArt15"]); } if (myRow["Foroperatore"] != System.DBNull.Value) { txtForoperatore.Checked = Convert.ToBoolean(myRow["Foroperatore"]); } } ModificaVisible = true; ((clsSession)Session["GreenApple"]).AzioneCorrente = clsSession.AzioniPagina.Modifica; //clsFunctions.WriteGOTO_and_FOCUS("SectionEdit", txtForprenome, this.Page); break; } case "ELIMINA": { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[e.Item.ItemIndex], SqlDbType.Int, ParameterDirection.Input)); sql = "DELETE FROM FORNITORI WHERE Forcodice=@ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); break; } } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Codice = txtCodice.Text.Trim(); string Descrizione = txtDescrizione.Text.Trim(); string NumRate = txtNumRate.Text.Trim(); string Giorni = txtGiorni.Text.Trim(); bool FM = chkFM.Checked; bool RIBA = chkRIBA.Checked; bool BB = chkBB.Checked; bool RD = chkRD.Checked; switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM ModalitaPagamento WHERE CODICE = '" + Codice + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@CODICE", Codice, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NUMRATE", NumRate, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GIORNI", Giorni, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@FM", FM, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RIBA", RIBA, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@BB", BB, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RD", RD, SqlDbType.Bit, ParameterDirection.Input)); sql = "INSERT INTO ModalitaPagamento (CODICE,DESCRIZIONE,NUMRATE,GIORNI,FM,RIBA,BB,RD) " + " VALUES(@CODICE,@DESCRIZIONE,@NUMRATE,@GIORNI,@FM,@RIBA,@BB,@RD) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; sql = "SELECT * FROM ModalitaPagamento WHERE CODICE = '" + Codice + "' "; sql += " AND IDModalita <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@CODICE", Codice, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@DESCRIZIONE", Descrizione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NUMRATE", NumRate, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GIORNI", Giorni, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@FM", FM, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RIBA", RIBA, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@BB", BB, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@RD", RD, SqlDbType.Bit, ParameterDirection.Input)); sql = "UPDATE ModalitaPagamento " + " SET CODICE = @CODICE " + ",DESCRIZIONE = @DESCRIZIONE " + ",NUMRATE = @NUMRATE " + ",GIORNI = @GIORNI " + ",FM = @FM " + ",RIBA = @RIBA " + ",BB = @BB " + ",RD = @RD " + " WHERE IDMODALITA = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); ModificaVisible = false; CaricaDati(); gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già una Modalità di Pagamento con lo stesso Codice."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string ID = txtID.Text.Trim(); string Iva = txtIVA.Text.Trim(); string Nazione = txtNazione.Text.Trim(); string Messaggio = txtMessaggio.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM " + TABLENAME + " WHERE " + COLUMNID + "='" + ID + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@IVA", Iva, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NAZIONE", Nazione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@MESSAGGIO", Messaggio, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "INSERT INTO " + TABLENAME + "(" + COLUMNIVA + "," + COLUMNMESSAGE + "," + COLUMNNAZIONE + ") " + " VALUES(@IVA,@MESSAGGIO,@NAZIONE) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@IVA", Iva, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@NAZIONE", Nazione, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@MESSAGGIO", Messaggio, SqlDbType.NVarChar, ParameterDirection.Input)); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); } sql = "UPDATE " + TABLENAME + " " + " SET " + COLUMNMESSAGE + " = @MESSAGGIO " + "," + COLUMNNAZIONE + " = @NAZIONE " + "," + COLUMNIVA + " = @IVA " + " WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già un " + NOMEOGGETTO + " con lo stesso nome."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Iban = txtIban.Text.Trim(); string Swift = txtSwift.Text.Trim(); string Elemento = txtElemento.Text.Trim(); string Posizione = txtPosizione.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM " + TABLENAME + " WHERE " + COLUMNDESCR + "='" + Elemento + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@IBAN", Iban, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SWIFT", Swift, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ELEMENTO", Elemento, SqlDbType.NVarChar, ParameterDirection.Input)); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.NVarChar, ParameterDirection.Input)); } sql = "INSERT INTO " + TABLENAME + "(" + COLUMNIBAN + "," + COLUMNDESCR + "," + COLUMNORDER + "," + COLUMNSWIFT + ") " + " VALUES(@IBAN,@ELEMENTO,@POSIZIONE,@SWIFT) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@IBAN", Iban, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SWIFT", Swift, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ELEMENTO", Elemento, SqlDbType.NVarChar, ParameterDirection.Input)); if (NvarcharID == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@COLUMNID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); } if (NvarcharPOS == false) { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.Int, ParameterDirection.Input)); } else { pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@POSIZIONE", Posizione, SqlDbType.NVarChar, ParameterDirection.Input)); } sql = "UPDATE " + TABLENAME + " " + " SET " + COLUMNDESCR + " = @ELEMENTO " + "," + COLUMNORDER + " = @POSIZIONE " + "," + COLUMNSWIFT + " = @SWIFT " + "," + COLUMNIBAN + " = @IBAN " + " WHERE " + COLUMNID + "=@COLUMNID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già un " + NOMEOGGETTO + " con lo stesso nome."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; object ForPctRivPrev = txtForPctRivPrev.Text.Trim(); object Forperc1 = txtForperc1.Text.Trim(); object Forperc2 = txtForperc2.Text.Trim(); object Forperc3 = txtForperc3.Text.Trim(); object Forperc4 = txtForperc4.Text.Trim(); object Forperc5 = txtForperc5.Text.Trim(); object Forperc6 = txtForperc6.Text.Trim(); object ForpercIVA = txtForpercIVA.Text.Trim(); object Forpercritenuta = txtForpercritenuta.Text.Trim(); object Forpercacconto = txtForpercacconto.Text.Trim(); object Forpercsuacconto = txtForpercsuacconto.Text.Trim(); object Fordatanascita = txtFordatanascita.Text.Trim(); object ForpostCAP = txtForpostCAP.Text.Trim(); object ForCAP = txtForCAP.Text.Trim(); if (ForPctRivPrev.ToString() == "") { ForPctRivPrev = System.DBNull.Value; } if (Forperc1.ToString() == "") { Forperc1 = System.DBNull.Value; } if (Forperc2.ToString() == "") { Forperc2 = System.DBNull.Value; } if (Forperc3.ToString() == "") { Forperc3 = System.DBNull.Value; } if (Forperc4.ToString() == "") { Forperc4 = System.DBNull.Value; } if (Forperc5.ToString() == "") { Forperc5 = System.DBNull.Value; } if (Forperc6.ToString() == "") { Forperc6 = System.DBNull.Value; } if (ForpercIVA.ToString() == "") { ForpercIVA = System.DBNull.Value; } if (Forpercritenuta.ToString() == "") { Forpercritenuta = System.DBNull.Value; } if (Forpercacconto.ToString() == "") { Forpercacconto = System.DBNull.Value; } if (Forpercsuacconto.ToString() == "") { Forpercsuacconto = System.DBNull.Value; } if (Fordatanascita.ToString() == "") { Fordatanascita = System.DBNull.Value; } if (ForpostCAP.ToString() == "") { ForpostCAP = System.DBNull.Value; } if (ForCAP.ToString() == "") { ForCAP = System.DBNull.Value; } clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forprenome", txtForprenome.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forragsoc", txtForragsoc.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forindirizzo", txtForindirizzo.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forlocalita", txtForlocalita.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forprovincia", txtForprovincia.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForCAP", ForCAP, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForNazione", txtForNazione.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpostaragsoc", txtForpostaragsoc.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpostaind", txtForpostaind.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpostaloc", txtForpostaloc.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForpostCAP", ForpostCAP, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForPostaNazione", txtForPostaNazione.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForPostaProv", txtForPostaProv.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Fortelef", txtFortelef.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForEmail", txtForEmail.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GANote", txtForNote.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forfax", txtForfax.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForIVA", txtForIVA.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForCF", txtForCF.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Fordatanascita", Fordatanascita, SqlDbType.DateTime, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forluogonascita", txtForluogonascita.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpagamento", txtForpagamento.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forbanca", txtForbanca.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForPiazza", txtForPiazza.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForpercIVA", txtForpercIVA.Text.Trim(), SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpercritenuta", txtForpercritenuta.Text.Trim(), SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpercacconto", Forpercacconto, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forpercsuacconto", Forpercsuacconto, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc1", Forperc1, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc2", Forperc2, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc3", Forperc3, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc4", Forperc4, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc5", Forperc5, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forperc6", Forperc6, SqlDbType.SmallInt, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Foroperatore", txtForoperatore.Checked, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat1", txtForcat1.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat2", txtForcat2.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat3", txtForcat3.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat4", txtForcat4.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat5", txtForcat5.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@Forcat6", txtForcat6.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForIBAN", txtForIBAN.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForEsenzioneIvaArt15", txtForEsenzioneIvaArt15.Checked, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForPctRivPrev", ForPctRivPrev, SqlDbType.Real, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForPagCodice", txtForPagCodice.Text.Trim(), SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ForInUso", txtForInUso.Checked, SqlDbType.Bit, ParameterDirection.Input)); if (ViewState["IDMOD"].ToString() == "") { sql = "SELECT * FROM FORNITORI WHERE Forragsoc = '" + txtForragsoc.Text + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { //INSERIMENTO sql = @"INSERT INTO FORNITORI ( Forprenome ,Forragsoc ,Forindirizzo ,Forlocalita ,Forprovincia ,ForCAP ,ForNazione ,Forpostaragsoc ,Forpostaind ,Forpostaloc ,ForpostCAP ,ForPostaNazione ,ForPostaProv ,Fortelef,ForEmail,GANote ,Forfax ,ForIVA ,ForCF ,Fordatanascita ,Forluogonascita ,Forpagamento ,Forbanca ,ForPiazza ,ForpercIVA ,Forpercritenuta ,Forpercacconto ,Forpercsuacconto ,Forperc1 ,Forperc2 ,Forperc3 ,Forperc4 ,Forperc5 ,Forperc6 ,Foroperatore ,Forcat1 ,Forcat2 ,Forcat3 ,Forcat4 ,Forcat5 ,Forcat6 ,ForIBAN ,ForEsenzioneIvaArt15 ,ForPctRivPrev ,ForPagCodice ,ForInUso ) VALUES( @Forprenome ,@Forragsoc ,@Forindirizzo ,@Forlocalita ,@Forprovincia ,@ForCAP ,@ForNazione ,@Forpostaragsoc ,@Forpostaind ,@Forpostaloc ,@ForpostCAP ,@ForPostaNazione ,@ForPostaProv ,@Fortelef,@ForEmail,@GANote ,@Forfax ,@ForIVA ,@ForCF ,@Fordatanascita ,@Forluogonascita ,@Forpagamento ,@Forbanca ,@ForPiazza ,@ForpercIVA ,@Forpercritenuta ,@Forpercacconto ,@Forpercsuacconto ,@Forperc1 ,@Forperc2 ,@Forperc3 ,@Forperc4 ,@Forperc5 ,@Forperc6 ,@Foroperatore ,@Forcat1 ,@Forcat2 ,@Forcat3 ,@Forcat4 ,@Forcat5 ,@Forcat6 ,@ForIBAN ,@ForEsenzioneIvaArt15 ,@ForPctRivPrev ,@ForPagCodice ,@ForInUso ) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); if (((System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("divErroreBox")).Visible == false) { ModificaVisible = false; CaricaDati(); gridData.Visible = true; gridData.SelectedIndex = -1; } } else { ShowError = true; } } if (ViewState["IDMOD"].ToString() != "") { ShowError = false; //sql = "SELECT * FROM FORNITORI WHERE Forragsoc = '" + txtForragsoc.Text + "' "; //sql += " AND Forcodice <> " + gridData.DataKeys[gridData.SelectedIndex]; //DataTable DTCheck = new DataTable(); //clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); //if (DTCheck.Rows.Count > 0) //{ // ShowError = true; //} if (ShowError == false) { //AGGIORNAMENTO pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex].ToString(), SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE FORNITORI " + @" SET Forprenome = @Forprenome ,Forragsoc = @Forragsoc ,Forindirizzo = @Forindirizzo ,Forlocalita = @Forlocalita ,Forprovincia = @Forprovincia ,ForCAP = @ForCAP ,ForNazione = @ForNazione ,Forpostaragsoc = @Forpostaragsoc ,Forpostaind = @Forpostaind ,Forpostaloc = @Forpostaloc ,ForpostCAP = @ForpostCAP ,ForPostaNazione = @ForPostaNazione ,ForPostaProv = @ForPostaProv ,Fortelef = @Fortelef ,ForEmail = @ForEmail ,GANote = @GANote ,Forfax = @Forfax ,ForIVA = @ForIVA ,ForCF = @ForCF ,Fordatanascita = @Fordatanascita ,Forluogonascita = @Forluogonascita ,Forpagamento = @Forpagamento ,Forbanca = @Forbanca ,ForPiazza = @ForPiazza ,ForpercIVA = @ForpercIVA ,Forpercritenuta = @Forpercritenuta ,Forpercacconto = @Forpercacconto ,Forpercsuacconto = @Forpercsuacconto ,Forperc1 = @Forperc1 ,Forperc2 = @Forperc2 ,Forperc3 = @Forperc3 ,Forperc4 = @Forperc4 ,Forperc5 = @Forperc5 ,Forperc6 = @Forperc6 ,Foroperatore = @Foroperatore ,Forcat1 = @Forcat1 ,Forcat2 = @Forcat2 ,Forcat3 = @Forcat3 ,Forcat4 = @Forcat4 ,Forcat5 = @Forcat5 ,Forcat6 = @Forcat6 ,ForIBAN = @ForIBAN ,ForEsenzioneIvaArt15 = @ForEsenzioneIvaArt15 ,ForPctRivPrev = @ForPctRivPrev ,ForPagCodice = @ForPagCodice ,ForInUso = @ForInUso WHERE Forcodice = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); if (((System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("divErroreBox")).Visible == false) { ViewState["IDMOD"] = ""; ViewState["MODFORN"] = "NO"; ModificaVisible = false; CaricaDati(); gridData.Visible = true; gridData.SelectedIndex = -1; } } } if (ShowError) { lblError.Text = "Esite già un Fornitore con lo stesso nome."; lblError.Visible = true; } }
protected void lnkAggiorna_Click(object sender, EventArgs e) { bool ShowError = false; string Voce = txtVoce.Text.Trim(); string Gruppo = txtGruppo.Text.Trim(); bool SimpleList = txtSimpleList.Checked; string Tabella = txtTabella.Text.Trim(); string Pagina = txtPagina.Text.Trim(); switch (((clsSession)Session["GreenApple"]).AzioneCorrente) { case clsSession.AzioniPagina.Inserimento: { sql = "SELECT * FROM ADMIN_MENU WHERE VOCE = '" + Voce + "' "; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count == 0) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@VOCE", Voce, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", Gruppo, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SIMPLELIST", SimpleList, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@TABELLA", Tabella, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@PAGINA", Pagina, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "INSERT INTO ADMIN_MENU (VOCE,GRUPPO,SIMPLELIST,TABELLA,PAGINA) " + " VALUES(@VOCE,@GRUPPO,@SIMPLELIST,@TABELLA,@PAGINA) "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); sql = "UPDATE ADMIN_MENU " + " SET POSIZIONE = (SELECT ISNULL(MAX(POSIZIONE)+1,1) FROM ADMIN_MENU WHERE GRUPPO=@GRUPPO) WHERE VOCE = '" + Voce + "' "; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } else { ShowError = true; } break; } case clsSession.AzioniPagina.Modifica: { ShowError = false; sql = "SELECT * FROM ADMIN_MENU WHERE VOCE = '" + Voce + "' "; sql += " AND IDMENU <> " + gridData.DataKeys[gridData.SelectedIndex]; DataTable DTCheck = new DataTable(); clsDB.Load_DataTable(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, "CHECKESISTENZA", ref DTCheck, true); if (DTCheck.Rows.Count > 0) { ShowError = true; } if (ShowError == false) { clsParameter pParameter = new clsParameter(); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@ID", gridData.DataKeys[gridData.SelectedIndex], SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@VOCE", Voce, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@GRUPPO", Gruppo, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@SIMPLELIST", SimpleList, SqlDbType.Bit, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@TABELLA", Tabella, SqlDbType.NVarChar, ParameterDirection.Input)); pParameter.Parameters.Add(new clsParameter.MemberOfclsParameter("@PAGINA", Pagina, SqlDbType.NVarChar, ParameterDirection.Input)); sql = "UPDATE ADMIN_MENU " + " SET VOCE = @VOCE " + ",GRUPPO = @GRUPPO " + ",SIMPLELIST = @SIMPLELIST " + ",TABELLA = @TABELLA " + ",PAGINA = @PAGINA " + " WHERE IDMENU = @ID"; clsDB.Execute_Command_ClsParameter(this.Page, ((clsSession)Session["GreenApple"]).CnnStr, sql, pParameter.Parameters); CaricaDati(); ModificaVisible = false; gridData.SelectedIndex = -1; } break; } } if (ShowError) { lblError.Text = "Esite già una voce di menu con lo stesso nome."; lblError.Visible = true; } }