I am working with Rdlc report. I have these fields:
First name : fn_data
Address1 : add1_Data
Address2 : add2_data
City, state, zip : city_data
If any one of these fields is empty, it should not show the blank space. For example (expected output)
First name,
Address1,
City, state, zip
But, as show in the above image, I am getting this:
First name,
Address1,
........................<-(blankspace is showing here)
City, state, zip
I tried changing Visiblity -> Expression -> ==IIF(IsNothing(Fields!add2_data.Value),False,True)
How can I remove this Blanck Space??
In Visibility.Hidden property you have to specify if the object must be hide or not.
So you can use:
=IIf(IsNothing(Fields!YourData.Value), True, False)
If you're using Table/Tablix you have to set Visibility property of your TABLEROW.
Related
I have 2 class methods. One method 'accountExistance()' checks if an account already exists by finding a duplicate username in a database and the other method 'customerDetails()' writes the user registration details to the database. My customerDetails() method calls the 'accountExistance() method and if there is a duplicate username, which is checked within 'accountExistance' method, I return False and back in the initial method, if the return value is False 'sys.exit()' occurs.
The problem lies because I would rather not quit the program as its running a tkinter gui, allowing the user to change the registration details. Rather, is there a way of instead of quitting I can cancel the execution where it is and not submit duplicate values to a database.
To note, customerDetails() is called from another file upon the user pressing registration where stringVars() from entry boxes are fed into the class method. Also, the indentation appearance is not formatted properly on here but I have produced a minimal example for logic, and have cut out some lines of code.
class Database():
def __init__(self):
Database.phoneNumber = ""
def accountExistance(email, phoneNumber):
conn=sqlite3.connect("system.db")
cur=conn.cursor()
emailExist = cur.execute("SELECT count(email) FROM customerDetails WHERE email = ?", (email,)).fetchall()
conn.commit()
print(emailExist)
phoneExist = cur.execute("SELECT count(phone) FROM customerDetails WHERE phone = ?", (phoneNumber,)).fetchall()
print(phoneExist)
conn.commit()
if emailExist or phoneExist != 0 :
tk.messagebox.showinfo("Error", "This email and/or phone number is associated with an account")
return False
sys.exit()
#else:
#return True
#INSERT SIGN UP DETAILS
def customerDetails(forename, surname, dob, address, city,
county, postcode, phone, email, password,verified, gender):
print(forename, surname, dob, address, city, county, postcode,
postcode, phone, email, password, verified, gender)
test = Database.accountExistance(email, phone)
if test == False:
sys.exit()
age = 0
conn=sqlite3.connect("system.db")
cur=conn.cursor()
cur.execute("INSERT INTO customerDetails VALUES
(NULL,?,?,?,?,?,?,?,?,?,?,?,?,?)",(forename, surname, dob, address, city,
county, postcode, phone, email, password, verified, age, gender))
conn.commit()
conn.close()
Just change your condition to the following:
test = Database.accountExistance(email, phone)
if test == False:
return # Stops the execution of the function
Also, if test is necessarily either True or False, you can check its value directly:
if not test:
is the same as
if test == False:
Using a PG database filled with registered voters.
Trying to set it up so I can search by first name, last name, zip or city. I want to be able to find all voters that match all of the entered params, but having trouble dealing with empty search fields.
where("zip LIKE ? OR city LIKE ? OR last_name LIKE ? OR first_name LIKE ?",
"#{params[:zip]}","#{params[:city]}","#{params[:last_name]}","#{params[:first_name]}")
Is there a better way to build it out so that it matches ALL entered parameters, but ignores empty string parameters? Right now if I enter a first and last name 'John Smith' I will get 'John Jones' and 'Jane Smith'.
This can do the trick:
attrs_name_to_search = %w( zip city last_name first_name )
fitlered_params = params.slice(*attrs_name_to_search).select { |_,v| v.present? }
sql_cond = filtered_params.map { |k,_| "#{k} LIKE :#{k}" }.join(' OR ')
YourModel.where(sql_cond, filtered_params)
But it should return all the records if no zip/city/last_name/first_name is given.
I am new to awk and sed. I have the following lines and want to move the line up if it does not match pattern.
File:
company name
address line
city, state, zip
extra info
company name
address line
city, state, zip
extra info
company name
address line
city, state, zip
extra info
... and it goes on like that
want to use pattern matching 'company name' . if the line does not have 'company name' move the line up.
Desired output:
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
... and continue on
Thanks for any help
Here us how to do it with awk
awk '{printf "%s"(NR%4?", ":RS),$0}' file
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
For every 4 line, use RS, else use ,
Or as Jaypal suggested:
awk '{ORS=(NR%4?", ":RS)}1' file
$ awk '{printf "%s%s", (/company name/?rs:", "), $0; rs=RS} END{print ""}' file
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
paste is a good tool for this job (assuming you are ok with , as a delimiter instead of , followed by space)
<file paste -d',' - - - -
company name,address line,city, state, zip,extra info
company name,address line,city, state, zip,extra info
company name,address line,city, state, zip,extra info
Alternately
<file paste -s -d',,,\n'
You could try this awk command also,
awk 'BEGIN{RS="company"}{ gsub (/\n/,", ");} NR>=2 {sub (/, $/,""); print RS$0}' file
Example:
$ cat file
company name
address line
city, state, zip
extra info
company name
address line
city, state, zip
extra info
company name
address line
city, state, zip
extra info
$ awk 'BEGIN{RS="company"}{ gsub (/\n/,", ");} NR>=2 {sub (/, $/,""); print RS$0}' file
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
company name, address line, city, state, zip, extra info
This is my first attempt at using Pentaho's Spoon.
Input file: CSV as follows
last_name, first_name
, Nod
zanie, Rod
anie, Slob
, Vod
meanie, Dod
Transformation: Where last_name is empty, set it to first_name
Hence the transformation script is
if ( last_name == null ){
last_name = first_name;
}
Output file: Coalescent.xml
The trouble is that above replacement simply does not happen. Why?
you need to specify the field in the grid at the bottom and specify replace=Y if you want to replace the last_name field back into the stream.
Did you use a Modified JavaScript Value for your transformation? Try to add
return last_name
I am updating the data by the following method
class xxxxxx
{
public static string updatepersonformData(string staffID, string Firstname, string Lastname, string Address1,
string Address2,string Address3, string Town, string County, string Postcode, string HomePhone, string Mobile,
string PersonalEmail, string Reference, string BookingName, string Position_Id, string Role_Id, string Gender,
string Dob, string WorkPhone, string WorkEmail, formMain mf)
{
string result = xxxxxx.InsertData(string.Format(#"update staff set staff_Reference='{2}' staff_Firstname = '{3}',staff_Lastname='{4}' ,
staffPosition_Id='{5}',staffRole_Id='{6}', staff_Dob='{7}',staff_Gender='{8}' staff_Address1 = '{9}',
staff_Address2='{10}',staff_Address3 ='{11}' staff_Town ='{12}',staff_County = '{13}',staff_Postcode='{14}',staff_HomePhone='{16}',
staff_WorkPhone ='{17}',staff_Mobile ='{18}',staff_PersonalEmail ='{19}',staff_WorkEmail='{20}',staff_BookingName='{21}',WHERE staff_Id ={0}",
staffID, Reference, Firstname, Lastname, Position_Id, Role_Id, Dob, Gender, Address1, Address2, Address3, Town, County, Postcode, HomePhone, WorkPhone,
Mobile, PersonalEmail, WorkEmail, BookingName), mf);
return result;
}
}
I am calling this function in main form by using this below
xxxxxx.updatepersonformData(tbCStaffHiddenId.Text, tbFirstname.Text, tbLastname.Text, tbAddress1.Text, tbAddress2.Text, tbAddress3.Text, tbTown.Text,
tbCounty.Text, tbPostcode.Text, tbHomePhone.Text, tbMobile.Text, tbPersonalEmail.Text, tbReference.Text, tbBookingName.Text, selectTextToId(cbPosition, aaPositions),
selectTextToId(cbRole, aaRoles), cbGender.Text, tbDob.Text.ToString(), tbWorkPhone.Text, tbWorkEmail.Text, mf);
But when I am updating this one I got the error like this......
Error: "Index (zero based)
must be greater than or equal to zero
and less than the size of the argument
list.
Make sure your method arguments are in
right form.
When converting a string to date time,
parse the string to take the date
before putting each variable into the
date time object.
Can anyone help on this ...
You're passing 20 arguments to string.Format, but your format placehorlders go from 0 to 21 (so presumably you need 22 arguments, or you've misindexed the thing - e.g. I don't see a {15} in there). Recheck your string and arguments until that formatting error is resolved.
And you have a syntax error in your query. The should not be a , before the WHERE keyword.
(And please use bind variables if they are available on whatever system/language it is you are using, and sanitize your data, otherwise bad things will happen - google for "sql injection".)
Sorry, User682417, but this is all kinds of messy.
I'm pretty sure you've got the indexing of the parameters wrong - you set
staff_Reference='{2}'
but it's at index 1 - is it possible you need to decrement each of the indices?
Also, SQL injection. But others have said that already.
Also, in the unlikely event you're passing the date of birth in correctly, you're assuming your client and your database have the same date formatting - but Europeans usually enter dd/mm/yyyy, whilst Americans often enter mm/dd/yyyy. Great source of comedy bugs, that one.