using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Drawing; using System.Data.Sql; using System.Data.SqlClient; public partial class toodetevaatamine : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public Color taustavarv(int kogus) { if (kogus == 0) { return Color.Red; } if (kogus < 7) { return Color.Yellow; } return Color.LightGreen; } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { //Ostmispaneel nähtav ainult juhul, kui kasutaja on sisse logitud. Panel1.Visible = HttpContext.Current.User.Identity.IsAuthenticated; } public void SalvestaOst(object allikas, EventArgs e) { SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings ["veebipoebaasConnectionString"].ConnectionString); SqlCommand cm=new SqlCommand("INSERT INTO ostud (kasutajaID, "+ " tooteID, kogus) VALUES (@kid, @tid, @k)",cn); cn.Open(); cm.Parameters.AddWithValue("kid", Membership.GetUser( HttpContext.Current.User.Identity.Name).ProviderUserKey); cm.Parameters.AddWithValue("tid", GridView1.SelectedValue); cm.Parameters.AddWithValue("k", Convert.ToInt32(tbkogus.Text)); cm.ExecuteNonQuery(); cn.Close(); tbkogus.Text = "0"; } }