protected void btnLogin_Click(object sender, EventArgs e) { User user = ConnectionClass.LoginUser(txtLogin.Text, txtPassword.Text); if (user != null) { //Store login variables in session Session["login"] = user.Name; Session["type"] = user.Type; Response.Redirect("~/Home.aspx"); } else { lblError.Text = "Login failed"; } }
protected void btnSave_Click(object sender, EventArgs e) { try { string type = txtType.Text; double price = Convert.ToDouble(txtPrice.Text); price = price / 100; string weight = txtWeight.Text; string image = "~/Imgs" + ddlImage.SelectedValue; Metals metals = new Metals(type, price, weight, image); ConnectionClass.AddMetal(metals); lblResult.Text = "Upload succesful!"; ClearTextFields(); } catch (Exception) { lblResult.Text = "Upload failed!"; } }
private void FillPage() { ArrayList metalsList = new ArrayList(); if (!IsPostBack) { metalsList = ConnectionClass.GetMetalsByType("%"); } else { metalsList = ConnectionClass.GetMetalsByType(DropDownList1.SelectedValue); } StringBuilder sb = new StringBuilder(); foreach (Metals metals in metalsList) { sb.Append( string.Format( @"<table class='metalsTable'> <tr> <th rowspan='4' width='150px'><img runat='server' src='{3}' /></th> <th width='50px'>type: </td> <td>{0} </td> </tr> <tr> <th>price: </th> <td>{1} $</td> </tr> <tr> <th>weight: </th> <td>{2} </td> </tr> </table>", metals.Type, metals.Price, metals.Weight, metals.Image)); lblOutput.Text = sb.ToString(); } }