Ejemplo n.º 1
0
        private List <GetQTitle> GetQTitleList(string t_id)
        {
            listGetQTitle.Clear();
            wcf.parti.Service1 _parti     = new wcf.parti.Service1();
            partiDB.RootObject rootObject = new partiDB.RootObject();
            if (listGetQTitle.Count == 0)
            {
                string json_str = _parti.GetQTitle(t_id);
                if (json_str == "e0")//code error
                {
                    MessageBox.swalModal(_Page, "error", "e0:ລະບົບຂັດຂ້ອງຕິດຕໍ່ຜູ້ເບີ່ງແຍ່ງດ່ວນ.", "");
                }
                else if (json_str == "e1")//no data found
                {
                    MessageBox.swalModal(_Page, "info", "e1:ບໍ່ມີຂໍ້ມູນທີ່ຈະສະແດງ.", "");
                }
                else if (json_str == "e2")//can't connect databbase
                {
                    MessageBox.swalModal(_Page, "warning", "e2:ບໍ່ສາມາດເຊື່ອມຕໍ່ຖານຂໍ້ມູນໄດ້.", "");
                }
                else
                {
                    var i = 1;
                    rootObject = JsonConvert.DeserializeObject <partiDB.RootObject>(json_str);
                    foreach (var vl in rootObject.GetQTitle)
                    {
                        listGetQTitle.Add(new GetQTitle(vl.t_id, vl.title_name, vl.training_id, vl.date_of_modified_data, vl.q_type));
                        HtmlElement _tbody = new HtmlElement();
                        var         QType  = "";

                        if (vl.q_type == "b")
                        {
                            QType = "ຄຳຖາມກ່ອນຝຶກ";
                        }
                        else if (vl.q_type == "a")
                        {
                            QType = "ຄຳຖາມຫຼັງຝຶກ";
                        }

                        _tbody.InnerHtml = "<tr class='evalist'><td class='col s1 m1 l1'>" + i + "</td>" +
                                           "<td class='col s2 m2 l2'>" + vl.t_id + "</td>" +
                                           "<td class='col s4 m4 l4'>" + vl.title_name + "</td>" +
                                           "<td class='col s2 m2 l2'>" + QType + " </td>" +
                                           "<td class='col s3 m3 l3 center'><div class='row right'><div class='col'>" +
                                           "<a class='btn-floating waves-effect tooltipped hvr-grow-shadow' data-position='left' data-tooltip='ແກ້ໄຂ' " +
                                           "id='btnEdit" + i + "' name='" + vl.t_id + "' onclick='GetQInfo(" + (i - 1) + ", this.name)'><i class='material-icons right'>edit</i>" +
                                           "</a></div><div class='col'><a class='btn-floating waves-effect tooltipped hvr-grow-shadow' data-position='top' " +
                                           "data-tooltip='ເປີດຫນ້າແບບຟອມສຳລັບຜູ້ຝຶກ' id='btnEvaLink" + i + "' name='" + vl.t_id + "' onclick='GenLink(this.name, " + i + ")'>" +
                                           "<i class='material-icons right'>open_in_new</i></a></div><div class='col'><a class='btn-floating waves-effect tooltipped hvr-grow-shadow modal-trigger' data-position='right' " +
                                           "data-tooltip='ສ້າງ QR Code ສຳລັບແບບຟອມນີ້' id='btnQRGent" + i + "' name='" + vl.t_id + "' onclick='GenQRCode(this.name, " + i + ")'><i class='fas fa-qrcode'></i></a></div></div></td></tr>";
                        tbody.Controls.Add(_tbody);
                        i++;
                    }
                }
            }
            return(listGetQTitle);
        }