//---------CRUD---------//

        private void createButton_Click(object sender, EventArgs e)
        {
            string fantasyName    = txtFantasyName.Text;
            string society        = txtSocietyName.Text;
            string legalDoc       = txtlegalCertification.Text;
            string telephone      = mtxtTelephone.Text;
            string mainAddress    = txaMainAddress.Text;
            string generalAddress = txaGeneralAddress.Text;
            string email          = txtEmail.Text;
            string webPage        = txtWebPage.Text;

            logo = ImageManagement.ImageToByte(file);

            try
            {
                if (BusinessManagement.InsertBusiness(fantasyName, society, legalDoc, telephone, mainAddress, generalAddress,
                                                      email, webPage, logo))
                {
                    Clear();
                    businessModels = BusinessManagement.SelectAllBusiness();
                    WireUpBusinessGridView();
                    FrmMain.Instance.ToolStripLabel.Text = "Negocio agregado correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error al agregar el negocio";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 internal string GetVirtualHardDiskInfo(string path)
 {
     if (WMIImageManagementInitialized())
     {
         ManagementBaseObject inparam = this.ImageManagement.GetMethodParameters("GetVirtualHardDiskSettingData");
         inparam["Path"] = path;
         ManagementBaseObject outparam = ImageManagement.InvokeMethod("GetVirtualHardDiskSettingData", inparam, null);
         string result = null;
         if (outparam != null)
         {
             if ((UInt32)outparam["ReturnValue"] == HvWmiReturnCode.Started)
             {
                 while (WMIJobCompleted(Scopes["Virtualization"], outparam))
                 {
                     result = outparam["SettingData"].ToString();
                 }
                 if ((UInt32)outparam["ReturnValue"] == HvWmiReturnCode.Completed)
                 {
                     result = outparam["Info"].ToString();
                 }
             }
             else if ((UInt32)outparam["ReturnValue"] == HvWmiReturnCode.Completed)
             {
                 result = outparam["SettingData"].ToString();
             }
         }
         return(result);
     }
     else
     {
         return(null);
     }
 }
Exemple #3
0
        public void OnPostVote(string id)
        {
            ImageManagement imageManagement = new ImageManagement();

            imageManagement.ApplyVote(_imageDirectory?.Images, id);
            TotalNumberOfVotes = imageManagement.GetTotalNumberOfVotes(_imageDirectory?.Images).GetValueOrDefault();
        }
Exemple #4
0
        private void dgvEmployee_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameEmployee.Text               = dgvEmployee.CurrentRow.Cells[1].Value.ToString();
                txtLastnameEmployee.Text           = dgvEmployee.CurrentRow.Cells[2].Value.ToString();
                cmbIdentificationType.SelectedItem = dgvEmployee.CurrentRow.Cells[3].Value.ToString();
                txtIdentification.Text             = dgvEmployee.CurrentRow.Cells[4].Value.ToString();
                mtxtTelephone.Text         = dgvEmployee.CurrentRow.Cells[9].Value.ToString();
                mtxtCellphone.Text         = dgvEmployee.CurrentRow.Cells[10].Value.ToString();
                datepBornDate.Text         = dgvEmployee.CurrentRow.Cells[6].Value.ToString();
                txtEmailEmployee.Text      = dgvEmployee.CurrentRow.Cells[8].Value.ToString();
                txtNacionality.Text        = dgvEmployee.CurrentRow.Cells[12].Value.ToString();
                txtResidence.Text          = dgvEmployee.CurrentRow.Cells[5].Value.ToString();
                cmbCivilState.SelectedItem = dgvEmployee.CurrentRow.Cells[7].Value.ToString();
                cmbChilds.SelectedItem     = dgvEmployee.CurrentRow.Cells[8].Value.ToString();

                photo          = (byte[])dgvEmployee.CurrentRow.Cells[18].Value;
                picPhoto.Image = ImageManagement.ByteToImage((byte[])dgvEmployee.CurrentRow.Cells[18].Value);

                cmbEnterStore.SelectedItem        = dgvEmployee.CurrentRow.Cells[11].Value.ToString();
                cmbPosition.SelectedItem          = dgvEmployee.CurrentRow.Cells[13].Value.ToString();
                workingStateComboBox.SelectedItem = dgvEmployee.CurrentRow.Cells[14].Value.ToString();
                startDateDateTime.Text            = dgvEmployee.CurrentRow.Cells[15].Value.ToString();
                txaObservation.Text = dgvEmployee.CurrentRow.Cells[17].Value.ToString();

                txtEmergencyName.Text   = dgvEmployee.CurrentRow.Cells[19].Value.ToString();
                mtxtEmergencyPhone.Text = dgvEmployee.CurrentRow.Cells[20].Value.ToString();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #5
0
        public RankingModel(IImageDirectory imageDirectory)
        {
            _imageDirectory = imageDirectory;
            ImageManagement imageManagement = new ImageManagement();

            ImagesList = imageManagement.GetImagesRankedByVotes(_imageDirectory.Images);
        }
Exemple #6
0
        public IndexModel(IImageDirectory imageDirectory)
        {
            _imageDirectory = imageDirectory;
            ImageManagement imageManagement = new ImageManagement();

            ImagesList         = imageManagement.GetImagesToVote(_imageDirectory?.Images);
            TotalNumberOfVotes = imageManagement.GetTotalNumberOfVotes(_imageDirectory?.Images).GetValueOrDefault();
        }
Exemple #7
0
        public void correctInputTestWithoutException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im = new ImageManagement(testIOFiles, testIImageDetection);

            testIOFiles.loadFile("nopath").Returns <Bitmap>(bitmap);

            Bitmap realimage = im.GetImageFromPath("nopath");

            // Compares if it is bitmaps
            Assert.AreEqual(realimage, bitmap);
        }
Exemple #8
0
        public void correctInputTestWithException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im = new ImageManagement(testIOFiles, testIImageDetection);

            testIOFiles.loadFile("nopath").Returns(k => { throw new ArgumentException(); });

            Bitmap falseimage = im.GetImageFromPath("nopath");

            // If there is a exception the catch will return null
            Assert.AreEqual(falseimage, null);
        }
Exemple #9
0
        private void btnUpdateEmployee_Click(object sender, EventArgs e)
        {
            string id          = dgvEmployee.CurrentRow.Cells[0].Value.ToString();
            string name        = txtNameEmployee.Text;
            string lastname    = txtLastnameEmployee.Text;
            string telephone   = mtxtTelephone.Text;
            string cellphone   = mtxtCellphone.Text;
            string idType      = cmbIdentificationType.Text;
            string identif     = txtIdentification.Text;
            string bornDate    = datepBornDate.Text;
            string email       = txtEmailEmployee.Text;
            string nationality = txtNacionality.Text;
            string residence   = txtResidence.Text;
            string civilStatus = cmbCivilState.Text;
            string childs      = cmbChilds.Text;

            string enterStore = cmbEnterStore.Text;

            PositionModel position = (PositionModel)cmbPosition.SelectedItem;

            string statusWorking = workingStateComboBox.Text;
            string startDate     = startDateDateTime.Text;
            string endDate       = startDateDateTime.Text;
            string observation   = txaObservation.Text;

            string emergencyName  = txtEmergencyName.Text;
            string emergencyPhone = mtxtEmergencyPhone.Text;

            if (!string.IsNullOrEmpty(file))
            {
                photo = ImageManagement.ImageToByte(file);
            }

            try
            {
                if (EmployeeManagement.UpdateEmployeeById(id, name, lastname, idType, identif, residence, bornDate, civilStatus, childs, telephone,
                                                          cellphone, enterStore, nationality, position.idPosition.ToString(), statusWorking, startDate, endDate, observation, photo, emergencyName, emergencyPhone))
                {
                    dgvEmployee.DataSource = EmployeeManagement.SelectAllEmployees();
                    FrmMain.Instance.ToolStripLabel.Text = "Se modifico el trabajador correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "No se pudo modificar el trabajador";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #10
0
        public void correctFilterTestWithException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im = new ImageManagement(testIOFiles, testIImageDetection);

            // It throws an exception
            testIImageDetection.applyFilter(nullbitmap).Returns(k => { throw new Exception(); });

            Bitmap falseimage = im.applyTheFilter(nullbitmap);

            // If a exception is trown, applyTheFilter returns null
            Assert.AreEqual(falseimage, null);
        }
Exemple #11
0
        public void correctFilterTestWithOutException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im = new ImageManagement(testIOFiles, testIImageDetection);

            // The substitute return a bitmap
            testIImageDetection.applyFilter(nullbitmap).Returns <Bitmap>(bitmap);

            Bitmap realimage = im.applyTheFilter(bitmap);

            // Check if the initial image is different (filter applied)
            Assert.AreNotEqual(realimage, bitmap);
        }
Exemple #12
0
        public void correctOutputTestWithException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im = new ImageManagement(testIOFiles, testIImageDetection);

            // We throw an exception when the methods is used
            testIOFiles.When(x => x.saveFile(bitmap, "nopath"))
            .Do(x => { throw new NullReferenceException(); });


            im.SaveImageToPath(bitmap, "nopath");
            // We get the boolean (that is in ImageManagement) and check if its true
            Assert.IsTrue(im.t);
        }
        private void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            string           id                 = dgvProduct.CurrentRow.Cells[0].Value.ToString();
            string           code               = txtCode.Text;
            string           style              = txtStyle.Text;
            BrandModel       brand              = (BrandModel)cmbBrand.SelectedItem;
            bool             ivi                = true;
            string           description        = txaDescription.Text;
            SubCategoryModel subcategory        = (SubCategoryModel)cmbSubcategory.SelectedItem;
            bool             nonExistingInvoice = true;
            string           enterQuantity      = txtEnterQuantity.Text;
            string           estableQuantity    = txtEstableQuantity.Text;
            string           unityPrice         = txtNormalPrice.Text;
            string           lowerPrice         = txtLowerPrice.Text;

            if (rbIviExcent.Checked)
            {
                ivi = false;
            }

            if (rbNonexistingNoPermit.Checked)
            {
                nonExistingInvoice = false;
            }

            if (!string.IsNullOrEmpty(file))
            {
                photo = ImageManagement.ImageToByte(file);
            }

            try
            {
                if (ProductManagement.UpdateProductById(id, code, style, brand.IdBrand.ToString(), description, subcategory.idsubCategory.ToString(), unityPrice, lowerPrice,
                                                        estableQuantity, enterQuantity, photo, ivi, nonExistingInvoice))
                {
                    dgvProduct.DataSource = ProductManagement.SelectAllProducts();
                    FrmMain.Instance.ToolStripLabel.Text = "Se modifico el producto correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error, no se pudo modificar el producto";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #14
0
        public void correctOutputTestWithoutException()
        {
            var             testIOFiles         = Substitute.For <IIOfiles>();
            var             testIImageDetection = Substitute.For <IImageDetection>();
            ImageManagement im   = new ImageManagement(testIOFiles, testIImageDetection);
            Boolean         isok = false;

            // Since its a void method we need to use when do
            // When the file is written it sets the boolean to true
            testIOFiles.When(x => x.saveFile(bitmap, "nopath"))
            .Do(x => isok = true);

            im.SaveImageToPath(bitmap, "nopath");

            Assert.IsTrue(isok);
        }
Exemple #15
0
 private void btnSelectPhoto_Click(object sender, EventArgs e)
 {
     try
     {
         this.openFileDialog1.ShowDialog();
         if (this.openFileDialog1.FileName.Equals("") == false)
         {
             photo = ImageManagement.ImageToByte(openFileDialog1.FileName);
             picPhoto.Load(this.openFileDialog1.FileName);
             file = openFileDialog1.FileName;
         }
     }
     catch (Exception ex)
     {
         FrmMain.Instance.ToolStripLabel.Text = "Error al cargar la imagen: " + ex.ToString();
     }
 }
 private void selectImageButton_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog openFileDialog = new OpenFileDialog()
     {
         Filter = "JPEG|*.jpg|PNG|*.png",
         Title = "Seleccione la imagen del producto",
         Multiselect = false,
     })
     {
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             pbLogo.Load(openFileDialog.FileName);
             file = openFileDialog.FileName;
             logo = ImageManagement.ImageToByte(openFileDialog.FileName);
         }
     }
 }
 private void btnRotRight_Click(object sender, EventArgs e)
 {
     try
     {
         if (File.Exists(file))
         {
             File.Delete(file);
         }
         RotateFlipType rp       = RotateFlipType.Rotate90FlipXY;
         Image          newImage = pbProduct.Image;
         newImage.RotateFlip(rp);
         pbProduct.Image = newImage;
         file            = ImageManagement.ImageToByte(newImage);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        //----------------METODOS DE SELECCION DE FOTO---------------

        private void SelectImageButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog openFileDialog = new OpenFileDialog()
                {
                    Title = "Seleccione el logo",
                    Multiselect = false
                })
                {
                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        auxImage = ImageManagement.TemporaryImage(Image.FromFile(openFileDialog.FileName));
                        ImgpictureBox.Load(auxImage);
                    }
                }
            }
            catch (Exception ex)
            {
                FrmMain.Instance.ToolStripLabel.Text = "Error: " + ex.Message;
            }
        }
        private void updateButton_Click(object sender, EventArgs e)
        {
            string id             = businessGridView.CurrentRow.Cells[0].Value.ToString();
            string fantasyName    = txtFantasyName.Text;
            string society        = txtSocietyName.Text;
            string legalDoc       = txtlegalCertification.Text;
            string telephone      = mtxtTelephone.Text;
            string mainAddress    = txaMainAddress.Text;
            string generalAddress = txaGeneralAddress.Text;
            string email          = txtEmail.Text;
            string webPage        = txtWebPage.Text;

            if (!string.IsNullOrEmpty(file))
            {
                logo = ImageManagement.ImageToByte(file);
            }

            try
            {
                if (BusinessManagement.UpdateBusinessById(id, fantasyName, society, legalDoc, telephone, mainAddress, generalAddress,
                                                          email, webPage, logo))
                {
                    Clear();
                    businessModels = BusinessManagement.SelectAllBusiness();
                    WireUpBusinessGridView();
                    FrmMain.Instance.ToolStripLabel.Text = "Negocio modificado correctamente";
                }
                else
                {
                    FrmMain.Instance.ToolStripLabel.Text = "Error al modificar el negocio";
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 private void businessGridView_Click(object sender, EventArgs e)
 {
     try
     {
         if (businessGridView.SelectedRows.Count != 0)
         {
             Clear();
             txtFantasyName.Text        = businessGridView.CurrentRow.Cells[1].Value.ToString();
             txtSocietyName.Text        = businessGridView.CurrentRow.Cells[2].Value.ToString();
             txtlegalCertification.Text = businessGridView.CurrentRow.Cells[3].Value.ToString();
             mtxtTelephone.Text         = businessGridView.CurrentRow.Cells[4].Value.ToString();
             txaMainAddress.Text        = businessGridView.CurrentRow.Cells[5].Value.ToString();
             txaGeneralAddress.Text     = businessGridView.CurrentRow.Cells[6].Value.ToString();
             txtEmail.Text   = businessGridView.CurrentRow.Cells[7].Value.ToString();
             txtWebPage.Text = businessGridView.CurrentRow.Cells[8].Value.ToString();
             logo            = (byte[])businessGridView.CurrentRow.Cells[9].Value;
             pbLogo.Image    = ImageManagement.ByteToImage((byte[])businessGridView.CurrentRow.Cells[9].Value);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        private void AddButton_Click(object sender, EventArgs e)
        {
            BrandModel       brand       = (BrandModel)BrandComboBox.SelectedItem;
            SubcategoryModel subcategory = (SubcategoryModel)SubcategoryComboBox.SelectedItem;
            bool             taxes       = true;

            if (exentoRadioButton.Checked)
            {
                taxes = false;
            }

            try
            {
                if (!string.IsNullOrEmpty(codeTextBox.Text) && ProductManagement.SelectProductByCode(codeTextBox.Text) == null)
                {
                    if (!string.IsNullOrEmpty(stockTextBox.Text))
                    {
                        if (!string.IsNullOrEmpty(unityPriceTextBox.Text))
                        {
                            if (!string.IsNullOrEmpty(descriptionTextBox.Text))
                            {
                                if (ProductManagement.InsertProduct(codeTextBox.Text, brand.Id_Brand.ToString(), subcategory.Id_Subcategory.ToString(), descriptionTextBox.Text,
                                                                    stockTextBox.Text, unityPriceTextBox.Text, lowerPriceTextBox1.Text, ImageManagement.ImageToByte(ImageManagement.TemporaryImage(ImgpictureBox.Image)), taxes))
                                {
                                    FrmMain.Instance.ToolStripLabel.Text = "Producto agregado de manera exitosa.";
                                    CleanProduct();
                                }
                                else
                                {
                                    MetroMessageBox.Show(this, $"Ha ocurrido un error al agregar el producto. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MetroMessageBox.Show(this, "La descripción no puede estar vacía.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "El precio no puede ser vacía.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "La catidad stock no puede ser vacía", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MetroMessageBox.Show(this, "El código de el producto no puede estar vacío, ni puede ser repetido.", "Error en el código", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void ModifyButton_Click(object sender, EventArgs e)
        {
            BrandModel       brand       = (BrandModel)BrandComboBox.SelectedItem;
            SubcategoryModel subcategory = (SubcategoryModel)SubcategoryComboBox.SelectedItem;
            bool             taxes       = true;

            if (exentoRadioButton.Checked)
            {
                taxes = false;
            }

            try
            {
                if (!string.IsNullOrEmpty(codeTextBox.Text) && (ProductManagement.SelectProductByCode(codeTextBox.Text) == null ||
                                                                ProductManagement.SelectProductByCode(codeTextBox.Text).Id_Product == int.Parse(ProductDataGridView.CurrentRow.Cells[0].Value.ToString())) && !IdLabel.Text.Equals("none"))
                {
                    if (!string.IsNullOrEmpty(descriptionTextBox.Text))
                    {
                        if (!string.IsNullOrEmpty(lowerPriceTextBox1.Text))
                        {
                            if (!string.IsNullOrEmpty(unityPriceTextBox.Text))
                            {
                                if (MetroMessageBox.Show(this, $"¿Seguro que desea modificar el Producto?", "Modificar Producto", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                                {
                                    if (ProductManagement.UpdateProductById(IdLabel.Text, codeTextBox.Text, brand.Id_Brand.ToString(), subcategory.Id_Subcategory.ToString(), stockTextBox.Text, descriptionTextBox.Text,
                                                                            unityPriceTextBox.Text, lowerPriceTextBox1.Text, ImageManagement.ImageToByte(ImageManagement.TemporaryImage(ImgpictureBox.Image)), taxes))
                                    {
                                        FrmMain.Instance.ToolStripLabel.Text = "Producto modificado de manera exitosa.";
                                        CleanProduct();
                                    }
                                    else
                                    {
                                        MetroMessageBox.Show(this, $"Ha ocurrido un error al modificar el Producto.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                            else
                            {
                                MetroMessageBox.Show(this, "El precio por unidad no puede estar vacío.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "El precio por mayor no puede estar vacío.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "La descripción no puede ser vacía.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MetroMessageBox.Show(this, "El Código no puede estar vacío, ni puede ser repetido.", "Error en el código", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                FrmMain.Instance.ToolStripLabel.Text = "Error: " + ex.Message;
            }
        }
        //----------------METODOS DATA GRID VIEW DE EL PRODUCTO---------------

        private void ProductDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            IdLabel.Text = ProductDataGridView.CurrentRow.Cells[0].Value.ToString();

            try
            {
                if (ProductDataGridView.SelectedRows[0] != null)
                {
                    ProductModel productModel = ProductManagement.SelectProductByID(ProductDataGridView.CurrentRow.Cells["Id_Product"].Value.ToString());

                    codeTextBox.Text        = Convert.ToString(productModel.Code);;
                    descriptionTextBox.Text = productModel.Description;
                    stockTextBox.Text       = Convert.ToString(productModel.Quantity_Stock);
                    unityPriceTextBox.Text  = Convert.ToString(productModel.Price);
                    lowerPriceTextBox1.Text = Convert.ToString(productModel.Lower_Price);

                    foreach (BrandModel item in BrandComboBox.Items)
                    {
                        int idBrand = productModel.Id_Brand;
                        if (item.Id_Brand == idBrand)
                        {
                            BrandComboBox.SelectedItem = item;
                        }
                    }

                    foreach (CategoryModel item2 in CategoryComboBox.Items)
                    {
                        SubcategoryModel sub = SubcategoryManagement.SelectSubCategoryById(productModel.Id_Subcategory);
                        CategoryModel    cat = CategoryManagement.SelectCategoryByID(sub.Id_Category.ToString());
                        if (item2.Id_Category == sub.Id_Category)
                        {
                            CategoryComboBox.SelectedItem = item2;
                            foreach (SubcategoryModel item in SubcategoryComboBox.Items)
                            {
                                if (item.Id_Subcategory == sub.Id_Subcategory)
                                {
                                    SubcategoryComboBox.SelectedItem = item;
                                }
                            }
                        }
                    }

                    if (productModel.Image == null)
                    {
                        ImgpictureBox.Image = null;
                    }
                    else
                    {
                        ImgpictureBox.Image = ImageManagement.ByteToImage(productModel.Image);
                    }

                    if (productModel.Ivi)
                    {
                        gravadoRadioButton.Select();
                    }
                    else
                    {
                        exentoRadioButton.Select();
                    }
                }
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, $"Ha ocurrido un error al seleccionar el producto.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void dgvProduct_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtCode.Text  = dgvProduct.CurrentRow.Cells[1].Value.ToString();
                txtStyle.Text = dgvProduct.CurrentRow.Cells[2].Value.ToString();
                //cmbBrand.SelectedItem = dgvProduct.CurrentRow.Cells[3].Value.ToString();
                txaDescription.Text = dgvProduct.CurrentRow.Cells[4].Value.ToString();
                //cmbSubcategory.SelectedItem = dgvProduct.CurrentRow.Cells[5].Value.ToString();
                txtNormalPrice.Text     = dgvProduct.CurrentRow.Cells[6].Value.ToString();
                txtLowerPrice.Text      = dgvProduct.CurrentRow.Cells[7].Value.ToString();
                txtEstableQuantity.Text = dgvProduct.CurrentRow.Cells[8].Value.ToString();
                txtEnterQuantity.Text   = dgvProduct.CurrentRow.Cells[9].Value.ToString();

                foreach (BrandModel item in cmbBrand.Items)
                {
                    int idBrand = int.Parse(dgvProduct.CurrentRow.Cells[3].Value.ToString());
                    if (item.idBrand == idBrand)
                    {
                        cmbBrand.SelectedItem = item;
                    }
                }

                foreach (SubCategoryModel item in cmbSubcategory.Items)
                {
                    int idSubCat = int.Parse(dgvProduct.CurrentRow.Cells[5].Value.ToString());

                    if (item.idsubCategory == idSubCat)
                    {
                        cmbSubcategory.SelectedItem = item;

                        foreach (CategoryModel item2 in cmbCategory.Items)
                        {
                            if (item2.idCategory == item.idCategory)
                            {
                                cmbCategory.SelectedItem = item2;
                            }
                        }
                    }
                }

                photo           = (byte[])dgvProduct.CurrentRow.Cells[10].Value;
                pbProduct.Image = ImageManagement.ByteToImage((byte[])dgvProduct.CurrentRow.Cells[10].Value);

                if (dgvProduct.CurrentRow.Cells[11].Value.Equals(true))
                {
                    rbIviRecorder.Select();
                }
                else
                {
                    rbIviExcent.Select();
                }

                if (dgvProduct.CurrentRow.Cells[12].Value.Equals(true))
                {
                    rbNonexistenPermit.Select();
                }
                else
                {
                    rbNonexistingNoPermit.Select();
                }
                txtCode.Focus();
            }
            catch (Exception)
            {
                throw;
            }
        }