package sms;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.infobank.sms.Client;
public class Sms
{
private Text text_11;
private Text text_12;
private Text text_10;
private Text text_6;
private Text text_9;
private Text text_8;
private Text text_7;
private Text text_5;
private Text text_4;
private Text text_3;
private Text text_2;
private Text text_1;
private Text text;
private String result;//result为函数的返回值
// 定义client对象,以调用它的函数
Client func = new Client();
// 用户名ID,密码,所属代理商 ,扩展位,手机号码,关键字,短信内容,发送时间
String szUserID, szPassword, szCPN, szCallback, szDestination, szKeyword, szContents, szDatetime;
// 新密码
String newpw;
public static void main(String[] args)
{
try
{
// 初始化
Sms window = new Sms();
// 调用函数,实现发送等功能
window.open();
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Open the window
*/
public void open()
{
final Display display = Display.getDefault();
final Shell smsShell = new Shell(SWT.CLOSE);
// 加载左上角的图片
smsShell.setImage(SWTResourceManager.getImage(Sms.class, "/img/logo.png"));
// 定义窗体大小
smsShell.setSize(512, 501);
// 定义窗体名称
smsShell.setText("SMS TEST");
//
smsShell.open();
final Group group = new Group(smsShell, SWT.NONE);
group.setBounds(11, 20, 201, 113);
group.setText("帐号");
final Label label_1 = new Label(group, SWT.NONE);
label_1.setText("用户名");
label_1.setBounds(31, 20, 42, 12);
final Label label_2 = new Label(group, SWT.NONE);
label_2.setText("密码");
label_2.setBounds(31, 51, 33, 12);
final Label label_3 = new Label(group, SWT.NONE);
label_3.setText("所属代理商");
label_3.setBounds(31, 82, 69, 12);
text_1 = new Text(group, SWT.BORDER);
text_1.setBounds(112, 17, 80, 25);
text_2 = new Text(group, SWT.BORDER);
text_2.setBounds(112, 48, 80, 25);
text_3 = new Text(group, SWT.BORDER);
text_3.setText("ibc");
text_3.setBounds(112, 79, 80, 25);
final Group group_1 = new Group(smsShell, SWT.NONE);
group_1.setBounds(223, 20, 150, 114);
group_1.setText("密码修改");
final Label label_4 = new Label(group_1, SWT.NONE);
label_4.setText("请输入新密码");
// 定义一个按钮,功能为修改密码
final Button button = new Button(group_1, SWT.NONE);
button.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(final SelectionEvent e)
{
// 从text获取用户名等
szUserID = text_1.getText();
szPassword = text_2.getText();
szCPN = text_3.getText();
newpw = text_4.getText();
// 调用修改密码函数
result = func.changePwd(szUserID, szPassword, szCPN, newpw);
text.setText("" + result); //显示函数的返回值
}
});
label_4.setBounds(18, 20, 75, 12);
button.setText("修改密码");
button.setBounds(25, 78, 65, 22);
text_4 = new Text(group_1, SWT.BORDER);
text_4.setBounds(16, 42, 80, 25);
final Group group_2 = new Group(smsShell, SWT.NONE);
group_2.setText("短信息发送");
group_2.setBounds(11, 142, 477, 155);
final Label label_5 = new Label(group_2, SWT.NONE);
label_5.setText("扩展位");
label_5.setBounds(18, 25, 54, 12);
final Label label_5_1 = new Label(group_2, SWT.NONE);
label_5_1.setBounds(18, 54, 64, 12);
label_5_1.setText("手机号列表");
final Label label_5_2 = new Label(group_2, SWT.NONE);
label_5_2.setBounds(18, 82, 70, 12);
label_5_2.setText("关键词列表");
final Label label_5_3 = new Label(group_2, SWT.NONE);
label_5_3.setBounds(18, 113, 66, 12);
label_5_3.setText("发送时间");
text_5 = new Text(group_2, SWT.BORDER);
text_5.setBounds(98, 21, 93, 22);
text_7 = new Text(group_2, SWT.BORDER);
text_7.setBounds(98, 51, 93, 22);
text_8 = new Text(group_2, SWT.BORDER);
text_8.setBounds(98, 80, 93, 22);
text_9 = new Text(group_2, SWT.BORDER);
text_9.setBounds(98, 110, 93, 22);
final Label label_6 = new Label(group_2, SWT.NONE);
label_6.setText("短信内容");
label_6.setBounds(302, 17, 57, 12);
text_6 = new Text(group_2, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
text_6.setBounds(205, 34, 254, 79);
// 定义一个按钮,功能为发送短信
final Button button_1 = new Button(group_2, SWT.NONE);
button_1.setText("发送");
button_1.setBounds(305, 118, 48, 22);
button_1.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(final SelectionEvent e)
{
// 从text获取用户名等
szUserID = text_1.getText();
szPassword = text_2.getText();
szCPN = text_3.getText();
szCallback = text_5.getText();
szDestination = text_7.getText();
szKeyword = text_8.getText();
szContents = text_6.getText();
szDatetime = text_9.getText();
// if(szPassword.equals(""))
// 调用发送函数
result = func.smsSend(szUserID, szPassword, szCPN, szCallback, szDestination, szKeyword, szContents, szDatetime);
text.setText("" + result); //显示函数的返回值
}
});
final Group group_3 = new Group(smsShell, SWT.NONE);
group_3.setText("信息管理");
group_3.setBounds(11, 303, 218, 154);
final Label label_7 = new Label(group_3, SWT.NONE);
label_7.setText("返回结果");
label_7.setBounds(72, 23, 55, 12);
// 定义一个按钮,功能为用户认证
final Button button_2 = new Button(group_3, SWT.NONE);
button_2.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(final SelectionEvent e)
{
//StringBuffer为一个可变对象,通过smsUser函数修改之后,赋值给text_10,做为返回结果
StringBuffer szResult = new StringBuffer();
// 从text获取用户名等
szUserID = text_1.getText();
szPassword = text_2.getText();
szCPN = text_3.getText();
// 调用用户认证函数
result = func.smsUser(szUserID, szPassword, szCPN, szResult);
text.setText(result); //显示函数的返回值
text_10.setText("" + szResult);//显示函数的返回结果
}
});
button_2.setText("用户认证");
button_2.setBounds(8, 123, 55, 22);
// 定义一个按钮,功能为用户帐户查询
final Button button_2_1 = new Button(group_3, SWT.NONE);
button_2_1.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(final SelectionEvent e)
{
// 从text获取用户名等
StringBuffer szResult = new StringBuffer();
szUserID = text_1.getText();
szPassword = text_2.getText();
szCPN = text_3.getText();
// 调用用户帐户查询函数
result = func.smsCount(szUserID, szPassword, szCPN, szResult);
text.setText(result);//显示函数的返回值
text_10.setText("" + szResult);//显示函数的返回结果
}
});
button_2_1.setBounds(68, 123, 81, 22);
button_2_1.setText("账户信息查询");
text_10 = new Text(group_3, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
text_10.setEditable(false);
text_10.setBounds(10, 41, 198, 70);
// 定义一个按钮,功能为接受短信
final Button button_2_2 = new Button(group_3, SWT.NONE);
button_2_2.setBounds(153, 123, 60, 22);
button_2_2.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(final SelectionEvent e)
{
// 从text获取用户名等
StringBuffer szResult = new StringBuffer();
szUserID = text_1.getText();
szPassword = text_2.getText();
szCPN = text_3.getText();
//调用短信接受函数
result = func.smsReceive(szUserID, szPassword, szCPN, szResult);
text.setText(result);
text_10.setText("" + szResult);
}
});
button_2_2.setText("接收短信");
final Group group_4 = new Group(smsShell, SWT.NONE);
grou
评论0