예제 #1
0
 private void DgvArticle_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         //Ver
         if (DgvArticle.CurrentCell.ColumnIndex == 4)
         {
             //Enviamos el codigo del articuloa la variable static de la clase Article
             Article._code_static = DgvArticle.Rows[e.RowIndex].Cells[0].Value.ToString();
             //Instanciamos y abrimos el formulario de ver
             FrmArticleViewer articleViewer = new FrmArticleViewer();
             articleViewer.ShowDialog();
             if (articleViewer.DialogResult.Equals(DialogResult.Yes))
             {
                 Article._code_static = "";
             }
         }
         //Editar
         else if (DgvArticle.CurrentCell.ColumnIndex == 5)
         {
             //Enviamos el codigo del articuloa la variable static de la clase Article
             Article._code_static = DgvArticle.Rows[e.RowIndex].Cells[0].Value.ToString();
             //Instanciamos y abrimos el formulario de editar
             FrmArticleFields articleFields = new FrmArticleFields();
             articleFields.ShowDialog();
             if (articleFields.DialogResult.Equals(DialogResult.Yes))
             {
                 Article._code_static = "";
                 BtnReadAll_Click(sender, e);
             }
         }
         //Eliminar
         else if (DgvArticle.CurrentCell.ColumnIndex == 6)
         {
             if (orderArticleLog.ArticlesOrders(DgvArticle.Rows[e.RowIndex].Cells[0].Value.ToString()))
             {
                 DialogResult dr = MessageBox.Show("¿Desea eliminar el artículo?" +
                                                   Environment.NewLine + Environment.NewLine +
                                                   "Código: " + DgvArticle.Rows[e.RowIndex].Cells[0].Value.ToString() +
                                                   Environment.NewLine +
                                                   "Descripción: " + DgvArticle.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                                   "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dr == DialogResult.Yes)
                 {
                     //Eliminamos
                     articleLog.Delete(DgvArticle.Rows[e.RowIndex].Cells[0].Value.ToString());
                     //Actualizamos tabla
                     BtnReadAll_Click(null, e);
                 }
             }
             else
             {
                 MessageBox.Show("El artículo no se puede eliminar porque es utilizado en varias órdenes");
             }
         }
     }
 }
예제 #2
0
        //métodos de interfaz
        private void IbtnNew_Click(object sender, EventArgs e)
        {
            FrmArticleFields articleFields = new FrmArticleFields();

            articleFields.ShowDialog();
            //articleFields.FormClosed += ArticleFields_FormClosed;
            if (articleFields.DialogResult.Equals(DialogResult.Yes))
            {
                Article._code_static = "";
                BtnReadAll_Click(sender, e);
            }
        }