Gridview row having multiple record - asp.net

I have a stored procedure that retrieves employee information - I don’t want to edit this stored procedure because it is globally use with in the website.
Here is now my dilemma, how can I put multiple row records in a column in the grid view. Is Gridview powerful enough to my scenario below or I really need to edit the stored procedure or my copy of it. Thanks
Records retrieve by stored procedure
Employee_ID Purchase ID Amount
1 0123456 100
1 012356 560
1 012446 560
1 012126 560
2 011122 100
2 051122 200
I want to achieve this in gridview
Employee ID Purchase ID Total Amount
-----------------------------------------
1 012345 1780
012346
012446
012126
2 011122 3000
051122

You could create a new stored procedure for use with this gridview only, leaving your existing stored procedure as-is so it doesn't break other parts of your code.
Alternatively, if you don't want to create a new stored procedure, you could sum the totals in your vb code, although it will be more work than doing it at the DB level. You'd do this using the gridview's datasource, not the gridview itself.

You can add a template column, and start it with (I believe) an </td></tr><tr><td>
In any case, each gridview template column implicitly (you can't see it) renders open/close td tags around whatever you put in it.

Related

Dynamodb re-order row priority field values and also make them sequential

I have a table in dynamodb, records has priority field. 1-N.
records shown to user with a form and user can update priority field, it means I need to change the priority of the field.
one solution is like when priority of a record changed I reorder all the records that their priory is more than it.
for example if I change a priority of record in N= 5 to 10, I need to order all records that their priority field is more than 5.
what do you recommend?
DynamoDB store all items(records) in order by a tables sort-attribute. However, you are unable to update a key value, you would need to delete and add a new item every time you update.
One way to overcome this is to create a GSI. Depending on the throughput required for you table you may need to artificially shard the partition key. If you expect to consume less than 1000 WCU per second, you won't need to.
gsipk
gsisk
data
1
001
data
1
002
data
1
007
data
1
009
data
Now to get all the data in order of priority you simply Query your index where gsipk = 1.
You can also Update the order attribute gsisk without having to delete and put an item.

Increment in Oracle Forms without commit record

I have used this code to generating an auto number:
DECLARE
ACC_NEW_ID NUMBER:=0;
BEGIN
if :acc_info_id is null then
SELECT MAX(NVL(ACC_INFO_ID,1000))+1 INTO ACC_NEW_ID FROM ACC_INFO;
:ACC_INFO_ID := ACC_NEW_ID;
end if;
END;
This code is working perfectly, but when I create one further record without clicking save button it creates the same number. For example: id is 1003 and after posting the record, I clicked new record button instead of save button, It generates the same 1003 number instead of 1004 as I expected.
Your code queries the records in the table, and returns the maximum ID that it can see at that point in time (i.e. it won't see uncommitted records), and adds one to it.
If it generates 1003 but no record with this value is saved into the table, of course you should expect it to not find it!
As far as that is concerned, it "works perfectly" and correctly. If, however, the intention is to generate a unique ID value for each record, this approach is flawed and will fail in any normal system due to concurrency.
Instead, if you need a unique ID you should use an Oracle SEQUENCE instead, which guarantees uniqueness.

How to show edited Row and before edited row in gridview?

I am working with ASP.NET and SQL Server 2012.
I have a form which has operation like Insert, Update and Delete.
While using Update, I need to display 2 rows; one row displaying previous row on which update has been performed, and the second row will be the updated row.
I am sharing my table column headings.
ServiceTaxCode Name Location CentralisedRegDate SurrenderDate
AA ARMI mumbai 2015-03-10 2016-04-03

MS Access 2010 Triggers/data macros

I am developing a database to do a annual inventory count with 32 tables in it, 33 including the Master.
We currently have 4000 SKU's so the master table needed to be broken down into smaller tables so I can hand out a realistic amount of work to my counters.
What I am trying to achive is when my counters enter data in the smaller tables using the UI it would automatically populate the fields in the master table.
Any help would be greatly appreciated.
Michael
In Access, there is no way to apply a trigger to a table. What you can do is create a form that implements a grid. Have an After-Update event fire that does what you need. You can make the form look like a table by using the datasheet view.
While you can create a data macro* to update a table from an update on another, why would you want to do it in this case? You can either include the quantity field in the sub table and validate the data against the main table before running an update query, or the sub table (note, table, the employee ID will be sufficient to divide the data) could consist only of an employee id and an SKU, the sub table can then be joined to the main table by SKU and all updates use the quantity field from the main table:
SELECT Mytable1.SKU, MyTable.Quantity
FROM MyTable1
INNER JOIN MyTable
ON MyTable1.SKU = MyTable.SKU
WHERE EmployeeID = [Enter ID: ]
*Data Macro

Web Form Next Number Generation Scenario

I have a web form with several fields first field is Employee Number which is having "EMP - 0001" Format.i'm generating next Employee number by considering the last Emp Number added and converting the latter part to integer and add one
ex: split EMP - 0001 -> get 0001 -> convert it to integer -> add one -> generate next no as EMP - 0002
Next Employee Number should be visible to the user.my issue is when there are multiple users using the system.imagine that one user opens the web Form and doesn't save the record.his Employee Number is EMP - 0002.another user opens the web form he also sees the EMP no as 0002 because last record is not saved yet.2nd user saves the records he gets the Number 0002.1st user then saves the record.so at last i've got duplicate EMP Numbers in my database.what kind of scenario should i follow to over come this situation
The only way to accurately predict their ID is to put in a blank record, get the ID used, then when they enter the form, update the record with their information. However, if they quit the form, you're left with a blank record.
Insert the record on the DB and get the ID it returns. You won't have concurrency issues there if you're opening and disclosing your connection correctly.
Your current approach is prone to concurrency issues as you pointed out & I will not recommend it you. You have the following options.
Use an Identity column in your database table as a serial column (The database automatically increments the identity column on every insert row operation- you don't have to specify it through code)SQL Server Identity
Use a database sequence (Depeding on your database version & its support - A database sequence returns a unique integer value - this can also be cached, presented on form once the form loads - once generated, same sequence is never generated again)
Use a database trigger to automatically update the Id column on every row insert
Depeding on your requirement, you can pick one option.
After saving the record you can give the user message tah record is saved and your Employee numnber is "EMP - 0002".

Resources