ASP.net Summary: This article describes the use of ASP.net to develop a software company's internal staff performance evaluation system, including all background staff information management, departmental information management, all departmental evaluation rules information management The front desk staff review and evaluate their staff monthly. Focus on database design and the use of important Web server and page controls. The author believes that this article will be helpful to the reader's database design and the use of asp.net development page technology.
First, System architecture
Visual Studio. NET is the most powerful and complete development tool ever launched by Microsoft to build ASP Web applications, XML Web services, desktop applications, and mobile applications. ASP.net is a compiled,. NET-based environment. The following chart shows us how the Visual Studio.NET framework supports ASP.net applications.
Visual C # (pronounced C Sharp) is a new object-oriented programming language that evolves from C and C + + to provide a simple and type-safe language for developing applications. Therefore, in the programming environment and the choice of language, we use the ASP.net architecture to support page development, Visual C # for practical programming. Our evaluation system uses a traditional three-tier architecture, including the data storage layer (SqlServer2000), the Application logic layer (. aspx.cs), and the page display (. aspx).
Second, database design
The database "YGPC" (Employee evaluation) contains five tables, as described below:
1. Employee, the basic information of all employees and supervisors of the company.
2. Department, basic information for all departments.
3. Bigrules, including the classification of the review rules, such as "compliance system", "professional skills", "Planning and Management", "Work results", "work attitude" and so on.
4. Smallrules, including specific evaluation rules corresponding to the classification of each rule, such as "skilled use of design tools (such as rational rose or Visio)" in the Classification of "professional skills", "proficiency in the use of databases or their related applications such as Sql,olap", Familiar with the company's technical system and be skilled in the development of ".
5. Score, the monthly evaluation results score, divided into staff self-test and supervisor of staff evaluation, for each of the evaluation rules of each employee monthly corresponding points.
The main fields of each table and the relationships between the tables are shown in the following illustration:
Table name main character Chini and foreign key employeeemployid,departid,leaderid,reallname, Username,userpass, emal, telephone ... primary key: Employid
FOREIGN key: Departiddepartmentdepartid,leaderid,dname,ddescription ... Primary key: Departidsmallrulessmallid,bigid,departid Simplediscription,fulldescription,score, primary key: SmallID
Foreign key: Bigid, Departidbigrulesbigid,content,totalscore primary key: Bigidscoretestpersonid, Testedpersonid,smallid, score, month Primary key: None
FOREIGN key: Smallid
In most software companies, departments are divided into research and development, testing, customer service and so on, employees are divided into a number of departments, each department has the same and different standards of evaluation. For example, in the author of the development of supermarket software companies, in compliance with the system, each department needs the same standard of evaluation, such as: No late leave early, something to the company, no reason for absenteeism, etc. at the same time, various departments have different evaluation criteria, such as in professional skills, research and development department staff need to master skilled. NET development of Windows page technology, and customer service departments need to master skilled database technology, at any time for each store to find merchandise sales, merchandise invoicing situation, etc. in the work results, the testing department will have "test leakage rate" evaluation criteria, and research and development and customer service departments do not need. Therefore, in the Smallrules (evaluation Rules) table, not only the corresponding Bigrules (classification of rules) in the Bigid, so that "skilled use of the development of more than two tools" corresponds to the "professional skills" category, but also to store the rules belong to the Department ID.
In addition, in the score table, in accordance with each month, each evaluation person, each test person, each evaluation rules to store the corresponding details of the score, so whether it is taken from the test results or the supervisor of their evaluation results are very convenient. All ID, score, score, month and other numeric data is int type, descriptive information is varchar type.
III. Application of logic implementation
1, Application overview
System Administrator, various department heads and employees from the same landing page into the former back-office system respectively. The system administrator completes the backstage staff information management, the Department information management, each department evaluation standard Information management and so on. The front desk user includes all department heads and general Staff. When the head of Department enters the evaluation homepage, he or she can select any employee of the department, select the work month to mark it, and the ordinary staff can only give their monthly evaluation. Employees can revise their previous evaluation results several times before the supervisor makes a review of their work this month, and once the supervisor has evaluated for himself, the supervisor can only rate them after the employee has evaluated them.
2. Use of important servers and page controls
We use quite a few basic controls, such as Button,textbox,htmlselect,dropdownlist, hidden controls, and so on. Due to its limited space, only the controls that play a key role are described.
(1) HtmlTable control
。
This page in the implementation of the logic is not complex, we are described as follows: Traversal bigrules table in each evaluation classification, according to the current rules classification ID from the smallrules to take out a number of corresponding evaluation rules, at the same time to determine whether the current employee has had a performance, if there is, then remove, put " "Box for easy reference. After entering the page, you also need to judge who is "who" in the "Who" evaluation, if the supervisor or employee self-test, the evaluation results into the database
Testpersonid,testedpersonid all fill in the same ID, otherwise Testpersonid storage Supervisor Id,testedpersonid store the person ID.
This page mainly uses the HtmlTable control. Use the HtmlTable control to program an HTML <table> element. In the background page IDE design environment, the control does not contain any content. After fetching the data from the database, we can realize the powerful function of the control. The HtmlTable control consists of rows (represented by HtmlTableRow objects) stored in the Rows collection of table tables. Each row consists of a cell in the Cells collection that stores the row (represented by a HtmlTableCell object). In actual programming, you first need to populate a number of HtmlTableCell content, join the HtmlTableRow object one at a time, and then add the HtmlTableRow object to the HtmlTable object.
(2) DataGrid
The DataGrid control differs from the HtmlTable control in that the DataGrid control is a Web server-side control. Writing in HTML and the implementation of server-side controls are already very different in thinking ways, which is just an identity for HTML languages, but for server-side HTML controls that have evolved into a program, an object.
It is not only convenient and quick to complete the binding display of data in the database, you can also generate a column that contains the edit, update, Cancel button, a column that contains a custom button, and a template column at design time. In the admin page we use the Edit Data feature of the control and click the Edit button on each item to update the item. Click on the update control to complete the update of the database content.
In addition, you can use the DataGrid control in other situations
We appreciate the powerful features of the control in different situations. This is precisely the ASP.net programming framework to provide users with the practical benefits.
Iv. concluding remarks
I developed this employee Evaluation Center for the company when I graduated from a company that developed supermarket software. Although the time is short, unable to make the function more, the richer page, but also did realize the asp.net various advantages. Also in the database design and use of a certain amount of experience, I hope to have some enlightenment. Believe that the use of this technology can also make the company more comprehensive functions of office automation products.
Establish a database connection, remove the Bigrules table data into the DS
SqlConnection conn = new SqlConnection ("server=localhost;uid=sa;pwd=;d ATABASE=YGPC";
SqlCommand Comm. = New SqlCommand ("SELECT * from Bigrules", conn);
SqlDataAdapter da = new SqlDataAdapter (comm);
DataSet ds;
Da. Fill (ds, "Bigrules");
int ntotalbig = ds. tables["Bigrules"]. Rows.Count;
int k = Convert.ToInt32 (ds. tables["Bigrules"]. rows[0]["Bigid"]. ToString ());
for (int ibig=0;k<=convert.toint32 (DS). tables["Bigrules"]. rows[ntotalbig-1]["Bigid"]. ToString ()); K=convert.toint32 (ds. tables["Bigrules"]. rows[ibig]["ID"]. ToString ()))
Ibig represents the row value in the Bigrules table, and K represents the ID value for the IBIG line
{
String commtext = "SELECT * from Smallrules where bigid=" +k+ "Order by id";
SqlCommand Commsmall = new SqlCommand (commtext,conn);
SqlDataAdapter dasmall = new SqlDataAdapter (Commsmall);
if (ds1!=null) ds1. Clear ();
DS1 = new DataSet ()//Every loop needs to update the rule data recorded in DS1
Dasmall.fill (DS1, "smallrules");
int ntotalrows = DS1. tables["Smallrules"]. Rows.Count;
int I=convert.toint32 (DS1. tables["Smallrules"]. rows[0]["ID"]. ToString ());
String str = "SELECT * FROM score where
_testpersonid= "+testid+" and "testedpersonid=" +testedid+ "and Month=" +curmon+ "and smallid=" +i;
Judge whether the current test staff has had a month, that is, check whether there is score table and Testedid, Testid,curmon match
Records to determine whether true or false is stored in the hidtested hidden control,
Plays a role in showing the "yellow box" in previous grades, slightly
for (int z=0;i<=convert.toint32 (DS1). tables["Smallrules"]
_. rows[ntotalrows-1]["ID"]. ToString ());
I=convert.toint32 (DS1. tables["Smallrules"]. rows[z]["ID"]. ToString ()))
Z represents the row value in Smallrules, I represents the ID value of the z row, and I need to find the "score" value of the score table corresponding to the I value
{
HtmlTableRow tr = new HtmlTableRow ();
Array. SetValue (Indexpagerow++,i);
The array is a static array that records the corresponding rows for each I value on the page,
Because the evaluation smallrules through the background constantly increase, delete, change, its ID value and the line on the page does not correspond
for (int j=0;j<ds1. tables["Smallrules"]. columns.count;j++)
{
HtmlTableCell TC = new HtmlTableCell ();
if (j==0)//current range of 0 rows 0 columns
{
if (i = = Convert.ToInt32 (DS1). tables["Smallrules"]. rows[0]["ID"]. ToString ()))
{
The leftmost Rule category column, note fetching data from the Bigrules table
Tc. InnerHtml = s.tables["Bigrules"]. ROWS[IBIG][J+1]. ToString () +
_ds. tables["Bigrules"]. rows[ibig]["Totalscore"]. ToString () + "min";
}
Tr. Cells.add (TC);
}
else//is not the leftmost column
{
if (j!=ds1. tables["Smallrules"]. COLUMNS.COUNT-1)//To determine whether the most right column
{
Tc. InnerHtml = DS1. tables["Smallrules"]. ROWS[Z][J]. ToString ();
}
Else
{
The right score is the list
if (hidtested.value== "true")
The last cell column contains two textbox columns, showing the results of the last evaluation
{
TextBox box1= new TextBox ();
Box1. Width = 30;
Find the score in the score table corresponding to the I value into the DS2
Box1. Text = ds2. tables["Score"]. rows[0]["Score"]. ToString ();
Box1. ReadOnly = true;
Box1. BackColor = System.Drawing.Color.Beige;
Tc. Controls.Add (Box1);
}
TextBox box = new TextBox ();
if (Hidtested.value = = "false")
Box. Width = 60;
Else
Box. Width = 30;
Box. attributes["onblur"]= "Javascript:onchange" ("+ds1"). tables[
"Smallrules"]. ROWS[Z][J-1]. ToString () + ", this)";
JavaScript controls user evaluation scores within this score,
DS1. tables["Smallrules"]. ROWS[Z][J-1]. ToString ()
Pass to onchange function The evaluation rule score
}
Tr. Cells.add (TC);//HtmlTableCell object to HtmlTableRow object
}
}
T.rows.add (TR);//one row of data completed, joined to HtmlTable's Rows collection
z++;
}//all evaluation details for a classification of the rules are completed
ibig++;
}//the next rules are classified, such as "compliance" to "professional skills"
The onchange () function of the embedded JavaScript statement is implemented in the head section of the HTML page as follows:
<script language= "JavaScript" >
function OnChange (maxvalue,obj)
{
MaxValue is the value of the rule, obj is the score, is the object type
parseint (obj.value,10); parseint (maxvalue,10);
if (!isnan (Obj.value))//To determine whether the natural number
if (obj.value>maxvalue)//value is over range
{
Alert (' Value beyond Range ') Obj.focus ();}
else {}
else//value illegal
{
Alert (' Value illegal ') Obj.focus ();}
</script>
Source code 2 (Evaluation results page, for example in a DataGrid):
DataTable table1 = ds. Tables.add ("score");//ds,ds1 to two dataset datasets
Table1. Columns.Add ("Smallid", typeof (int));//Rule ID column
Table1. Columns.Add ("Realname", typeof (String));//name of the person who evaluates
Table1. Columns.Add ("Score", typeof (int))//score of the rule
String commtext = "Select Smallid,realname,score from Score, employee where score.testpersonid=" +testid+ "and Score.testedpersonid= "+testedid+" and score.month= "+curmon+" Order by Score.smallid ";
Where Testid,testedid is the evaluation Person ID and the rated ID value of the previous page record when the page enters
SqlConnection conn = new SqlConnection ("server=localhost;uid=sa;pwd=;d ATABASE=YGPC";
Conn.Open ();
SqlCommand comm= New SqlCommand (Commtext,conn);
SqlDataReader reader = com1. ExecuteReader ();
int ncolcount= table1. Columns.count;
while (reader. Read ())
{
System.Data.DataRow row = table1. NewRow ();
for (int i=0;i<ncolcount;i++)
{
Row[i]=reader[i];
}
Table1. Rows.Add (row);
}
Datagrid1.datasource=ds. tables["Score"]. DefaultView;
DataGrid1.DataMember =ds. tables["Employee"]. TableName;
Datagrid1.databind ();
Use DataSource and DataMember to display information from two tables in a DataGrid control
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.