示例#1
0
        async void OnTapped2(Parm1 tt2)
        {
            test_add = 1;
            await tt2.Img.FadeTo(0.7, 100);

            await tt2.Img.FadeTo(1, 200);

            if (dt_q_answer.Rows.Count == 0)
            {
                dt_q_answer.Rows.Add(tt2.Q_id, tt2.A_id);
            }
            else
            {
                int ts = 0;
                try
                {
                    DataRow[] fr = dt_q_answer.Select();
                    for (int i = 0; i < fr.Length; i++)
                    {
                        if (Convert.ToInt32(fr[i]["q_id"].ToString()) == tt2.Q_id)
                        {
                            dt_q_answer.Rows.RemoveAt(i);
                            break;
                        }
                    }
                    ts = 1;
                }
                catch
                {
                    ts = 0;
                }
                if (ts == 0)
                {
                    try
                    {
                        DataRow[] fr = dt_q_answer.Select();
                        for (int i = 0; i < fr.Length; i++)
                        {
                            if (Convert.ToInt32(fr[i]["q_id"].ToString()) == tt2.Q_id)
                            {
                                dt_q_answer.Rows.RemoveAt(i);
                                break;
                            }
                        }
                        ts = 1;
                    }
                    catch
                    {
                        ts = 0;
                    }
                }
                if (ts == 1)
                {
                    dt_q_answer.Rows.Add(tt2.Q_id, tt2.A_id);
                }
            }
            get_qus(ini);
        }
示例#2
0
        public UpdateQuestion()
        {
            InitializeComponent();
            App.test_add_update = "UpdateQ";
            if (dt_answer.Columns.Count == 0)
            {
                dt_answer.Columns.Add("id", typeof(int));
                dt_answer.Columns.Add("answer_text", typeof(string));
                dt_answer.Columns.Add("correct", typeof(int));
            }
            MessagingCenter.Subscribe <AddAnswer>(this, "ref", (sender) =>
            {
                IsBusy = true;

                Refsh();
            });
            DellAnswer    = new Command <Parm1>((Parm1 parameter) => OnTapped(parameter));
            CorrectAnswer = new Command <Parm1>((Parm1 parameter) => OnTapped2(parameter));
            DataRow[] fr = QuestionsBank1.dt_Question.Select("q_id=" + QuestionsBank1.QID);
            if (fr.Length > 0)
            {
                dt_answer.Rows.Clear();
                QuestionNo.Text        = fr[0]["q_name"].ToString();
                ExamType.SelectedIndex = Convert.ToInt32(fr[0]["q_type"].ToString());
                mark.Text         = fr[0]["q_mark"].ToString();
                QuestionText.Text = fr[0]["q_text"].ToString();
                stk_answer.Children.Clear();
                DataRow[] fr2 = QuestionsBank1.dt_Answer.Select("q_id=" + QuestionsBank1.QID);

                Grid grd1 = new Grid {
                    ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA")
                };
                grd1.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Star
                });
                for (int i = 0; i < fr2.Length; i++)
                {
                    dt_answer.Rows.Add(Convert.ToInt32(fr2[i]["id"].ToString()), fr2[i]["a_text"].ToString(), Convert.ToInt32(fr2[i]["a_correct"].ToString()));



                    grd1.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });
                    StackLayout stk_c = new StackLayout {
                        Orientation = StackOrientation.Horizontal, Margin = 5
                    };
                    ImageButton img1 = new ImageButton
                    {
                        BackgroundColor = Color.Transparent,
                        Source          = "CloseIcon.png",
                        HeightRequest   = 30,
                        WidthRequest    = 30,
                    };
                    img1.BindingContext = this;
                    img1.SetBinding(ImageButton.CommandProperty, new Binding("DellAnswer", 0));
                    var c1 = new Parm1 {
                        Answer_id = Convert.ToInt32(fr2[i]["id"].ToString())
                    };
                    img1.CommandParameter = c1;

                    ImageButton img2 = new ImageButton
                    {
                        Source          = "choise1.png",
                        HeightRequest   = 30,
                        WidthRequest    = 30,
                        BackgroundColor = Color.Transparent,
                    };
                    img2.BindingContext = this;
                    img2.SetBinding(ImageButton.CommandProperty, new Binding("CorrectAnswer", 0));
                    img2.CommandParameter = c1;

                    if (Convert.ToInt32(fr2[i]["a_correct"].ToString()) == 1)
                    {
                        img2.Source = "choise2.png";
                    }
                    Label lb1 = new Label
                    {
                        Text              = fr2[i]["a_text"].ToString(),
                        TextColor         = Color.FromHex("#2E2E2E"),
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    };

                    stk_c.Children.Add(img1);
                    stk_c.Children.Add(lb1);
                    stk_c.Children.Add(img2);

                    grd1.Children.Add(stk_c, 0, i);
                }
                stk_answer.Children.Add(grd1);
            }
        }
示例#3
0
        void Refsh()
        {
            stk_answer.Children.Clear();


            DataRow[] fr = dt_answer.Select("", "id");
            if (fr.Length > 0)
            {
                Grid grd1 = new Grid {
                    ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA")
                };
                grd1.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Star
                });


                for (int i = 0; i < fr.Length; i++)
                {
                    grd1.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });
                    StackLayout stk_c = new StackLayout {
                        Orientation = StackOrientation.Horizontal, Margin = 5
                    };
                    ImageButton img1 = new ImageButton
                    {
                        BackgroundColor = Color.Transparent,
                        Source          = "CloseIcon.png",
                        HeightRequest   = 30,
                        WidthRequest    = 30,
                    };
                    img1.BindingContext = this;
                    img1.SetBinding(ImageButton.CommandProperty, new Binding("DellAnswer", 0));
                    var c1 = new Parm1 {
                        Answer_id = Convert.ToInt32(fr[i]["id"].ToString())
                    };
                    img1.CommandParameter = c1;

                    ImageButton img2 = new ImageButton
                    {
                        Source          = "choise1.png",
                        HeightRequest   = 30,
                        WidthRequest    = 30,
                        BackgroundColor = Color.Transparent,
                    };
                    img2.BindingContext = this;
                    img2.SetBinding(ImageButton.CommandProperty, new Binding("CorrectAnswer", 0));
                    img2.CommandParameter = c1;

                    if (Convert.ToInt32(fr[i]["correct"].ToString()) == 1)
                    {
                        img2.Source = "choise2.png";
                    }
                    Label lb1 = new Label
                    {
                        Text              = fr[i]["answer_text"].ToString(),
                        TextColor         = Color.FromHex("#2E2E2E"),
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    };

                    stk_c.Children.Add(img1);
                    stk_c.Children.Add(lb1);
                    stk_c.Children.Add(img2);

                    grd1.Children.Add(stk_c, 0, i);
                }
                stk_answer.Children.Add(grd1);
            }
        }
示例#4
0
        void get_qus(int ii)
        {
            test_add = 0;
            stk_answer.Children.Clear();
            QuestionText.Text = q_fr[ii]["q_text"].ToString();
            DataRow[] fr;
            DataRow[] cr;
            qid           = Convert.ToInt32(q_fr[ii]["q_id"].ToString());
            qus_Name.Text = "Question -" + (ii + 1);
            fr            = ExamView_s.Answ.Select("exam_id=" + ExamView_s.EID + " and q_id=" + Convert.ToInt32(q_fr[ii]["q_id"].ToString()));
            if (fr.Length > 0)
            {
                Grid grd1 = new Grid {
                    RowSpacing = 5, ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA")
                };
                grd1.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Star
                });
                for (int i = 0; i < fr.Length; i++)
                {
                    grd1.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });
                    StackLayout stk_c = new StackLayout {
                        Orientation = StackOrientation.Horizontal, Margin = 5
                    };
                    ImageButton img2 = new ImageButton
                    {
                        Source          = "choise1.png",
                        HeightRequest   = 30,
                        WidthRequest    = 30,
                        BackgroundColor = Color.Transparent,
                    };
                    cr = dt_q_answer.Select("q_id=" + Convert.ToInt32(q_fr[ii]["q_id"].ToString()) + " and id=" + Convert.ToInt32(fr[i]["id"].ToString()));
                    if (cr.Length == 1)
                    {
                        img2.Source = "choise2.png";
                    }
                    var c1 = new Parm1 {
                        Img = img2, A_id = Convert.ToInt32(fr[i]["id"].ToString()), Q_id = Convert.ToInt32(q_fr[ii]["q_id"].ToString())
                    };
                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("CorrectAnswer", 0));
                    tapGestureRecognizer.BindingContext   = this;
                    tapGestureRecognizer.CommandParameter = c1;

                    img2.BindingContext = this;
                    img2.SetBinding(ImageButton.CommandProperty, new Binding("CorrectAnswer", 0));
                    img2.CommandParameter = c1;


                    stk_c.GestureRecognizers.Add(tapGestureRecognizer);
                    Label lb1 = new Label
                    {
                        VerticalOptions   = LayoutOptions.Center,
                        Margin            = new Thickness(5, 0, 5, 0),
                        Text              = fr[i]["a_text"].ToString(),
                        TextColor         = Color.FromHex("#2E2E2E"),
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    };
                    stk_c.Children.Add(lb1);
                    stk_c.Children.Add(img2);
                    grd1.Children.Add(stk_c, 0, i);
                }
                stk_answer.Children.Add(grd1);
                if (ii == 0)
                {
                    prb_but.IsVisible    = false;
                    nxt_but.IsVisible    = true;
                    finish_but.IsVisible = false;
                }
                if (ii > 0)
                {
                    prb_but.IsVisible    = true;
                    nxt_but.IsVisible    = true;
                    finish_but.IsVisible = false;
                }
                if (ii == (q_fr.Length - 1))
                {
                    prb_but.IsVisible    = true;
                    nxt_but.IsVisible    = false;
                    finish_but.IsVisible = true;
                }
            }
        }