private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = dgvData.CurrentCell.RowIndex;

            switch (dataType)
            {
            case DataManager.PRODUCTLAPTOP:
                btnProLaptopSua.Enabled = btnProLaptopXoa.Enabled = true;

                txbProLaptopMaSP.Text       = dgvData.Rows[row].Cells[0].Value.ToString();
                txbProLaptopTenSP.Text      = dgvData.Rows[row].Cells[1].Value.ToString();
                txbProLaptopThuongHieu.Text = dgvData.Rows[row].Cells[2].Value.ToString();

                cbbProLaptopLoai.Text  = dgvData.Rows[row].Cells[3].Value.ToString();
                txbProLaptopGiaSP.Text = dgvData.Rows[row].Cells[4].Value.ToString();
                txbProLaptopGiaTT.Text = dgvData.Rows[row].Cells[5].Value.ToString();
                nmrProLaptopRate.Value = (int)dgvData.Rows[row].Cells[6].Value;

                DataRow      rowTableImg = new BLImageLaptop().FindImageByID(txbProLaptopMaSP.Text.Trim());
                MemoryStream mem         = new MemoryStream((byte[])rowTableImg[1]);
                ptbProLaptopImage1.Image = Image.FromStream(mem);

                mem = new MemoryStream((byte[])rowTableImg[2]);
                ptbProLapImage2.Image = Image.FromStream(mem);

                mem = new MemoryStream((byte[])rowTableImg[3]);
                ptbProLaptopImage3.Image = Image.FromStream(mem);

                mem = new MemoryStream((byte[])rowTableImg[4]);
                ptbProLaptopImage4.Image = Image.FromStream(mem);

                break;

            case DataManager.DETAILLAPTOP:
                btnDetLaptopSua.Enabled = btnDetLaptopXoa.Enabled = true;

                txbDetLaptopMaSP.Text    = dgvData.Rows[row].Cells[0].Value.ToString();
                txbDetLaptopManHinh.Text = dgvData.Rows[row].Cells[1].Value.ToString();

                txbDetLaptopRam.Text   = dgvData.Rows[row].Cells[2].Value.ToString();
                txbDetLaptopOCung.Text = dgvData.Rows[row].Cells[3].Value.ToString();

                txbDetLaptopChip.Text = dgvData.Rows[row].Cells[4].Value.ToString();
                cbbDetLaptopHDH.Text  = dgvData.Rows[row].Cells[5].Value.ToString();

                txbDetLaptopPin.Text = dgvData.Rows[row].Cells[6].Value.ToString();

                break;

            case DataManager.CATEGORY_LAPTOP:
                btnCatLaptopSua.Enabled = btnCatLaptopXoa.Enabled = true;
                txbCatLaptopLoai.Text   = dgvData.Rows[row].Cells[0].Value.ToString();

                MemoryStream ms = new MemoryStream((byte[])dgvData.Rows[row].Cells[1].Value);
                btnCatLaptopChangeImg.Image = Image.FromStream(ms);
                break;
            }
        }
示例#2
0
        // Chia bảng ra nhiều lần get, một lần get (end - begin) item
        static private DataTable GetDatabase(int begin, int end, out bool flag, string nameTable)
        {
            flag = true;
            DataSet dt = null;

            if (nameTable.Contains("IMAGE"))
            {
                switch (nameTable.Trim())
                {
                case "IMAGE_PHONE":
                    dt = new BLImageSmartPhone().GetData();
                    break;

                case "IMAGE_LAPTOP":
                    dt = new BLImageLaptop().GetData();
                    break;

                case "IMAGE_FASHION":
                    dt = new BLImageFahion().GetData();
                    break;

                case "IMAGE_CAR":
                    dt = new BLImageCar().GetData();
                    break;

                case "IMAGE_BOOK":
                    dt = new BLImageCar().GetData();
                    break;

                default:
                    flag = false;
                    return(null);
                }
            }
            else if (nameTable.Contains("PRODUCT"))
            {
                switch (nameTable.Trim())
                {
                case "PRODUCT_PHONE":
                    dt = new BLProductSmart().GetData();
                    break;

                case "PRODUCT_LAPTOP":
                    dt = new BLProductLaptop().GetData();
                    break;

                case "PRODUCT_FASHION":
                    dt = new BLProductFashion().GetData();
                    break;

                case "PRODUCT_CAR":
                    dt = new BLProductCar().GetData();
                    break;

                case "PRODUCT_BOOK":
                    dt = new BLProductBook().GetData();
                    break;

                default:
                    flag = false;
                    return(null);
                }
            }
            else if (nameTable.Contains("DETAIL"))
            {
                switch (nameTable.Trim())
                {
                case "DETAIL_PHONE":
                    dt = new BLDetailSmartPhone().GetData();
                    break;

                case "DETAIL_LAPTOP":
                    dt = new BLDetailLaptop().GetData();
                    break;

                case "DETAIL_FASHION":
                    dt = new BLDetailFashion().GetData();
                    break;

                case "DETAIL_CAR":
                    dt = new BLDetailCar().GetData();
                    break;

                case "DETAIL_BOOK":
                    dt = new BLDetailBook().GetData();
                    break;

                default:
                    flag = false;
                    return(null);
                }
            }
            else if (nameTable.Contains("CATEGORY"))
            {
                switch (nameTable.Trim())
                {
                case "CATEGORY_PHONE":
                    dt = new BLCategory_Smartphone_Tablet().GetData();
                    break;

                case "CATEGORY_LAPTOP":
                    dt = new BLCategory_Laptop().GetData();
                    break;

                case "CATEGORY_FASHION":
                    dt = new BLCategory_Fashion().GetData();
                    break;

                case "CATEGORY_CAR":
                    dt = new BLCategory_Car().GetData();
                    break;

                case "CATEGORY_BOOK":
                    dt = new BLCategory_Book().GetData();
                    break;

                default:
                    flag = false;
                    return(null);
                }
            }
            else
            {
                switch (nameTable.Trim())
                {
                case "CUSTOMER":
                    dt = new BLCustomer().GetData();
                    break;

                case "COMMENT":
                    dt = new BLComment().GetData();
                    break;

                case "BILL":
                    dt = new BLDetailBill().GetData();
                    break;

                default:
                    flag = false;
                    return(null);
                }
            }

            DataTable table = dt.Tables[0];

            if (table.Rows.Count <= end)
            {
                end  = table.Rows.Count;
                flag = false;
            }
            DataTable resulrSplip = table.AsEnumerable().Skip(begin).Take(end - begin).CopyToDataTable();

            return(resulrSplip);
        }