protected void Page_Load(object sender, EventArgs e) {//trebuie sa aflu id-ul clientului ca sa stiu al cui cos e if (!Page.IsPostBack) { string connString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\vali\\Downloads\\mine-licenta\\licenta\\licenta\\App_Data\\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"; string query_id = "select ClientId from aspnet_Users where UserId='" + Membership.GetUser().ProviderUserKey + "' ;"; SqlConnection con = new SqlConnection(connString); SqlDataAdapter my_adapter = new SqlDataAdapter(query_id, con); DataSet dss = new DataSet(); my_adapter.Fill(dss, "user"); con.Close(); idClient = dss.Tables["user"].Rows[0][0].ToString(); RepeaterCart.DataSource = ShowCart(); RepeaterCart.DataBind(); Client master = (Client)Page.Master; if (master != null) { master.UpdateCart(idClient); } } }
private void LoadData() { using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext()) { PelangganLogin Pelanggan = (PelangganLogin)Session["PelangganLogin"]; //MENCARI TRANSAKSI SESSION var TransaksiECommerceDetail = db.TBTransaksiECommerceDetails .Where(item => item.TBTransaksiECommerce.IDPelanggan == Pelanggan.IDPelanggan); if (TransaksiECommerceDetail.Count() > 0) { MultiView1.ActiveViewIndex = 1; RepeaterCart.DataSource = TransaksiECommerceDetail .Select(item => new { item.IDTransaksiECommerceDetail, Foto = "/images/cover/" + item.TBStokProduk.TBKombinasiProduk.IDProduk + ".jpg", item.TBStokProduk.TBKombinasiProduk.Nama, item.Quantity, Harga = item.TBStokProduk.HargaJual, Total = (item.Quantity * item.TBStokProduk.HargaJual) }) .ToArray(); RepeaterCart.DataBind(); } else { MultiView1.ActiveViewIndex = 0; } } }
private void LoadData() { using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext()) { PelangganLogin Pelanggan = (PelangganLogin)Session["PelangganLogin"]; //MENCARI TRANSAKSI SESSION var TransaksiECommerce = db.TBTransaksiECommerces .FirstOrDefault(item => item.IDPelanggan == Pelanggan.IDPelanggan); if (TransaksiECommerce != null) { var TransaksiECommerceDetail = TransaksiECommerce.TBTransaksiECommerceDetails; StokProduk_Class ClassStokProduk = new StokProduk_Class(db); var Result = ClassStokProduk.ValidasiStokProdukTransaksi(TransaksiECommerceDetail.ToArray()); LiteralWarning.Text = ""; foreach (var item in Result) { LiteralWarning.Text += item + "<br/>"; } MultiView1.ActiveViewIndex = 1; RepeaterCart.DataSource = TransaksiECommerceDetail .Select(item => new { item.IDTransaksiECommerceDetail, Foto = "/images/cover/" + item.TBStokProduk.TBKombinasiProduk.IDProduk + ".jpg", item.TBStokProduk.TBKombinasiProduk.Nama, item.Quantity, Harga = item.TBStokProduk.HargaJual, Total = (item.Quantity * item.TBStokProduk.HargaJual) }) .ToArray(); RepeaterCart.DataBind(); var total = TransaksiECommerceDetail.Sum(item => item.Quantity * item.TBStokProduk.HargaJual).ToString(); LiteralTotal.Text = total.ToFormatHarga(); } else { MultiView1.ActiveViewIndex = 0; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext()) { //VALIDASI STOK PRODUK ValidasiStokProdukTransaksi(db); //PROVINSI DropDownListProvinsi.DataSource = db.TBKurirProvinsis.OrderBy(item => item.Nama).ToArray(); DropDownListProvinsi.DataValueField = "IDKurirProvinsi"; DropDownListProvinsi.DataTextField = "Nama"; DropDownListProvinsi.DataBind(); DropDownListProvinsi.Items.Insert(0, new ListItem { Selected = true, Text = "- Pilih Provinsi -", Value = "0" }); PelangganLogin Pelanggan = (PelangganLogin)Session["PelangganLogin"]; var Data = db.TBPelanggans .FirstOrDefault(item => item.IDPelanggan == Pelanggan.IDPelanggan); if (Data != null) { TextBoxNamaLengkap.Text = Data.NamaLengkap; TextBoxAlamatEmail.Text = Data.Email; TextBoxNomorTelepon.Text = Data.Handphone; var Alamat = Data.TBAlamats .OrderByDescending(item => item.IDAlamat) .FirstOrDefault(); if (Alamat != null) { TextBoxAlamat.Text = Alamat.AlamatLengkap; TextBoxKodePos.Text = Alamat.KodePos; } //MENCARI TRANSAKSI SESSION var TransaksiECommerceDetail = db.TBTransaksiECommerceDetails .Where(item => item.TBTransaksiECommerce.IDPelanggan == Pelanggan.IDPelanggan); if (TransaksiECommerceDetail.Count() > 0) { RepeaterCart.DataSource = TransaksiECommerceDetail .Select(item => new { item.IDTransaksiECommerceDetail, Foto = "/images/cover/" + item.TBStokProduk.TBKombinasiProduk.IDProduk + ".jpg", item.TBStokProduk.TBKombinasiProduk.Nama, item.Quantity, Harga = item.TBStokProduk.HargaJual, Total = (item.Quantity * item.TBStokProduk.HargaJual) }) .ToArray(); RepeaterCart.DataBind(); } else { Response.Redirect("_Cart.aspx"); } } else { Response.Redirect("_Cart.aspx"); } } } }