Ejemplo n.º 1
0
        private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = dgvData.CurrentCell.RowIndex;

            switch (dataType)
            {
            case DataManager.PRODUCTCAR:
                btnProCarSua.Enabled = btnProCarXoa.Enabled = true;

                txbProCarMaSP.Text       = dgvData.Rows[row].Cells[0].Value.ToString();
                txbProCarTenSP.Text      = dgvData.Rows[row].Cells[1].Value.ToString();
                txbProCarThuongHieu.Text = dgvData.Rows[row].Cells[2].Value.ToString();

                cbbProCarLoai.Text  = dgvData.Rows[row].Cells[3].Value.ToString();
                txbProCarGiaSP.Text = dgvData.Rows[row].Cells[4].Value.ToString();
                txbProCarGiaTT.Text = dgvData.Rows[row].Cells[5].Value.ToString();
                nmrProCarRate.Value = (int)dgvData.Rows[row].Cells[6].Value;

                DataRow      rowTableImg = new BLImageCar().FindImageByID(txbProCarMaSP.Text.Trim());
                MemoryStream mem         = new MemoryStream((byte[])rowTableImg[1]);
                ptbProCarImage1.Image = Image.FromStream(mem);

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

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

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

                break;

            case DataManager.DETAILCAR:
                btnDetCarSua.Enabled = btnDetCarXoa.Enabled = true;

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

                txbDetCarXang.Text   = dgvData.Rows[row].Cells[2].Value.ToString();
                txbDetCarXilanh.Text = dgvData.Rows[row].Cells[3].Value.ToString();
                txbDetCarLoai.Text   = dgvData.Rows[row].Cells[4].Value.ToString();

                break;

            case DataManager.CATEGORY_CAR:
                btnCatCarSua.Enabled = btnCatCarXoa.Enabled = true;
                txbCatCarLoai.Text   = dgvData.Rows[row].Cells[0].Value.ToString();

                //DataRow rowTable = new BLCATEGORY_CAR().FindImageByID(txbProSmartMaSP.Text.Trim());
                MemoryStream ms = new MemoryStream((byte[])dgvData.Rows[row].Cells[1].Value);
                btnCatCarChangeImg.Image = Image.FromStream(ms);
                break;
            }
        }
Ejemplo n.º 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);
        }