Details.aspx.cs
Details.aspxcodice:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.Sql; using System.Data.SqlClient; namespace AffiliationCMS { public partial class Details : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string LoginStatus = Request.Cookies["HasLogged"]["Status"].ToString(); if(LoginStatus !="1") { Response.Redirect("Login.aspx"); } } protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { string Username = Request.Cookies["HasLogged"]["Username"].ToString(); string Code = Guid.NewGuid().ToString(); SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = "localhost\\SQLExpress"; builder.InitialCatalog = "MioDB"; builder.IntegratedSecurity = true; SqlConnection conn = new SqlConnection(builder.ConnectionString); SqlCommand cmd = new SqlCommand("INSERT INTO UsersAffiliation(Data, Nome, Cognome, EmailSkrill, Referer, UserCode, chkTrade, chk24Option, chkEtoro, txtTrade, txtEtoro, txt24Option) values ('" + txtData.Text + "', '" + txtName.Text + "', '" + txtSurname.Text + "', '" + txtSkrillMail.Text + "', '" + Username + "', '" + Code + "', '" + chkTrade.SelectedValue.ToString() + "', '" + chk24Option.SelectedValue.ToString() + "', + '" + chkEtoro.SelectedValue.ToString() + "', '" + txtTrade.Text.ToString() + "', '" + txtEtoro.Text.ToString() + "', '" + txt24Option.Text.ToString() + "')", conn); conn.Open(); cmd.ExecuteNonQuery(); } } protected void chkEtoro_CheckedChanged(object sender, EventArgs e) { txtEtoro.Enabled = true; } protected void chk24Option_CheckedChanged(object sender, EventArgs e) { txt24Option.Enabled = true; } protected void chkTrade_CheckedChanged1(object sender, EventArgs e) { txtTrade.Enabled = true; } protected void chkTrade_SelectedIndexChanged(object sender, EventArgs e) { if(chkTrade.SelectedValue=="SI") { txtTrade.Enabled = true; } else { txtTrade.Enabled = false; } } protected void chkEtoro_SelectedIndexChanged(object sender, EventArgs e) { if(chkEtoro.SelectedValue =="SI") { txtEtoro.Enabled = true; } else { txtEtoro.Enabled = false; } } } }
codice:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Details.aspx.cs" Inherits="AffiliationCMS.Details" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <style type="text/css"> .auto-style1 { width: 210px; } .auto-style2 { width: 164px; } </style> <h1>AREA RISERVATA</h1> </head> <body> <form id="form1" runat="server"> <div> Benvenuto, <b><%=Request.Cookies["HasLogged"]["Username"] %></b> </div> <table style="width:70%;"> <tr> <td class="auto-style1">Data</td> <td class="auto-style2"> <asp:TextBox ID="txtData" runat="server" EnableViewState="False"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="validatorData" runat="server" ControlToValidate="txtData" ErrorMessage="Inserire la Data!"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style1">Nome</td> <td class="auto-style2"> <asp:TextBox ID="txtName" runat="server" EnableViewState="False"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="validatorName" runat="server" ControlToValidate="txtName" ErrorMessage="Inserire il Nome"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style1">Cognome</td> <td class="auto-style2"> <asp:TextBox ID="txtSurname" runat="server" EnableViewState="False"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="validatorSurname" runat="server" ControlToValidate="txtSurname" ErrorMessage="Inserire il Cognome!"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style1">Email Skrill</td> <td class="auto-style2"> <asp:TextBox ID="txtSkrillMail" runat="server" EnableViewState="False"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="validatorMail" runat="server" ControlToValidate="txtSkrillMail" ErrorMessage="Inserire la mail Skrill!"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style1"> </td> <td class="auto-style2"> </td> <td> </td> </tr> <tr> <td colspan="3"><center>BROKER</center></td> </tr> <tr> <td class="auto-style1"> <asp:ListBox ID="chkTrade" runat="server" Rows="1" OnSelectedIndexChanged="chkTrade_SelectedIndexChanged"> <asp:ListItem Value="SI">SI</asp:ListItem> <asp:ListItem Value="NO">NO</asp:ListItem> </asp:ListBox> Trade</td> <td class="auto-style2"> <asp:TextBox ID="txtTrade" runat="server" Enabled="False" EnableViewState="False"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="auto-style1"> <asp:ListBox ID="chkEtoro" runat="server" Rows="1" OnSelectedIndexChanged="chkEtoro_SelectedIndexChanged"> <asp:ListItem Value="SI">SI</asp:ListItem> <asp:ListItem Value="NO">NO</asp:ListItem> </asp:ListBox> Etoro</td> <td class="auto-style2"> <asp:TextBox ID="txtEtoro" runat="server" Enabled="False" EnableViewState="False"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="auto-style1"> <asp:ListBox ID="chk24Option" runat="server" Rows="1"> <asp:ListItem Value="SI">SI</asp:ListItem> <asp:ListItem Value="NO">NO</asp:ListItem> </asp:ListBox> 24Option</td> <td class="auto-style2"> <asp:TextBox ID="txt24Option" runat="server" Enabled="False" EnableViewState="False"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="auto-style1"> Rimborsato</td> <td class="auto-style2"> <asp:ListBox ID="chkRefund" runat="server" Rows="1"> <asp:ListItem Value="1">SI</asp:ListItem> <asp:ListItem Value="0">NO</asp:ListItem> </asp:ListBox> </td> <td> </td> </tr> <tr> <td class="auto-style1"> Rimborso</td> <td class="auto-style2"> <asp:TextBox ID="refundTxt" runat="server" EnableViewState="False"></asp:TextBox> </td> <td> </td> </tr> </table> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Inserisci" /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </form> </body> </html>

Rispondi quotando