How to prepare attendance sheet in asp.net? - asp.net

I want to add a attendance sheet for HR record purpose, where they save attendance of different employees. Then I have to retrieve those records on different pages on searching respective fields.

If you are using a gridview to accomplish your task you can use the SQLDataSource control which will allow you to perform different commands like insert, edit and update.
Here you can use GridView.DataBind Method to bind data to your gridview.
The article about Simple Insert, Select, Edit, Update and Delete in Asp.Net GridView control will give you a better idea of doing

This is rather a database design question then asp.net. Starting from a simple design, first you need to have an Employee table (Call it Employees) with all employee names & secondly an attendance table which will record each employee attendance. Refer to my sample schema

Related

Best User Interface way to update an employees Sql table from an ASP.net web application

I would like the communities opinion on the best approach to update a table from an asp.net web application.
I have an Employees table in SQL and I want to create a webform page to Insert, Update and Delete the employees from the employees table.
Not looking for code but for ideas/examples on the User Interface for this webform.
Like have a webform split into two sections one list all the employees in the table. The other sections has textboxes that represent all the fields for the employee table. When you click on one of the employees in the list all their info appear in all the textboxes on the other section.
To insert a new employee you would fill in all the textboxes then click the enter button to save the employee to the table. and so on
Would like the community to show me other better... more exciting...way to do this.
Thank you
Check out jTable - a jquery plugin to perform ajax based CRUD operations.

Interactive search results table

In Asp.net using Visual Basic code I want to be able to query a database after a user inputs search criteria, get the results and display them in a table, with the ability of the user to click/select individual results and delete the corresponding data from the database. How can I do this?
You can do this by utilizing a Datagridview and binding data to it (by using OLEDB for example). Use the WHERE clause in your query to filter the records, based on the user input. (http://www.w3schools.com/sql/sql_where.asp)
The Datagrid has events you can use (delete, select, insert and update event).
See for more information: https://code.msdn.microsoft.com/VBASPNETGridView-19039173
Good luck!

Advanced editing, insert, delete with datagridview ASP.NET Web Forms

I am moving from windows forms to ASP.NET Web Forms and I run into troubles. I am trying to insert, delete, edit and update. Bellow are two table that i have.
Person table - PersonID, Person
Company table - CompanyID, Company, PersonID
How to use the datagrid properly so that instead of PersonID I use Person field in a dropdown list so that the user can choose a value from and at the same time I can do insert, delete, edit, update.
I hope you get my point here and will help me in a way. Thanks
This can be done easily.
You need to attach a datasource of Company table with the grid, by default it will show person Id. In order to connect it to the person table, change the column of person ID to Template. In the Edit Template import a dropdown and attach another Datasource of Person Table to it. Select Value and Key accordingly.
For a basic Idea have a look at: http://odetocode.com/articles/231.aspx

Edit a read-only view

I have a column and I would like to edit some of its rows. The problem is that the table is a view so I cannot edit the rows. How would I proceed to solve this problem?
SQLite doesn't let you update views. But it does allow triggers on views. So you can write an INSTEAD OF UPDATE trigger that makes the appropriate modifications to the underlying table.
As dan04 pointed out, you can use triggers to update views (like in most other databases). For sqlite, see http://www.sqlite.org/lang_createtrigger.html#instead_of_trigger
Example with a view called "myview", containing a table "my_t2"
CREATE TRIGGER myview_update INSTEAD OF UPDATE ON myview
BEGIN
UPDATE my_t2 SET field1 = new.field1, field2 = new.field2 WHERE my_t2.key = old.key;
END
If it's a view, it's not a table. The data for the view is drawn from one or more other tables. Edit the underlying table and when you examine the data in the view it will reflect the changes you made.
A SQL View is a virtual table, which is based on SQL SELECT query. Essentially a view is very close to a real database table (it has columns and rows just like a regular table), except for the fact that the real tables store data, while the views don’t. The view’s data is generated dynamically when the view is referenced. A view references one or more existing database tables or other views. In effect every view is a filter of the table data referenced in it and this filter can restrict both the columns and the rows of the referenced tables.
If you wish to modify the data in your table, you cannot do so with a view. SQL Views are always read-only. If you want to modify your table outside of the View, then use something like an UPDATE or ALTER TABLE statement.

Binding gridviews to viewstate until being able to write to database

I recently began working on a project which has many gridviews on a single page. During creation of a new record, the user needs to be able to add/remove/edit these gridviews and then save to the database at the end. The problem with this obviously is that there is no datasource to bind the data too until after its written to the database.
This data represents a 1..* relationship, which is why the gridview data cannot be written to the database until the parent record has been created first.
The best way I have found so far to solve this is to use viewstate. This solution however does not seem ideal to me. I am also forced to manually create the gridview functionality with OnDeleting, OnUpdating, etc so that I can manage the binding of the viewstate with the gridview.
Does anyone have any suggestions on a better way to manage this situation, it seems like it would be a common thing?
UPDATE:
Keep in mind this data needs to be around throughout postbacks.
Use a DataSet as an intermediate connection to your data source. Fill the DataSet with your data and then bind your GridView to the DataSet setting the GridView DataMember to the name of the table it is supposed to bind to.
As the user updates tables it will add/modify records in the DataTables in the DataSet. When the user is done editing and clicks "Save" your code can then update the database from the datasets, either automatically using a DataAdapter, or manually looking at the RowState of the rows in the DataTables.
Use a DataAdapter and a Dataset. Invoke the fillschema method in the adapter to create de metadata (cols, constraints, relations, etc) in the dataset. bind the data tables created to the different grid views. update manually cheking each row rowstate on each table or call the adapter's update method to do it automatically. If you do it automatically you need to define commands for insert, delete, and update in the adapter.

Resources