Esempio n. 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (objGru.gru_codigo != 0)
         {
             //Verificar se possui um subgrupo vinculado ao grupo
             SubGrupoBLL objSG = new SubGrupoBLL();
             objSG.localizar(objGru.gru_codigo.ToString(), "sg_grupo");
             if (objSG.sg_grupo != 0)
             {
                 throw new Exception("Este grupo possui subgrupos vinculados a ele, por favor, exclua estes subgrupos para que este grupo possa ser excluído");
             }
             if (MessageBox.Show("Deseja realmente excluir?", "Excluir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
             {
                 objGru.excluir();
                 objGru.limpar();
                 limpar();
                 carregaGrid();
                 MessageBox.Show("Grupo excluído com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
             }
         }
         else
         {
             MessageBox.Show("Favor selecionar uma grupo na aba 'Pesquisar', ou escolher um código válido para poder excluir", "Excluir", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         }
     }
     catch (SqlException)
     {
         MessageBox.Show("Este grupo está vinculado a alguma movimentação do sistema e não pode ser excluído", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Esempio n. 2
0
            public GruposCelula()
            {
                var excluirGrupo = new MenuItem
                {
                    Text = "Excluir"
                };

                excluirGrupo.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                excluirGrupo.Clicked += (sender, e) =>
                {
                    GrupoInfo grupo      = (GrupoInfo)((MenuItem)sender).BindingContext;
                    GrupoBLL  regraGrupo = GrupoFactory.create();
                    regraGrupo.excluir(grupo.Id);

                    ListView listaGrupos = this.Parent as ListView;

                    listaGrupos.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
                    listaGrupos.RowHeight = 120;
                    var grupos = regraGrupo.listar();
                    listaGrupos.BindingContext = grupos;
                    listaGrupos.ItemTemplate   = new DataTemplate(typeof(GruposCelula));
                };
                ContextActions.Add(excluirGrupo);

                StackLayout main = new StackLayout();

                main.BackgroundColor   = Color.Transparent;
                main.Orientation       = StackOrientation.Horizontal;
                main.VerticalOptions   = LayoutOptions.StartAndExpand;
                main.HorizontalOptions = LayoutOptions.CenterAndExpand;

                StackLayout stackRight = new StackLayout();

                stackRight.Orientation       = StackOrientation.Vertical;
                stackRight.VerticalOptions   = LayoutOptions.CenterAndExpand;
                stackRight.HorizontalOptions = LayoutOptions.StartAndExpand;

                StackLayout stackLeft = new StackLayout();

                stackLeft.Orientation       = StackOrientation.Vertical;
                stackLeft.VerticalOptions   = LayoutOptions.StartAndExpand;
                stackLeft.HorizontalOptions = LayoutOptions.StartAndExpand;


                Image foto = new Image()
                {
                    WidthRequest      = 50,
                    HeightRequest     = 50,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    Source            = "ic_add_a_photo_48pt.png"
                };
                //foto.SetBinding(Image.SourceProperty, new Binding("Imagem"));

                Label nome = new Label
                {
                    TextColor         = Color.FromHex(TemaInfo.PrimaryText),
                    FontFamily        = "Roboto-Condensed",
                    FontSize          = 20,
                    HorizontalOptions = LayoutOptions.Start,
                    VerticalOptions   = LayoutOptions.Center,
                };

                nome.SetBinding(Label.TextProperty, new Binding("NomeStr"));


                Label descricao = new Label
                {
                    TextColor         = Color.FromHex(TemaInfo.PrimaryText),
                    FontFamily        = "Roboto-Condensed",
                    FontSize          = 20,
                    HorizontalOptions = LayoutOptions.Start,
                    VerticalOptions   = LayoutOptions.Center,
                };

                descricao.SetBinding(Label.TextProperty, new Binding("DescricaoStr"));


                var frameOuter = new Frame();

                frameOuter.BackgroundColor = Color.FromHex(TemaInfo.BlueAccua);
                frameOuter.HeightRequest   = AbsoluteLayout.AutoSize;
                if (Device.OS == TargetPlatform.iOS)
                {
                    foto.WidthRequest = 60;

                    //frameOuter.Padding = new Thickness(5, 10, 5, 10);
                    frameOuter.WidthRequest = TelaUtils.Largura * 0.9;
                    frameOuter.Margin       = new Thickness(5, 10, 5, 0);
                }
                else
                {
                    frameOuter.Margin = new Thickness(5, 10, 5, 10);
                }

                stackLeft.Children.Add(foto);
                stackRight.Children.Add(nome);
                stackRight.Children.Add(descricao);

                main.Children.Add(stackLeft);
                main.Children.Add(stackRight);

                frameOuter.Content = main;

                View = frameOuter;
            }