public CheckList_Chaves(Check check) { InitializeComponent(); this.check = check; int area = 0; //seta a area do alfa que verá as chaves try { area = Convert.ToInt32(check.Area); } catch { area = 1; } CheckListBLL BLL = new CheckListBLL(); chaves = BLL.ListaChaves(); //int count = 0; if (chaves != null) { //chavesA = chaves; // depois apagar foreach (Chave p in chaves) { int a1 = 1; try { a1 = Convert.ToInt32(p.Area); } catch { } if (area == a1) { chavesA.Add(p); } } //separação por área apos criar opção no banco if (chavesA != null) { checkBox1.Visible = true; checkBox1.Text = chavesA[0].Nome; if (chavesA.Count > 1) { checkBox2.Visible = true; checkBox2.Text = chavesA[1].Nome; } if (chavesA.Count > 2) { checkBox3.Visible = true; checkBox3.Text = chavesA[2].Nome; } if (chavesA.Count > 3) { checkBox4.Visible = true; checkBox4.Text = chavesA[3].Nome; } if (chavesA.Count > 4) { checkBox5.Visible = true; checkBox5.Text = chavesA[4].Nome; } if (chavesA.Count > 5) { checkBox6.Visible = true; checkBox6.Text = chavesA[5].Nome; } if (chavesA.Count > 6) { checkBox7.Visible = true; checkBox7.Text = chavesA[6].Nome; } if (chavesA.Count > 7) { checkBox8.Visible = true; checkBox8.Text = chavesA[7].Nome; } if (chavesA.Count > 8) { checkBox9.Visible = true; checkBox9.Text = chavesA[8].Nome; } if (chavesA.Count > 9) { checkBox10.Visible = true; checkBox10.Text = chavesA[9].Nome; } if (chavesA.Count > 10) { checkBox11.Visible = true; checkBox11.Text = chavesA[10].Nome; } if (chavesA.Count > 11) { checkBox12.Visible = true; checkBox12.Text = chavesA[11].Nome; } if (chavesA.Count > 12) { checkBox13.Visible = true; checkBox13.Text = chavesA[12].Nome; } if (chavesA.Count > 13) { checkBox14.Visible = true; checkBox14.Text = chavesA[13].Nome; } if (chavesA.Count > 14) { checkBox15.Visible = true; checkBox15.Text = chavesA[14].Nome; } if (chavesA.Count > 15) { checkBox16.Visible = true; checkBox16.Text = chavesA[15].Nome; } if (chavesA.Count > 16) { checkBox17.Visible = true; checkBox17.Text = chavesA[16].Nome; } if (chavesA.Count > 17) { checkBox18.Visible = true; checkBox18.Text = chavesA[17].Nome; } if (chavesA.Count > 18) { checkBox19.Visible = true; checkBox19.Text = chavesA[18].Nome; } if (chavesA.Count > 19) { checkBox20.Visible = true; checkBox20.Text = chavesA[19].Nome; } if (chavesA.Count > 20) { checkBox21.Visible = true; checkBox21.Text = chavesA[20].Nome; } if (chavesA.Count > 21) { checkBox22.Visible = true; checkBox22.Text = chavesA[21].Nome; } if (chavesA.Count > 22) { checkBox23.Visible = true; checkBox23.Text = chavesA[22].Nome; } if (chavesA.Count > 23) { checkBox24.Visible = true; checkBox24.Text = chavesA[23].Nome; } if (chavesA.Count > 24) { checkBox25.Visible = true; checkBox25.Text = chavesA[24].Nome; } if (chavesA.Count > 25) { checkBox26.Visible = true; checkBox26.Text = chavesA[25].Nome; } if (chavesA.Count > 26) { checkBox27.Visible = true; checkBox27.Text = chavesA[26].Nome; } if (chavesA.Count > 27) { checkBox28.Visible = true; checkBox28.Text = chavesA[27].Nome; } } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); check = Shared.Get(); Shared.Clean(); CheckListBLL BLL = new CheckListBLL(); chaves = BLL.ListaChaves(); //int count = 0; if (chaves != null) { foreach (Chave p in chaves) { if (p.Area.Equals(check.Area) && !p.Area.Equals("2")) { chavesA.Add(p); } if (p.Area.Equals("2")) { chavesA.Add(p); } } //PARAMETROS PARA OS INTENS LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); LayoutParams lpL = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.Height = 120; //LAYOUT PRINCIPAL QUE IRÀ DENTRO DO SCROLL LinearLayout layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; layout.LayoutParameters = lpL; //SCROLL DE ROLAGEM ScrollView scroll = new ScrollView(this); scroll.LayoutParameters = lpL; this.SetContentView(scroll); scroll.AddView(layout); TextView lblChaves = new TextView(this); lblChaves.Text = "Confira as Chaves!!!! =)"; lblChaves.SetTextSize(Android.Util.ComplexUnitType.Sp, 30); //ADICIONAR TUDO AO LAYOUT layout.AddView(lblChaves, lp); Button botao = new Button(this); botao.Text = "CONCLUIR"; if (chavesA != null) { foreach (Chave a in chavesA) { Switch s = new Switch(this); s.Text = a.Nome; //try { s.Id = Convert.ToInt32(a.Id); } catch { } s.SetTextSize(Android.Util.ComplexUnitType.Sp, 30); switches.Add(s); } } //for (int i = 0; i < 60; i++) //{ // Switch s = new Switch(this); // s.Text = "Texto do Switch..: " + i; // s.SetTextSize(Android.Util.ComplexUnitType.Sp, 30); // switches.Add(s); //} foreach (var s in switches) { layout.AddView(s, lp); } layout.AddView(botao, lp); botao.Click += delegate { Aguarde.MostraAguarde(true, this); var task = Task.Factory.StartNew(() => { certo = Cadastrar(); }); task.ContinueWith( t => { if (certo) { Toast.MakeText(this, "CHECKLIST FINALIZADO", ToastLength.Long).Show(); this.FinishAffinity(); } else { Toast.MakeText(this, "VERIFIQUE OS CAMPOS OBRIGATÓRIOS", ToastLength.Long).Show(); } Aguarde.MostraAguarde(false, this); }, TaskScheduler.FromCurrentSynchronizationContext()); // }; } }