Пример #1
0
        private async void mnuRemain_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }

                var ret = await Utilities.PingHostAsync();

                if (ret.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(ret.ErrorMessage);
                    return;
                }


                var guid  = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var panel = await SmsPanelsBussines.GetAsync(guid);

                if (panel == null)
                {
                    return;
                }

                var api = new Sms.Api(panel.API.Trim());
                var res = api.AccountInfo();

                MessageBox.Show(this, $"مانده حساب پنل {panel.Name} {res.RemainCredit} ریال می باشد");
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #2
0
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                if (_st)
                {
                    if (MessageBox.Show(this,
                                        $@"آیا از حذف {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    var prd = await SmsPanelsBussines.GetAsync(guid);

                    res.AddReturnedValue(await prd.ChangeStatusAsync(false));
                }
                else
                {
                    if (MessageBox.Show(this,
                                        $@"آیا از فعال کردن {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟",
                                        "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    var prd = await SmsPanelsBussines.GetAsync(guid);

                    res.AddReturnedValue(await prd.ChangeStatusAsync(true));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در تغییر وضعیت پنل ارسال پیامک");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }