Example #1
0
        private static async void Targetbtn_clickAsync(dom.MouseEvent ev)
        {
            // ajax thứ nhất
            var GetTest = new AjaxTask
            {
                Url    = "http://localhost:52084/home/TestGet",
                Method = HttpMethod.GET,
                data   = new { }.ToDynamic()
            };
            dynamic Test1 = await GetTest.Execute();

            if (!GetTest.requestError)
            {
                dom.document.getElementById("targetbtn").innerHTML += ("get" + Test1.id);
            }

            // ajax thứ 2
            var PostTest = new AjaxTask
            {
                Url    = "http://localhost:52084/home/TestPost",
                Method = HttpMethod.POST,
                data   = new { }.ToDynamic()
            };
            dynamic Test2 = await PostTest.Execute();


            if (!PostTest.requestError)
            {
                dom.document.getElementById("targetbtn").innerHTML += ("post " + Test2.id);
            }
        }
Example #2
0
        /// <summary>
        ///  Xóa nhân viên khỏi danh sách nhân viên.
        /// </summary>
        /// <param name="StaffId"> Mã nhân viên </param>
        /// <returns></returns>
        private static async Task <bool> DeleteStaff(int StaffId)
        {
            var delete = new AjaxTask()
            {
                Async  = true,
                Method = HttpMethod.DELETE,
                Url    = "/Admin/DeleteStaff",
                data   = new Identifier()
                {
                    Id = StaffId
                }.As <dynamic>()
            };


            await delete.Execute();

            if (delete.requestError)
            {
                return(false);
            }

            var delete_result = delete.AjaxResult.As <AjaxResult>();

            return(delete_result.status == AjaxStatus.success);
        }
        public override async void dialogAction_onClickAsync(dom.MouseEvent evt)
        {
            Console.WriteLine("Người dùng ấn Cập nhật - editOrCreateStaff dialog");
            var confirmed = dom.confirm("Bạn có thưc sự muốn cập nhật ? ");

            GetUserInputs();

            if (confirmed && InputOk())
            {
                var updateSale = new AjaxTask()
                {
                    Async  = true,
                    Url    = "/Admin/UpdateStaff",
                    Method = HttpMethod.POST,
                    data   = new StaffManagerModelView
                    {
                        Id         = _Id,
                        Email      = edit_email,
                        PositionId = edit_positionid,
                        Name       = edit_name,
                        Skype      = edit_skype,
                        ChiefEmail = edit_chief_email
                    }.As <dynamic>()
                };

                var result = await updateSale.Execute();

                if (updateSale.requestError)
                {
                    dom.alert("Lỗi ajax");
                }
                else
                {
                    if (result.status == popupNotificationConst.Sucess)
                    {
                        kendGridReloadData(getKendoGrid("grid"));
                        ShowMessage("Cập nhật thành công", popupNotificationConst.Sucess);
                    }
                    else
                    {
                        ShowMessage("Lỗi xảy ra khi cập nhật", popupNotificationConst.Error);
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Gán từ khóa tìm kiếm vào session
        /// </summary>
        /// <param name="ev"></param>
        private async void setSearchKeyword(dom.KeyboardEvent ev)
        {
            //Trong hàm async thì từ khóa this vẫn giữ nguyên ý nghĩa.
            string requestUrl = string.Empty;

            dom.HTMLInputElement sourceTextBox = ev.srcElement.As <dom.HTMLInputElement>();


            if (sourceTextBox.value.Length < Const.Search.MinKeywordLength)
            {
                return;
            }

            switch (sourceTextBox.id)
            {
            case Const.StaffManager.txtEmail1Id:
            case Const.StaffManager.txtEmail2Id:

                requestUrl = "/Admin/SetKeywordForSearchStaff";
                break;

            default:
                return;
            }

            //Chờ người dùng thêm 0.2 giây
            await Task.Delay(200);

            if (ev.type == "keypress" || ev.keyCode == Functions.Const.Keyboard.Enter)
            {
                var SetKeywordFortxtEmailAutoComplete = new AjaxTask()
                {
                    Url    = requestUrl,
                    Method = HttpMethod.POST,
                    data   = new Search()
                    {
                        Keyword = sourceTextBox.value
                    }.ToDynamic()
                };
                await SetKeywordFortxtEmailAutoComplete.Execute();
            }
        }
Example #5
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var Ajax = new AjaxTask()
                {
                    Url    = "https://account.esms.vn/Admin/Salesby",
                    Method = HttpMethod.GET,
                };
                await Ajax.Execute();

                if (!Ajax.requestError)
                {
                    var message = "Lấy dữ liệu thành công";
                    var data    = Ajax.AjaxResult.As <SaleInfo[]>();
                    var counter = 0;
                    // lấy 3 thằng sale đầu tiên
                    foreach (var sale in data)
                    {
                        message += $" id = {sale.Id} , tên = {sale.SaleBy} ";

                        counter++;
                        if (counter == 3)
                        {
                            break;
                        }
                    }

                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show("Lỗi Ajax");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show($"Exception : {err.Message}");
            }
        }
Example #6
0
        public async void email_onchange(dom.FocusEvent ev)
        {
            dom.document.getElementById("name").addEventListener("onfocusout", (e) =>
            {
                dom.document.getElementById("name").onfocus = null;
            });

            var input_email = getValueById <string>("email");

            if (input_email.Length < 5 || !input_email.Contains("@"))
            {
                return;
            }

            var GetUserInfo = new AjaxTask()
            {
                Method = HttpMethod.GET,

                data = new
                {
                    email = input_email
                }.ToDynamic(),

                Url = "/Admin/GetUserInfo"
            };
            await GetUserInfo.Execute();

            if (!GetUserInfo.requestError)
            {
                var userinfo = GetUserInfo.AjaxResult.ToDynamic();
                if (!string.IsNullOrWhiteSpace(userinfo.name))
                {
                    setValue("name", userinfo.name);
                }
            }
        }