基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
using Lskj.Control;
|
||||
using Lskj.Control.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.PubInvoiceOut
|
||||
{
|
||||
public partial class FrmSendCode : BaseForm
|
||||
{
|
||||
public EventHandler<ResultEventArgs> SendCodeCallback;
|
||||
public EventHandler<ResultEventArgs> LoginCallback;
|
||||
public System.Timers.Timer timer = new System.Timers.Timer();
|
||||
public string SendCode { get { return this.codeText.Text; } }
|
||||
public FrmSendCode()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Load += OnSendCodeControlLoad;
|
||||
this.sendBtn.Click += OnSendBtnClick;
|
||||
this.okBtn.Click += OnOkBtn_Click;
|
||||
this.FormClosing += OnFormClosing;
|
||||
}
|
||||
|
||||
private void OnOkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
WaitForm.ShowForm("正在确认验证码...");
|
||||
ResultEventArgs resultEventArgs = new ResultEventArgs();
|
||||
if (LoginCallback != null)
|
||||
{
|
||||
LoginCallback(null, resultEventArgs);
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer.Dispose();
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowTips(resultEventArgs.Message);
|
||||
}
|
||||
}
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
|
||||
private void OnSendBtnClick(object sender, EventArgs e)
|
||||
{
|
||||
WaitForm.ShowForm("正在发送验证码...");
|
||||
ResultEventArgs resultEventArgs = new ResultEventArgs();
|
||||
if (SendCodeCallback != null)
|
||||
{
|
||||
SendCodeCallback(null, resultEventArgs);
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
this.sendBtn.Tag = 60;
|
||||
this.sendBtn.Text = string.Format("发送({0})", this.sendBtn.Tag);
|
||||
this.sendBtn.Enabled = false;
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(resultEventArgs.Message);
|
||||
}
|
||||
}
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
|
||||
private void OnSendCodeControlLoad(object sender, EventArgs e)
|
||||
{
|
||||
this.sendBtn.Text = "发送";
|
||||
timer.Interval = 1000;
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
ResultEventArgs resultEventArgs = new ResultEventArgs();
|
||||
if (SendCodeCallback != null)
|
||||
{
|
||||
SendCodeCallback(null, resultEventArgs);
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
this.sendBtn.Tag = 60;
|
||||
this.sendBtn.Text = string.Format("{0}s", this.sendBtn.Tag);
|
||||
this.sendBtn.Enabled = false;
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(resultEventArgs.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.timer.Enabled = false;
|
||||
int time = Convert.ToInt32(this.sendBtn.Tag) - 1;
|
||||
if (time == 0)
|
||||
{
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.sendBtn.Enabled = true;
|
||||
this.sendBtn.Text = "发送";
|
||||
this.timer.Enabled = false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.sendBtn.Enabled = false;
|
||||
this.sendBtn.Tag = time;
|
||||
this.sendBtn.Text = string.Format("发送({0})", this.sendBtn.Tag);
|
||||
}));
|
||||
}
|
||||
}
|
||||
this.timer.Enabled = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer.Dispose();
|
||||
}
|
||||
|
||||
public void ShowTips(string msg)
|
||||
{
|
||||
this.toolTip.Show(msg, this.codeText, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user