Example #1
0
        private void dgvPedidos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                int id = Convert.ToInt32(dgvPedidos.Rows[e.RowIndex].Cells["PedidoId"].Value);

                if (e.ColumnIndex == 0)
                {
                    //Chamando formulário de cadastro/alteração.
                    var frms = this.MdiParent.MdiChildren.Where(f => f.Name.Contains("FrmCadastroPedidos"));
                    FrmCadastroPedidos frm = (FrmCadastroPedidos)frms.FirstOrDefault();

                    if (frm == null)
                    {
                        frm = new FrmCadastroPedidos();
                    }

                    frm.PedidoId = id;

                    frm.MdiParent   = this.MdiParent;
                    frm.WindowState = FormWindowState.Maximized;
                    frm.Show();
                }
                else if (e.ColumnIndex == 1)
                {
                    ExcluirPedido(id);
                }
            }
        }
Example #2
0
        private void cadastroToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var frms = this.MdiChildren.Where(f => f.Name.Contains("FrmCadastroPedidos"));
            FrmCadastroPedidos frm = (FrmCadastroPedidos)frms.FirstOrDefault();

            if (frm == null)
            {
                frm = new FrmCadastroPedidos();
            }

            frm.MdiParent   = this;
            frm.WindowState = FormWindowState.Maximized;
            frm.Show();
        }