ASP.NET convert string to pre-defined length string - asp.net

Here at work we are converting over to a new payment system which allows only a maximum of 7 characters in the product code. The product codes we are using can and will excede 7 characters (changing would require changing past orders so changing the codes is out of the question).
The product code for us is the event code (ie ccsws2011), the old system allowed us to pass the entire event code in, whereas the new system is limiting us to only 7 characters. I do not want to do a look up table at all. I want to be able to create a product code list for the system (outside the website) and then have the code within the website automatically convert our event code to the product code I created outside the website and pass it to the payment system.
Is there a way to hash our product code into a 7 character product code for the new system?
I.E.:
our product code: ccsws2011
Hashed product code: xxxxxxx

Thanks for your efforts everyone, another value was decided upon to be used for the item code which nullified this issue. Thank you again everyone

Related

Generate and display html table with user data from wordpress

Update: With the help of the answerer below I figured out how to do this. Basically I used a WP Query to get users and their user metadata and I sorted and placed the data in a for each loop in a table.
I'm new to PHP and I need some help. Basically I want to create a leaderboard with different user data. I want to display it in an html table.
This is kinda what i want:
Username GamiPress Points Time since last login
And I want the table to be populated with these data amongst others automatically. I want two versions one that is sorted with the 15 users who have the most points and one that sorts on the 15 users that logged in last.
Can someone point me to the right place on how I can best implement this?
I basically want to create the GamiPress Leaderboard add-on that I, unfortunately, can't afford, but with some extra fields.
There are multiple steps to do if you want to achieve this:
1) Add meta field to your users, so you can store the points. For example you can use "Advanced Custom Fields" plugin for this.
2) Write a function for adding points to this field. Define when this function will be fired.
3) Query the users ordered by that meta value and display it (get_users($args) might be useful).
4) For the Last-Login value you can use a plugin (google Wordpress Last Login) and write another Query and order results by that meta field. You can also write this by your own, here is a link I found: https://www.wpbeginner.com/plugins/how-to-show-users-last-login-date-in-wordpress/
I don't know if this is what you were looking for.
Or did you want to see an example code how you use a wp query and display data in html table?

Drupal WebForm Conditionals

I need to build a webform where one of the questions asks the user to pick a date from a list of 5 dates. Each of the 5 dates only allows 10 attendees. How can I track the number of people that have registered for each date and limit the number of attendees? Thanks for any help.
Go for some custom solution. I.e. create some content type with 5 integer fields where you will keep count of attendees per day.
Then hook that webform (hook_form_alter()) and add another submission handler function, like described here:
Drupal 7 Webform submit hook
In that function (submit handler) read the form values increase counter if it has free space or shoot some message that no more places remained.

Asp.net how to suggest multiple words inside textbox

Summary: I'm doing a web app to manage products in a warehouse. So I have a db with list of products and quantities. I have one page for unload products when they are used. On that page I have a textbox in which users write the note on how the product has been used.
Request: when users type inside the textbox I'd like a popup to appear showing products that contains the entered characters. More than 1 products is possible. Also users enters quantity of the used products, so I'd like that my app can update the db with new value.
For example:
I have a product named "AAA batteries" and I have 10 in stock.
I also have "9V batteries" 5 in stock.
User write "Used 3 AAA batteries and 4 9V batteries"
While typing I'd like popup appear suggesting "AAA batteries" etc.
Then I'd like to update the db subtracting 3 AAA and 4 9V.
It's ok to use delimiter characters
User press a button to save the note (db should be updated at this point)
Is this possible? I'm already using the ajax autocomplete extender but it can't do exactly what I want. I did a lot o searches but I can't find the right direction, can you help me? Thanks

pro asp.net 4.5 in c# book by adam freeman sportstore

just wondering did anybody complete the sport store application in this book, i am having a problem with the data binding in the orders page for the admin, i want to pull in the product id from the order lines table but i keep getting errors, it working correctly for the quantity but i can seem to get the product id to bind. i have tried the following code but this is not working for me at the moment
**<td><%# Item.OrderLines.Product_ProductID %></td>**
it says i am missing a definition in the orderline
First of all, OrderLines is of type List most likely. So the list doesn't have a definition of Product_ProductID. You should rather make a loop for Item.OrderLines and then you can access each order line of the order with its product. At second, take a look at your OrderLine model. Does it contain Product_ProductID? Most likely it has Product property
references to Product model which contains ProductID. So after all, your code would look like:
**<td><%# Item.OrderLines[i].Product.ProductID %></td>**

Auto-Incrementation in InfoPath 2010 Form

I have a form in which I am attaching a workflow to. The form has a number that will be auto-generated. For example the first number will be 1, the next time the form is opened the number should be 2, so on and so forth. The issue I am having is: in the Default Value under the Text Box Properties I have the Value as: count(mynumber QuoteNumber) +1. When the form is generated the first and only number is 2 the number begins at 2 and never increases. Can someone help me with this or explain what I may be doing wrong? Thank You. I'm not using visual studio.
Rachel: I have fought with this problem since InfoPath 2007. Here is how I do it.
Since you say you are attaching a workflow, I assume you are using the from in SharePoint.
1 - create your form library in SharePoint
2 - use InfoPath to design the form. When you publish the form to SP, make sure you promote AT LEAST the ID field you want to auto-inc. (I usually promote every field in my forms, 'cause I like to use them like SP lists.)
3 - In SP, create one new form and manually set the ID field to the starting number for your form series.
4 - return to InfoPath designer and re-open your form template.
5 - create a new data source to receive data from your SP form library and specify your form library as the source, and the ID field as a data element. Name the data source something like “ID Lookup”.
6 - open the properties of the field you want to auto-inc on your form and, in the default value box, select function, then choose the MAX function.
And add “+1” after the function to increment by 1.
Now, double-click in the field are of the Max function. You will see a dialog showing your form fields. Notice the drop-down at the top of the dialog – here you can choose the data source (notice I named mine “sales Contracts” in this example). If you select the data source you created in step 5, you will see a dialog showing you a couple of data branches.
Expand the ‘dataFields’ branch until you see the field you want to auto-inc. Click on this.
Your formula dialog will look something like:
max(ID_X0020) + 1
With your field name instead of the 'ID' in the Max function – the function will now return the Maximum value of the field IN THE FORM LIBRARY, plus 1.
Save the form in InfoPath and try previewing it. You will probably get a security warning – your InfoPath form is grabbing data from your SharePoint library on the fly. You may even get asked to re-enter your password (I usually do). When the new, blank form is displayed in InfoPath preview, you should see you ID field filled in with a value one greater that the number in that field of your SP library.
There is one huge Gothca with this method - if users re-open a completed form to edit it, the formula will probably try to replace the ID number. If your users don't edit the forms after they are submitted, the this will work for you.
Hope this makes sense.
You aren't doing anything wrong - you just have to change how you think about "forms" a bit. Remember a form is just like a word document template. Suppose you save a word document on your hard drive with a blank spot to fill in your name. Later you open the template, type your name, and save a copy as V1.doc. When you go back and open the template again - your name is not there because it was saved in V1.doc. Everytime you open the template you start again from scratch.
Infopath forms that you design and that the user fills out are templates (.xsn files). When the user fills it out and saves it they are really saving a copy which is only data (.xml files). The .xsn template doesn't change when users interact with it.
So to answer your question - there is no way directly in InfoPath to cleanly keep track of an auto incrementing ID. You will need to tap into some code (webservice, sharepoint, etc) to do that. You could also consider making the ID a GUID (which infopath does support) but it won't be auto incrementing and it won't look "clean" if it has to be displayed/used by real people.

Resources