Acumatica - VisibleExp Multiple Conditions - c#

I need to show/hide tab for the specific values in a form, I need to use VisibleExp and not PXUIFieldAttribute.SetVisible.
Let's take a look at an example:
VisibleExp="DataControls["edProductType"].Value == LN"
What if I need to compare ProductType to "TR" as well? How can I add "or" or "and" statements in the expression?

I've solved this problem by using the unbound hidden field. I pass the whole expression value to that field and then I use it for the VisibleExp. It's a kind of weird solution but in fact, it works!

Related

(SQL) Efficient way of replacing of NULL values in DataGridView?

I have a database table like this on SQL Server:
USER PASSWORD
1 samplepassword
2 NULL
3 NULL
4 sample_password
I want to replace the NULL values in the PASSWORD column, along with other columns, with values like '(Not set)' or '-' upon displaying it to the user in a DataGridView.
There are three ways I know of in achieving this. First is to use the NullValue property of the column's DefaultCellStyle. The concern with this method is that the designer would create multiple copies of the same DefaultCellStyle - one per column.
Then there's the CellFormatting event of the DataGridView. Lastly, the replacing can be done on the SQL statement itself, ala ISNULL(password, '(Not set)').
Considering that this DataGridView can be filtered afterwards by the user (e.g. show only those without a password), what is the more suggested way in doing this?
Thanks!
Formatting is not SQL server responsibility, keep formatting in your UI code.
Use DefaultCellStyle and create instance of DefaultCellStyle in the code and set same instance to the all columns of datagridview manually.
Or assign only NullValue property to already existed styles
const string NULL_VALUE = "not set";
DataGridView.Columns["ColumnName1"].DefaultCellStyle.NullValue = NULL_VALUE;
DataGridView.Columns["ColumnName2"].DefaultCellStyle.NullValue = NULL_VALUE;
Not 100% sure on SQL Server but on MySQL I wold do the following
SELECT USER, IF(PASSWORD IS NULL,'Not Set', PASSWORD) AS PASSWORD FROM TABLE
SELECT ISNULL(YourColumn, 'yourcharacter' ) FROM YourTableName
Run a JavaScript or jQuery function after your DataGridView load, to find empty values from DataGridView and replace it with "(Not set)" or "-".
OR
Update your dataset values which are empty with values "-".
The selected answer is the best one from a paradigm standpoint, though you can also handle this by creating a helper function to handle nulls. This will make your default values something you can change based on your datatype. It also lets you manage nulls before they ever touch the UI, but without affecting your queries, which is essential if you have to handle mathematics before displaying output.
public static dynamic NullCheck(object d, dynamic default)
{
return DbNull.Value == d ? default : d;
}
Just be ready to cast the result as needed in your code, such as ((foo)(Nullcheck(foo, bar))).

How to combine 2 entities as 1 in Autocad .net

I'm making an autocad plugin and i want to create a new entity that is a combination of a line and the text.If i select the line the text is selected and backwords when i delete the line delete the text etc etc.How to treat them as one object referencing eachother?Is this possible?
I recommend using groups. Below is a link on how to access groups, I'm sure that site has more information on creating groups.
Users can control whether objects are selected with the group based on the system variable, PICKSTYLE. you can use ctrl+ h to toggle the PICKSTYLE value.
http://adndevblog.typepad.com/autocad/2012/04/how-to-detect-whether-entity-is-belong-to-any-group-or-not.html
Another option - though it doesn't answer your question - and this is something for you to think about: is to create a new block which consists of the line and some text. The line can be an entity in your block, and the text can be a tag string value. the tag can be called "line_information".
I know this might be abit too late but there is a better more flexible way to do this, although it's not actually combining the two entities but rather more of a visual effect.
It's called using Overrules. Basically you change the way the entity is displayed. So instead of displaying a line, you can display a circle, or in your case display a text and a line.
Overruling is a very powerful tool, you can not only change how the entity looks but also add grips, remove grips, change how entity is highlighted or highlight other entities when your entity is highlighted, override some of the entity methods like erase and much more.
Best place to start from is Kean Walmsley's "Through the Interface" blog.
And here is a link to this blog related to what you want to achieve
http://through-the-interface.typepad.com/through_the_interface/2009/08/a-simple-overrule-to-change-the-way-autocad-lines-are-displayed-using-net.html

Lower-case all text in a datatable, or lower-case all text on a page to use css text-transform: capitalize?

I've run into the problem that CSS cannot use text-transform: capitalize on text that's already capitalized. Unfortunately the text being returned from my database is capitalized in many cases. Rather than putting a LOWER(X) ahead of every single field I'm requesting from the database, or call a JS function on every field, it seems like it'd be easier to use a solution that just targets the entire datatable returned, and then use text-transform: capitalize in the page's CSS.
Any suggestions for an easy way to do this? Alternatively, a way to target all the text on the page (JS, perhaps?) and lowercase it, then have the CSS part recapitalize would be fine. I'm looking for the easiest possible solution, whatever that may be (and rewriting a large number of queries simply isn't it.)
Ben you can use this Select Query against your DataTable
you will need to adjust the field(s) based on your Table. I am only showing this using 1 field name called DESC
select
DESC =
-- Adjust the length of your filed(s) for example DESC is varchar(500)
convert(varchar(500),
upper(substring(DESC,1,1))+
lower(substring(DESC,2,499)))
from
YouTable Name
Using CSS to do that is incorrect. Lowercase what’s in your database, easier or not.
Easiest would be to change the data in your database so that you don't have capitalized strings, and let CSS do its thing. In any case, doing it on JS/CSS alone is not the way to go.

Validation spanning a group of text boxes

I'm trying to achieve the following:
Where:
Surname is always required
NI Number OR Reference Number is required
Is this beyond the scope of the ASP.NET Validation Controls? The only solution I can think of is writing some bespoke javascript (for client side) and backing that up with some server side code.
One thing you can try is to have a CustomValidator(see here) check that both textboxes are not
empty. Then validate both textboxes with a regular expression. The expression should check for either a valid entry OR a blank field.
You can create a CustomValidator and handle it there
http://msdn.microsoft.com/en-us/library/aa479013.aspx#aspnet-validateaspnetservercontrols_topic7

Query filter design for string field

A field in my table can have arbitrary strings. On the UI, there is a drop down having options like
All, Value1, Value2
And the results were filtered by the selected option value. So far this is easy and adding new filters to the UI is not a problem. Needs no changes in my stored procedure. Now I want to have an "Others" option here as well, which will return rows not having the column value as Value1 or Value2.
Apparently this will require a "not in" operator in my query, and will make maintenance difficult, as the list of values is likely to change
Any suggestions, design tips?
If your options table could have an additional column called IsOther then your query could simply be WHERE IsOther = 1 instead of using a NOT IN.
Make a separate stored procedure for others case and call it when the selected option is others. Pass the contents of the list as input to the procedure: by this way, you need to update the list only at one place.

Categories

Resources