Ejemplo n.º 1
0
        protected void LinkButton_Bestil_Click(object sender, EventArgs e)
        {
            Kurv test    = new Kurv();
            int  Kundeid = 3;

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
            SqlCommand    cmd  = new SqlCommand();

            cmd.Connection = conn;

            cmd.CommandText = @"INSERT INTO Ordrer (ordre_dato, ordre_status, FK_kunde_id) VALUES (GETDATE(), 1, @kundeid);
        SELECT SCOPE_IDENTITY()";
            cmd.Parameters.Add("@kundeid", SqlDbType.Int).Value = Kundeid;
            conn.Open();
            object OrdreId = cmd.ExecuteScalar();

            conn.Close();

            cmd.CommandText = @"INSERT INTO OrdreLinjer (FK_ordre_id, FK_produkt_id, antal, pris) VALUES (@ordreid, @produktid, @antal, @pris)";
            cmd.Parameters.Add("@ordreid", SqlDbType.Int).Value = OrdreId;
            cmd.Parameters.Add("@produktid", SqlDbType.VarChar);
            cmd.Parameters.Add("@antal", SqlDbType.Int);
            cmd.Parameters.Add("@pris", SqlDbType.Decimal);
            conn.Open();

            foreach (DataRow varenIKurven in test.get_kurv().Rows)
            {
                cmd.Parameters["@produktid"].Value = varenIKurven["produktid"];
                cmd.Parameters["@antal"].Value     = varenIKurven["antal"];
                cmd.Parameters["@pris"].Value      = varenIKurven["pris"];
                cmd.ExecuteNonQuery();
            }
            conn.Close();
            Response.Redirect("Samlede_ordrer.aspx");
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Kurv nyKurv = new Kurv();
         GridView1.DataSource = Session["kurv"];
         GridView1.DataBind();
         Label_PrisIAlt.Text = nyKurv.prisIalt(0).ToString();
     }
 }
Ejemplo n.º 3
0
        protected void GridView_VisVare_SelectedIndexChanged(object sender, EventArgs e)
        {
            string  varenr   = GridView_VisVare.SelectedRow.Cells[1].Text;
            TextBox TextBox1 = (TextBox)GridView_VisVare.SelectedRow.Cells[4].Controls[1];
            int     antal    = Convert.ToInt32(TextBox1.Text);

            Kurv minKurv = new Kurv();

            minKurv.RetVare(varenr, antal);
            Response.Redirect(Request.RawUrl);
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            TableCell cell = GridView1.Rows[e.RowIndex].Cells[1];

            string x = cell.Text;
            //Response.Write(x);
            Kurv minKurv = new Kurv();

            minKurv.SletVare(x);
            Response.Redirect("default.aspx");
        }
Ejemplo n.º 5
0
 protected void Repeater_vare_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "PutIKurv")
     {
         Kurv        minKurv    = new Kurv();
         HiddenField pris       = (HiddenField)e.Item.FindControl("HiddenField_pris");
         HiddenField navn       = (HiddenField)e.Item.FindControl("HiddenField_navn");
         HiddenField produktid  = (HiddenField)e.Item.FindControl("HiddenField_produktid");
         decimal     pris_con   = Convert.ToDecimal(pris.Value);
         int         produkt_id = Convert.ToInt32(produktid.Value);
         minKurv.PutiKurv(e.CommandArgument.ToString(), 1, pris_con, navn.Value, produkt_id);
         Response.Redirect(Request.RawUrl);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Kurv nyKurv = new Kurv();

            GridView1.DataSource = Session["kurv"];
            GridView1.DataBind();
            Label_prisIalt.Text = nyKurv.prisIalt(0).ToString();

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
            SqlCommand    cmd  = new SqlCommand();

            cmd.Connection = conn;

            if (!IsPostBack)
            {
                repeaterData();
            }
        }