Exemple #1
0
        // load data bằng productID
        private void LoadDefaultDataToForm()
        {
            DataTable dtProductInfo = bus_Product.BUS_GetAllProductInfoByID(this._ProductID);

            if (dtProductInfo == null)
            {
                MessageBox.Show("Có lỗi xảy ra khi load dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (dtProductInfo.Rows.Count > 0)
            {
                // load dữ liệu vào các field
                cmbCategories.SelectedValue = int.Parse(dtProductInfo.Rows[0]["ID_MALOAI"].ToString());

                cmbManufacturer.SelectedValue = int.Parse(dtProductInfo.Rows[0]["ID_HANGSX"].ToString());

                txbProductName.Text     = dtProductInfo.Rows[0]["TENSP"].ToString();
                txbProductPrice.Text    = dtProductInfo.Rows[0]["DONGIA"].ToString();
                txbProductQuantity.Text = dtProductInfo.Rows[0]["SOLUONG"].ToString();

                txbCPU.Text     = dtProductInfo.Rows[0]["CPU"].ToString();
                txbGPU.Text     = dtProductInfo.Rows[0]["GPU"].ToString();
                txbRAM.Text     = dtProductInfo.Rows[0]["RAM"].ToString();
                txbStorage.Text = dtProductInfo.Rows[0]["BONHO"].ToString();
                txbScreen.Text  = dtProductInfo.Rows[0]["MANHINH"].ToString();
                txbCamera.Text  = dtProductInfo.Rows[0]["CAMERA"].ToString();
                txbPin.Text     = dtProductInfo.Rows[0]["PIN"].ToString();
                txbOS.Text      = dtProductInfo.Rows[0]["HEDIEUHANH"].ToString();
                txbMore.Text    = dtProductInfo.Rows[0]["KHAC"].ToString();

                Byte[] arrByteImage = (Byte[])dtProductInfo.Rows[0]["HINHANH"];

                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(arrByteImage))
                {
                    Picimage.Image = Image.FromStream(ms);
                }

                // set dữ liệu cho product profile
                this._ID_ProductProfile = int.Parse(dtProductInfo.Rows[0]["ID_CHITIETCAUHINH"].ToString());
            }
            else
            {
                return;
            }
        }