Exemple #1
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;
            }
        }
 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 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;
            }
        }
        //----------------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);
            }
        }