protected void Page_Load(object sender, EventArgs e) { string tmp = Server.UrlDecode(Request.QueryString["EAN"]); OkPneuTireTable okTable = new OkPneuTireTable(); OkPneuTire tire = new OkPneuTire(); tire = okTable.Select(tmp); string labelTmp = tire.Name + " Prodejní cena " + tire.ProdejniCena; Label1.Text = labelTmp; }
public int Insert(OkPneuTire tire) { SchoolDatabase db = new SchoolDatabase(); db.Connect(); SqlCommand command = db.CreateCommand(SQL_INSERT); PrepareCommand(command, tire); int ret = db.ExecuteNonQuery(command); db.Close(); return ret; }
protected void GridViewCustomers_SelectedIndexChanged(object sender, EventArgs e) { int Empl_id = Int32.Parse(DropDownList1.SelectedValue.ToString()); int Cust_id = Int32.Parse(GridViewCustomers.SelectedValue.ToString()); string EAN = Server.UrlDecode(Request.QueryString["EAN"]); int count = Int32.Parse(TextBoxCount.Text); OkPneuTire tire = new OkPneuTire(); OkPneuTireTable okTable = new OkPneuTireTable(); tire = okTable.Select(EAN); decimal price = tire.ProdejniCena; OrderTable tb = new OrderTable(); int result = tb.InsertNewOrder(Cust_id, Empl_id, EAN, count, price); if(result > 0) Response.Redirect("~/Customers/Orders"); else Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Něco je špatně');", true); }
public OkPneuTire Select(string EAN) { SchoolDatabase db = new SchoolDatabase(); db.Connect(); SqlCommand command = db.CreateCommand(SQL_FIND_BY_EAN); command.Parameters.Add(new SqlParameter("@p_EAN", SqlDbType.VarChar, 14)); command.Parameters["@p_EAN"].Value = EAN; SqlDataReader reader = db.Select(command); reader.Read(); OkPneuTire tire = new OkPneuTire(); tire.Name = reader.GetString(0); tire.ProdejniCena = reader.GetDecimal(1); reader.Close(); db.Close(); return tire; }
private List<OkPneuTire> Read(SqlDataReader reader) { List<OkPneuTire> Tires = new List<OkPneuTire>(); while (reader.Read()) { OkPneuTire tire = new OkPneuTire(); tire.EAN = reader.GetString(0); tire.Manufacturer = reader.GetString(1); tire.Detail = reader.GetInt32(2); tire.ExternalStore = reader.GetInt32(3); tire.code = reader.GetString(4); tire.OnStore = reader.GetInt32(5); tire.ProdejniCena = (decimal) reader.GetSqlMoney(6); tire.Name = reader.GetString(7); tire.Season = reader.GetString(8); tire.Description = reader.GetString(9); tire.ImageURL = reader.GetString(10); Tires.Add(tire); } return Tires; }
private void PrepareCommand(SqlCommand command, OkPneuTire tire) { command.Parameters.Add(new SqlParameter("@p_EAN", SqlDbType.VarChar, 14)); command.Parameters["@p_EAN"].Value = tire.EAN; command.Parameters.Add(new SqlParameter("@p_manufacturer", SqlDbType.VarChar, 10)); command.Parameters["@p_manufacturer"].Value = tire.Manufacturer; command.Parameters.Add(new SqlParameter("@p_Size", SqlDbType.Int)); command.Parameters["@p_Size"].Value = tire.Detail; command.Parameters.Add(new SqlParameter("@p_ExternalStore", SqlDbType.Int)); command.Parameters["@p_ExternalStore"].Value = tire.OnStore; command.Parameters.Add(new SqlParameter("@p_code", SqlDbType.VarChar, 15)); command.Parameters["@p_code"].Value = tire.code; command.Parameters.Add(new SqlParameter("@p_Photo", SqlDbType.VarChar, 200)); command.Parameters["@p_Photo"].Value = tire.ImageURL; command.Parameters.Add(new SqlParameter("@p_Description", SqlDbType.VarChar, 2000)); command.Parameters["@p_Description"].Value = tire.Description; command.Parameters.Add(new SqlParameter("@p_OnStore", SqlDbType.Int)); command.Parameters["@p_OnStore"].Value = tire.OnStore; command.Parameters.Add(new SqlParameter("@p_Price", SqlDbType.Money)); command.Parameters["@p_Price"].Value = tire.ProdejniCena; command.Parameters.Add(new SqlParameter("@p_Name", SqlDbType.VarChar, 50)); command.Parameters["@p_Name"].Value = tire.Name; command.Parameters.Add(new SqlParameter("@p_season", SqlDbType.VarChar, 14)); command.Parameters["@p_season"].Value = tire.Season; }