コード例 #1
0
        private void frm_ChiTiet_CauHinhSanPham_Load(object sender, EventArgs e)
        {
            //if (frmCauHinh.isAdd)
            //{
            //    bteSanPham.Enabled = true;
            //    txtNhaCC.Text = "";
            //    txtLogo.Text = "";
            //    //pteLogo.
            //    //grcChiTietCauHinh.DataSource = lst;
            //    grcChiTietCauHinh.DataSource = new BindingList<DMCauHinhSanPhamInfo>(lst)
            //                                       {
            //                                           AllowEdit = true,
            //                                           AllowNew = true,
            //                                           AllowRemove = true,
            //                                       };
            //}
            //else
            //{
            txtLogo.Enabled  = false;
            txtNhaCC.Enabled = false;
            bteSanPham.Tag   = DmSanPhamProvider.GetSanPhamById(IdSanPham);
            bteSanPham.Text  = TenSanPham;
            //txtLogo.Text = Logo;
            DMCauHinhSanPhamInfo nhaCC = DMCauHinhSanPhamDataProvider.Instance.GetNhaCCByIdSanPham(IdSanPham);

            txtNhaCC.Text = nhaCC.Hang;
            try
            {
                string path = String.Format("http://logo.trananh.com.vn/{0}.jpg", txtNhaCC.Text);
                System.Net.WebRequest  req      = System.Net.WebRequest.Create(path);
                System.Net.WebResponse response = req.GetResponse();
                System.IO.Stream       stream   = response.GetResponseStream();
                if (path != null)
                {
                    //Image im = new Bitmap(path, true);
                    Image im = Image.FromStream(stream);
                    pteLogo.Image = im;
                    //Crop(im, 192, 83, AnchorPosition.Center);
                }
            }
            catch (Exception)
            {
                clsUtils.MsgCanhBao("Sản phẩm chưa có Logo!");
            }

            lst = DMCauHinhSanPhamDataProvider.Instance.GetCauHinhByIdSanPham(IdSanPham);
            grcChiTietCauHinh.DataSource = new BindingList <DMCauHinhSanPhamInfo>(lst)
            {
                AllowEdit   = true,
                AllowNew    = true,
                AllowRemove = true,
            };
            //grcChiTietCauHinh.DataSource = null;
            //grcChiTietCauHinh.DataSource = lst;
            //}
        }
コード例 #2
0
        private void LoadData()
        {
            if (frmMH.isAdd)
            {
                txtMaSanPham.Enabled = true;
                txtMaSanPham.Focus();
                txtTenTat.Text       = "";
                txtTenSanPham.Text   = "";
                txtMoTa.Text         = "";
                txtMaVach.Text       = "";
                txtMaSanPham.Text    = "";
                txtGiaNhap.Text      = "0";
                txtBaoHanhHang.Text  = "0";
                txtBaohanhKhach.Text = "0";
                txtMaSanPham.Focus();
                btnXoa.Enabled = false;
            }
            else
            {
                txtMaSanPham.Enabled = false;
                dm = DmSanPhamProvider.GetSanPhamById(frmMH.Oid);

                txtTenTat.Text             = dm.TenVietTat;
                txtTenSanPham.Text         = dm.TenSanPham;
                txtMoTa.Text               = dm.MoTa;
                txtMaVach.Text             = dm.MaVach;
                txtMaSanPham.Text          = dm.MaSanPham;
                txtGiaNhap.Text            = Convert.ToString(dm.GiaNhap);
                txtBaoHanhHang.Text        = Convert.ToString(dm.BaoHanhHang);
                txtBaohanhKhach.Text       = Convert.ToString(dm.BaoHanhKhach);
                cboDonViTinh.SelectedValue = dm.IdDonViTinh;
                cbTyLeVAT.SelectedValue    = dm.TyLeVAT;
                bteLoaiSanPham.Tag         = DMLoaiSanPhamDataProvider.Instance.GetFullInfoByKey(dm.IdCha);
                if (bteLoaiSanPham.Tag != null)
                {
                    bteLoaiSanPham.Text = ((DMLoaiSanPhamInfo)bteLoaiSanPham.Tag).TenLoaiSP;
                }
                chkSuDung.Checked      = dm.SuDung == 1;
                chkTrungMaVach.Checked = dm.TrungMaVach == 1;
                chkChietKhau.Checked   = dm.ChietKhau == 1;
            }
            if (frmMH.IsSync)
            {
                //không cho phép người dùng sửa, xóa các thông tin trên form.
                txtMaSanPham.Enabled = false;
                txtMaVach.Enabled    = false;
                btnXoa.Enabled       = false;
            }
        }