예제 #1
0
        private void btnThemSanPham_Click(object sender, EventArgs e)
        {
            if (txtTenSanPham.Text.Trim() == "" ||
                txtLoaiSanPham.Text.Trim() == "" ||
                txtDonGia.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập đầy đủ thông tin", "Thông báo");
            }
            else
            {
                SanPham_DTO sp = new SanPham_DTO();
                sp.TenSP   = txtTenSanPham.Text;
                sp.LoaiSP  = txtLoaiSanPham.Text;
                sp.DonGia  = decimal.Parse(txtDonGia.Text);
                sp.IconUrl = imageName;
                sp.NgayTao = dateTimeNgayTapSP.Value;

                if (imagePath != "")
                {
                    DirectoryInfo di   = Directory.CreateDirectory("data/hinhanh");
                    string        path = System.IO.Path.Combine(di.FullName, imageName);
                    System.IO.File.Copy(imagePath, path, true);
                }

                SanPham_BUS dtBus = new SanPham_BUS();
                dtBus.ThemSanPham(sp, 1);
                MessageBox.Show("Đã Thêm 1 Sản Phẩm mới");
                LoadDSSP();
                ResetSP();
            }
        }