function jsSMSAccountManage(){

};

$(function(){
    jsSMSAccountManage.LoadInfo();
});

jsSMSAccountManage.LoadInfo=function(){
    var strSql="select * from t_smsaccount";
    var strResult=DBReader.selectSqlForJson(strSql);
    if(strResult!=null)
    {
        var result=eval("[{"+strResult+"}]");
        if(result[0].table!=undefined){
            $("#txtComID").val(result[0].table[0].corporationid);
            $("#txtUserID").val(result[0].table[0].account);
            $("#txtPassword").val(result[0].table[0].passw);
        }
        result=null;
    }
    strSql=null;
    strResult=null;
    CollectGarbage();
};

jsSMSAccountManage.DelInfo=function(){
    var strSql="DELETE FROM t_smsaccount";
    DBReader.execSql(strSql);
    strSql=null;
    CollectGarbage();
};

/*保存短信帐户*/
jsSMSAccountManage.SaveAccountInfo=function(){
    var result =-1;
    jsSMSAccountManage.DelInfo();
    var strComID=$("#txtComID").val().split('\"').join('“').split('\'').join('‘');
    var strUserID=$("#txtUserID").val().split('\"').join('“').split('\'').join('‘');
    var strPassword=$("#txtPassword").val().split('\"').join('“').split('\'').join('‘');
    if(strComID=="" || strUserID=="" || strPassword==""){
        alert("输入内容不能为空值！");
    }
    else{
        var id=jsCommonLogic.selColumnData("ID","t_smsaccount","WHERE corporationid='"+strComID+"'");
        var entity=jsEntity.CreateEntityByTableName_access("t_smsaccount");  
        entity.Fields.account=strUserID;
        entity.Fields.passw=strPassword;
        entity.Fields.corporationid=strComID;
        if(id>0){
            entity.Fields.ID=id;
            entity.Update(entity);
        }
        else{
            entity.Insert(entity);
        }
        
        if(result){
            alert("短信帐户录入成功！");
        }
        else{
            alert("短信帐户录入失败！");
        }
        DBReader.DisposeEntity(entity);
        id=null;
    }
    strComID=null;
    strUserID=null;
    strPassword=null;
    result=null;
    CollectGarbage();
};