ExampleI have been asked to write a formula that will conditionally display text on a single field if item numbers on an order are a of a certain value.
So if any of the items on an order match the following values:
>{oeordlin_sql.item_no} = '022471-2000'
>{oeordlin_sql.item_no} = '142846-003'
>{oeordlin_sql.item_no} = '202522-2000'
>{oeordlin_sql.item_no} = '022468-2000'
>{oeordlin_sql.item_no} = '022471-2000'
>{oeordlin_sql.item_no} = '202522-2010'
>{oeordlin_sql.item_no} = '202258-01'
>{oeordlin_sql.item_no} = '142845-002'
>{oeordlin_sql.item_no} = '142847-20204'
>{oeordlin_sql.item_no} = '142848-01402'
>{oeordlin_sql.item_no} = '142848-01408'
>{oeordlin_sql.item_no} = '142849-001'
Then return a text line saying "Class VI Certification Required"
Otherwise nothing should be printed.
Currently I have:
If {oeordlin_sql.item_no} = '022471-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142846-003'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202522-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '022468-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '022471-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202522-2010'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202258-01'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142845-002'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142847-20204'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142848-01402'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142848-01408'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142849-001'
Then "Class VI certificate Required"
else ""
This works to a point, but it generates extra pages for every part, the report should be a single page.
How can I get this to print out the text field on the single page if any of the part numbers match without it generating a new page for each?
I was able to get this to work by using
edit formula:
If {oeordlin_sql.item_no} = '022471-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142846-003'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202522-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '022468-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '022471-2000'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202522-2010'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '202258-01'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142845-002'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142847-20204'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142848-01402'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142848-01408'
Then "Class VI certificate Required"
else if {oeordlin_sql.item_no} = '142849-001'
Then "Class VI certificate Required"
else "suppress"
then going to select expert:
and setting #Class VI Cert to "is not equal to 'suppress'"
then Format field:
Suppress If Duplicated
Related
I am making registration/login form with qt c++ saving registration information in mysql password is hashed by md5 also I've tried sha256 same there, so main problem it saves password hashed and I've got no problem with that but when i'm comparing it in login window it doesn't compares and password wrong message appears. without hashing everything works fine, with hashing checking problem. Thanks for help))
if (db.open()) {
QString email = ui->email->text();
QString password = QString("%1").arg(QString(QCryptographicHash::hash(ui->password->text().toUtf8(),QCryptographicHash::Md5).toHex()));
// Insert Query
QSqlQuery query(QSqlDatabase::database("MyConnection"));
query.prepare("SELECT * FROM users WHERE email = :email AND password = :password");
query.bindValue(":email", email);
query.bindValue(":password", password);
if (!query.exec()) {
QMessageBox::information(this,"Failed","Error please try again");
}
else {
QString emailLog = query.value(1).toString();
QString passwordLog = query.value(4).toString();
if (query.next()) {
QMessageBox::information(this,"SUCCESS","SUCCESS");
ui->plstryagain->close();
db.close();
} else {
QMessageBox::information(this,"Wrong","Wrong Password try again");
ui->plstryagain->show();
db.close();
}
}
}
else {
QMessageBox::information(this, "Database Error", "Can't Connect To Database");
}
I want to make a login system, I have mysql database I want to login according to my mysql database username and password but it is not working I think I have problem with my code please check the code
void MainWindow::on_loginBtn_clicked()
{
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QMYSQL", "MyConnect");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("");
db.setDatabaseName("qtregister");
QString username = ui->loginEdit->text();
QString password = ui->loginPassword->text();
if(db.open()) {
QSqlQuery query(QSqlDatabase::database("MyConnect"));
query.prepare(QString("SELECT username and password from users where username = :username AND password = :password"));
query.bindValue(":username", username);
query.bindValue(":password", password);
if(!query.exec()) {
QMessageBox::information(this, "Failed", "Failed To Login");
}else {
QMessageBox::information(this, "Success", "Login Success");
}
}
else {
QMessageBox::information(this, "Not Connected", "Not Conneced Success");
}
}
UPDATED
There was an error in your query (Sometimes you need to debug your query in another environment that Qt like mysql clis or online ones http://sqlfiddle.com)
SELECT username,password from users where username = :username AND password = :password
instead of
SELECT username and password from users where username = :username AND password = :password
Corrected Answer
void MainWindow::on_loginBtn_clicked() {
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QMYSQL", "MyConnect");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("");
db.setDatabaseName("qtregister");
QString username = ui - > loginEdit - > text();
QString password = ui - > loginPassword - > text();
if (db.open()) {
QSqlQuery query(db);
query.prepare(QString("SELECT username , password from users where username = :username AND password = :password"));
query.bindValue(":username", username);
query.bindValue(":password", password);
if (!query.exec()) {
QMessageBox::information(this, "Failed", "Error in executing query");
} else {
while (query.next()) {
QString usernameFromDB = query.value(0).toString();
QString passwordFromDB = query.value(1).toString();
qDebug() << usernameFromDB << passwordFromDB;
if (usernameFromDB == username && passwordFromDB == password)
QMessageBox::information(this, "Success", "Login Success");
else
QMessageBox::information(this, "Failed", "Username or password error");
}
}
} else {
QMessageBox::information(this, "Not Connected", "Not Conneced Success");
}
}
I am a new one for amazon Ec2 instance.Now I want to send mail to client using php code.I installed wamp in my amazon ec2 instance and run these file.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'src/PHPMailer.php';
require 'src/SMTP.php';
//SMTP Settings
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "email-smtp.us-east-1.amazonaws.com";
$mail->Port = 25;
$mail->Username = "support#example.com";
$mail->Password = "*******";
//
$mail->SetFrom('support#example.com', 'Example'); //from (verified email address)
$mail->Subject = "Email Subject"; //subject
//message
$body = "This is a test message.";
$body = eregi_replace("[\]",'',$body);
$mail->MsgHTML($body);
//
//recipient
$mail->AddAddress("myname#gmail.com", "Myname");
//Success
if ($mail->Send()) {
echo "Message sent!"; die;
}
//Error
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
?>
When run these file and I got some error.
Parse error: parse error in C:\wamp\www\samplemail\src\PHPMailer.php on line 304
I want to add new recipients to existing recipientlist using code. I tried with below code but it didnt work.
TargetAudience recipientList = Factory.GetTargetAudience("RecipientListId");
if ((recipientList != null))
{
Contact contact = //I dont know how to create object for this, because it is protected class
contact.Profile.Email = "my Email";
contact.Profile.Name = "My Name";
contact.Profile.FullName = "Full Name";
recipientList.Subscribers.Add(contact);
}
Please help me to acheive this,
Thanks in advance
You can get a contact from the username of the user.
This method gets the contact by email address and contains code to get the username from the email address.
public Contact GetContact(string email)
{
// managerRoot is the top level ECM item
ManagerRoot managerRootFromId = Factory.GetManagerRootFromID(managerRoot.ID.ToString());
var username = Util.AddressToUserName(email);
string commonDomain = managerRootFromId.Settings.CommonDomain;
string fullName = commonDomain + "\\" + Util.AddressToUserName(username);
if (User.Exists(fullName))
{
return Contact.FromName(fullName);
}
return null;
}
You should then be able to add the Contact to the subscription list.
Or once you have the Contact you can set the profile values and use the subscribe method.
contact.InnerUser.Profile["Fullname"] = string.Format("{0} {1}",person.Firstname,person.Surname);
contact.Subscribe(subscriptionLists);
You can also add ECM users by using the following code supplying the email address as the localname.
protected static Contact CreateAnonymousECMUser(string localName, ManagerRoot root)
{
Contact contact = (Contact)null;
if (root != null && !string.IsNullOrEmpty(localName))
{
string commonDomain = root.Settings.CommonDomain;
Assert.IsNotNullOrEmpty(commonDomain, EcmTexts.Localize("The Common Domain setting is not set.", new object[0]));
string str = commonDomain + "\\" + Util.AddressToUserName(localName);
while (User.Exists(str))
str = str + "_";
string password = new PasswordGenerator()
{
MinimumCharacters = 14
}.Generate();
System.Web.Security.Membership.CreateUser(str, password, localName);
contact = Contact.FromName(str);
contact.Profile.ProfileItemId = root.Settings.SubscriberProfile;
contact.Profile.Save();
}
return contact;
}
I'm trying to run this Qt code
QString serverName = "localhost";
QString dbName = "zfserver";
QString userName = "root";
QString passWord = "123456";
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setConnectOptions();
db.setHostName(serverName);
db.setDatabaseName(dbName);
db.setUserName(userName);
db.setPassword(passWord);
if(db.open())
{
QSqlQuery query;
query.prepare("INSERT INTO account (name, email, password, type) "
"VALUES (:name, :email, :password, :type)");
query.bindValue(":name", "atef");
query.bindValue(":email", "asfasf#gfasga.com");
query.bindValue(":password", "123");
query.bindValue(":type", "2");
if (query.exec())
{
qDebug() << "OK";
} else {
qDebug() << "Error" << query.lastError().text();
}
db.close();
}
But I'm getting this error
Error "Using unsupported buffer type: 1701601889 (parameter: 1) QMYSQL3: Unable
to bind value"
If I change the query without the bindValue it works. Is there a way to solve this?
Try to rebuild the SQL driver .
QMYSQL3 seems to be old.