private void loadsanpham() { sanphamBLL sp = new sanphamBLL(); khuyenmaiBLL km = new khuyenmaiBLL(); int id = Convert.ToInt32(Request.Form["id"]); dathangdetailBLL bs = new dathangdetailBLL(); List <dathangdetail> ds = bs.getdathangDetail(id); rpDatHang.DataSource = ds; rpDatHang.DataBind(); decimal gia = 0; for (int i = 0; i <= ds.Count - 1; i++) { decimal giasp = 0; List <sanphamDAL> list = sp.getSPbyId(ds[i].id_sanpham); if (list[0].khuyenmai == true) { giasp = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100); } else { giasp = ds[i].gia; } Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label; gia += (giasp * ds[i].soluong); lbSTT.Text = (i + 1).ToString(); } lbTongTien.Text = String.Format("{0:0,0 VNĐ}", gia); }
// san pham mua nhieu private void load10muanhieu(int id_khm) { khuyenmaiBLL km = new khuyenmaiBLL(); sanphamBLL spbs = new sanphamBLL(); dathangdetailBLL bs = new dathangdetailBLL(); List <dathangdetail> ds = bs.getdathangDetailMuaNhieuPubLic(); rpbanchay.DataSource = ds; rpbanchay.DataBind(); for (int i = 0; i <= ds.Count() - 1; i++) { Label lbA = rpbanchay.Items[i].FindControl("lbA") as Label; Label lbHinh = rpbanchay.Items[i].FindControl("lbHinh") as Label; Label lbTen = rpbanchay.Items[i].FindControl("lbTen") as Label; Label lbGia = rpbanchay.Items[i].FindControl("lbGia") as Label; List <sanphamDAL> sptt = spbs.getSPbyId(ds[i].id_sanpham); lbA.Text = "<a href='chitietsanpham.aspx?id=" + sptt[0].id_sanpham + "&gr=" + sptt[0].id_danhmuc + "' title='" + sptt[0].ten_sanpham + "'>"; lbHinh.Text = "<img class='hinhsp' height='350' width='275' alt='" + sptt[0].ten_sanpham + "' src='/uploads/" + sptt[0].hinhanh + "' style='display: block;' />"; lbTen.Text = "<span class='productName'>" + sptt[0].ten_sanpham + "</span>"; if (sptt[0].khuyenmai == true) { decimal khm = sptt[0].gia - (sptt[0].gia * km.getKhuyenMaibyId(id_khm) / 100); lbGia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</del> </span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>"; } else { lbGia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</span>"; } } }
private void loadsanpham() { int id = Convert.ToInt32(Request.Form["id"]); dathangdetailBLL bs = new dathangdetailBLL(); List <dathangdetail> ds = bs.getdathangDetail(id); rpDatHang.DataSource = ds; rpDatHang.DataBind(); }
// load san pham ban chay: private void spbanchay(int id_khm) { lbtitle.Text = "Sản phẩm bán chạy"; lbDanhMuc.Text = "Sản phẩm bán chạy"; int row = 10; int hide = 0; if (Request.QueryString["p"] != null) { hide = Convert.ToInt32(Request.QueryString["p"]); } phantrang pt = new phantrang(); khuyenmaiBLL km = new khuyenmaiBLL(); sanphamBLL spbs = new sanphamBLL(); dathangdetailBLL bs = new dathangdetailBLL(); List <dathangdetail> ds = bs.getdathangDetailMuaNhieuP(row, hide); rpbanchay.DataSource = ds; rpbanchay.DataBind(); for (int i = 0; i <= ds.Count() - 1; i++) { Label lbA = rpbanchay.Items[i].FindControl("lbA") as Label; Label lbHinh = rpbanchay.Items[i].FindControl("lbHinh") as Label; Label lbTen = rpbanchay.Items[i].FindControl("lbTen") as Label; Label lbGia = rpbanchay.Items[i].FindControl("lbGia") as Label; List <sanphamDAL> sptt = spbs.getSPbyId(ds[i].id_sanpham); lbA.Text = "<a href='chitietsanpham.aspx?id=" + sptt[0].id_sanpham + "&gr=" + sptt[0].id_danhmuc + "' title='" + sptt[0].ten_sanpham + "'>"; lbHinh.Text = "<img class='hinhsp' height='350' width='275' alt='" + sptt[0].ten_sanpham + "' src='/uploads/" + sptt[0].hinhanh + "' style='display: block;' />"; lbTen.Text = "<span class='productName'>" + sptt[0].ten_sanpham + "</span>"; if (sptt[0].khuyenmai == true) { decimal khm = sptt[0].gia - (sptt[0].gia * km.getKhuyenMaibyId(id_khm) / 100); lbGia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</del> </span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>"; } else { lbGia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</span>"; } } int r = bs.countMuaNhieuP(); lbPhanTrang.Text = pt.pagingpublic(r, row, "&v=bc", hide); }
protected void btnUpDate_Click(object sender, EventArgs e) { dathangBLL bs = new dathangBLL(); dathangdetailBLL bss = new dathangdetailBLL(); string id = ""; int lengh = 0; bool tf = false; bool tff = false; bool check = false; for (int i = 0; i <= rpDatHang.Items.Count - 1; i++) { CheckBox cbDell = rpDatHang.Items[i].FindControl("cbDell") as CheckBox; if (cbDell.Checked) { id += cbDell.ToolTip + ","; check = true; } } lengh = id.Length; if (check == true) { string hid = id.Remove(lengh - 1); tff = bss.del(hid); tf = bs.del(hid); if (tff == true && tf == true) { Response.Redirect("dathang.aspx?up=t"); } else { lbError.Text = "<div class='error'> " + " <div class='tl'></div><div class='tr'></div>" + "<div class='desc'>" + " <p>Cập nhật thất bại!</p>" + "</div>" + "<div class='bl'></div><div class='br'></div>" + "</div>"; } } }
protected void Page_Load(object sender, EventArgs e) { sanphamBLL sp = new sanphamBLL(); dathangdetailBLL bs = new dathangdetailBLL(); List <dathangdetail> ds = bs.getdathangDetailMuaNhieu(); rpDatHang.DataSource = ds; rpDatHang.DataBind(); for (int i = 0; i <= ds.Count - 1; i++) { Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label; Label lbTen = rpDatHang.Items[i].FindControl("lbTen") as Label; lbSTT.Text += (i + 1).ToString(); List <sanphamDAL> lsp = sp.getSPbyId(ds[i].id_sanpham); lbTen.Text = lsp[0].ten_sanpham; } }
private void loadDatHang() { decimal tong = 0; dathangBLL bs = new dathangBLL(); dathangdetailBLL dhdt_bs = new dathangdetailBLL(); khuyenmaiBLL km = new khuyenmaiBLL(); List <dathangDAL> ds = bs.getDathangdoanhthu("false"); rpDatHang.DataSource = ds; rpDatHang.DataBind(); for (int i = 0; i <= ds.Count - 1; i++) { List <dathangdetail> dhdt_ds = dhdt_bs.getdathangDetail(ds[i].id_dathang); Label lbTongTien = rpDatHang.Items[i].FindControl("lbTongTien") as Label; decimal tongTien = 0; for (int j = 0; j <= dhdt_ds.Count - 1; j++) { if (dhdt_ds[j].khuyenmai == true) { tongTien += (dhdt_ds[j].gia - (dhdt_ds[j].gia * km.getKhuyenMaibyId(1) / 100)) * dhdt_ds[j].soluong; } else { tongTien += (dhdt_ds[j].gia * dhdt_ds[j].soluong); } } tong += tongTien; lbTongTien.Text = String.Format("{0:0,0 VNĐ}", tongTien); Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label; lbSTT.Text += (i + 1).ToString(); } lbSum.Text = "Tổng doanh thu:" + String.Format("{0:0,0 VNĐ}", tong); }
// load dat hang private void loadDatHang(string v) { int row = 10; int hide = 0; if (Request.QueryString["p"] != null) { hide = Convert.ToInt32(Request.QueryString["p"]); } dathangBLL bs = new dathangBLL(); phuongthucthanhtoanBLL pt_bs = new phuongthucthanhtoanBLL(); dathangdetailBLL dhdt_bs = new dathangdetailBLL(); nguoidungBLL nd_bs = new nguoidungBLL(); khuyenmaiBLL km = new khuyenmaiBLL(); List <dathangDAL> ds = bs.getDathangP(row, hide, v); rpDatHang.DataSource = ds; rpDatHang.DataBind(); for (int i = 0; i <= ds.Count - 1; i++) { List <nguoidungDAL> nd_ds = nd_bs.getNguoiDungbyId(ds[i].id_user); List <phuongthucthanhtoanDAL> pt_ds = pt_bs.getPhuongThucById(ds[i].id_pt); List <dathangdetail> dhdt_ds = dhdt_bs.getdathangDetail(ds[i].id_dathang); Label lbNguoiDung = rpDatHang.Items[i].FindControl("lbNguoiDung") as Label; lbNguoiDung.Text = nd_ds[0].hoten; Label lbThanhToan = rpDatHang.Items[i].FindControl("lbThanhToan") as Label; lbThanhToan.Text = pt_ds[0].ten_phuongthuc; Label lbTongTien = rpDatHang.Items[i].FindControl("lbTongTien") as Label; decimal tongTien = 0; for (int j = 0; j <= dhdt_ds.Count - 1; j++) { if (dhdt_ds[j].khuyenmai == true) { tongTien += (dhdt_ds[j].gia - (dhdt_ds[j].gia * km.getKhuyenMaibyId(1) / 100)) * dhdt_ds[j].soluong; } else { tongTien += (dhdt_ds[j].gia * dhdt_ds[j].soluong); } } lbTongTien.Text = String.Format("{0:0,0 VNĐ}", tongTien); Label lbHinh = rpDatHang.Items[i].FindControl("lbHinh") as Label; if (ds[i].trangthai == true) { lbHinh.Text = "<img src=\"../images/admin/dathutien.jpg\" alt=\"Đã thu tiền\">"; } Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label; lbSTT.Text += (i + 1 + hide).ToString(); } string view = ""; if (v != "") { view = "&v=" + Request.QueryString["v"]; } // phan trang: int current = Convert.ToInt32(Request.QueryString["p"]); phantrang pt = new phantrang(); lbPage.Text = pt.paging(bs.countP(v), row, view, current); }