コード例 #1
0
        public void HienthiSPTheoMa()
        {
            ThongTinSanPham sp = new ThongTinSanPham();
            sp.MaSanPham = int.Parse(Request.QueryString.Get("MaSanPham"));
            XulyLayThongTinSanPhamByID SanphamID = new XulyLayThongTinSanPhamByID();
            SanphamID.thongtinsanpham.MaSanPham = sp.MaSanPham;
            try
            {
                SanphamID.Thucthi();

                DropdownMaNSX.SelectedIndex = DropdownMaNSX.Items.IndexOf(DropdownMaNSX.Items.FindByText(SanphamID.thongtinsanpham.Nhasx.TenNSX));
                DropdownPhongCach.SelectedIndex = DropdownPhongCach.Items.IndexOf(DropdownPhongCach.Items.FindByText(SanphamID.thongtinsanpham.Phongcach.TenPhongCach));
                DropdownMaKieuDang.SelectedIndex = DropdownMaKieuDang.Items.IndexOf(DropdownMaKieuDang.Items.FindByText(SanphamID.thongtinsanpham.Kieudang.TenKieuDang));
                txtTenSanPham.Text = SanphamID.thongtinsanpham.TenSanPham;
                txtMoTaSanPham.Text = SanphamID.thongtinsanpham.MoTa;
                txtGiaSanPham.Text = SanphamID.thongtinsanpham.GiaSanPham.ToString();
                txtSoLuong.Text = SanphamID.thongtinsanpham.SoLuong.ToString();
                txtHDH.Text = SanphamID.thongtinsanpham.TenHDH;
                txtRAM.Text = SanphamID.thongtinsanpham.RAM;
                txtCamera.Text = SanphamID.thongtinsanpham.Camera;
                txtPin.Text = SanphamID.thongtinsanpham.Pin.ToString();
                Label1.Text = SanphamID.thongtinsanpham.ImageSP;
                image1.ImageUrl = SanphamID.thongtinsanpham.ImageSP;
                
            }
            catch
            { lbThongbao.Text = "Lỗi! không lấy được DL"; }
            
        }
コード例 #2
0
        protected void btnThem_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                XulyThemSanPhamMoi themsanpham = new XulyThemSanPhamMoi();
                ThongTinSanPham ttsanpham = new ThongTinSanPham();
                string linkimage = this.Laylink_file_image();

                ttsanpham.MaNSX = DropdownMaNSX.SelectedItem.Value;
                ttsanpham.MaKieuDang = DropdownMaKieuDang.SelectedItem.Value;
                ttsanpham.MaPhongCach = DropdownPhongCach.SelectedItem.Value;

                ttsanpham.TenSanPham = txtTenSanPham.Text;
                ttsanpham.MoTa = txtMoTaSanPham.Text;
                ttsanpham.GiaSanPham = Convert.ToInt32(txtGiaSanPham.Text);
                ttsanpham.SoLuong = Convert.ToInt32(txtSoLuong.Text);
                ttsanpham.TenHDH = DropDownList1.SelectedItem.Value;
                ttsanpham.RAM = txtRAM.Text;
                ttsanpham.Camera = txtCamera.Text;
                ttsanpham.Pin = Convert.ToInt32(txtPin.Text);
                ttsanpham.ImageSP = linkimage.ToString();
                themsanpham.ttsanpham = ttsanpham;

                themsanpham.Thucthi();
                txtTenSanPham.Focus();

                // lbThongbao.Text = "Không thêm được";
            }
        }
コード例 #3
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {

                ThongTinSanPham ttsanpham = new ThongTinSanPham();
                XulySuaThongTinSanPham editSp = new XulySuaThongTinSanPham();
                string linkimage = this.Laylink_file_image();

                ttsanpham.MaSanPham = int.Parse(Request.QueryString.Get("MaSanPham"));

                ttsanpham.MaNSX = DropdownMaNSX.SelectedItem.Value;
                ttsanpham.MaKieuDang = DropdownMaKieuDang.SelectedItem.Value;
                ttsanpham.MaPhongCach = DropdownPhongCach.SelectedItem.Value;

                ttsanpham.TenSanPham = txtTenSanPham.Text;
                ttsanpham.MoTa = txtMoTaSanPham.Text;
                ttsanpham.GiaSanPham = Convert.ToInt32(txtGiaSanPham.Text);
                ttsanpham.SoLuong = Convert.ToInt32(txtSoLuong.Text);
                ttsanpham.TenHDH = txtHDH.Text;
                ttsanpham.RAM = txtRAM.Text;
                ttsanpham.Camera = txtCamera.Text;
                ttsanpham.Pin = Convert.ToInt32(txtPin.Text);
                ttsanpham.ImageSP = Label1.Text;
                if (FileUpload1.HasFile == true)
                {
                    ttsanpham.ImageSP= this.Laylink_file_image();
                }

                editSp.Thongtinsanpham = ttsanpham;
                try
                {
                    editSp.Thucthi();

                    lbThongbao.Text= "sửa sảnh phẩm thành công";
                }
                catch
                {
                    lbThongbao.Text = "Không sửa được";
                }
            }
        }