Objective
This system is for Zhi Sheng Group, mainly for the group of each department of the office supplies of basic information management. Starting from the purchase of office supplies, the first is the purchase of office supplies information input, to the middle of the various departments to use, to the monthly statistical work.
The system uses a pure three-tier architecture, SQL Server database. Clear thinking, the process is simple, but there are a lot of problems, need to summarize.
PROBLEMS1, ASP. NET Build Template page
This is often used, but the good for a long time without contact, a little forget, so I have to summarize, lest later use, do not know how to engage:
Here's how :
First, add the template page.
Locate the assembly name → right click → add → new item to open the Add New Item window.
图1-1 打开添加新项窗口
Select the language you want to use, here I use C #, then select the template page, modify the name of the template page, and finally click OK.
After adding the interface, as follows, the following is the main code: Red is the public part, the Blue Place is the interface of the various subform changes. Here the template page is added to complete.
图1-3 添加好的模板页界面
How do I use the add after it is finished? How do I create a form that uses a template?
Locate the assembly name → right click → add → new item to open the Add New Item window.
图1-4 打开添加新项窗口
Select the Web form that uses the master page, modify the name, and click OK to finish adding the subform.
图1-5 添加使用母版页的Web窗体
Pop-up Select Master page, select the master you want to use, and click OK.
图1-6 选择母版页
This completes the addition of the subform, so that you can add different code and there will be different interfaces. Very nice!!
图1-7 子窗体添加代码
2. Summary of DropDownList control usage
In the system, this control is very practical, so it is really necessary to master this.
图2-1 DropDownList
This control can be said to have three ways, the following I give you to share in turn:
First, use code to add content to the foreground
图2-2 用代码来添加内容
protected void Page_Load(object sender, EventArgs e) { DropDownList1.Items.Add("苹果"); DropDownList1.Items.Add("西瓜"); DropDownList1.Items.Add("香蕉"); DropDownList1.Items.Add("水蜜桃"); }
Second, bind the data in the foreground with the control itself bound to the database
In the vs2012+ many control design is very human, can directly through the control itself binding background database content, is very to force, of course, speed is very fast. The disadvantage is also natural, that is, if the database crashes, then the front desk will have no data, finished Duzi. Share DropDownList through the foreground non-code bound data:
From the Toolbox, drag a DropDownList out, it will have a small triangle, click on the small triangle, select the data source. The Data Source Configuration Wizard dialog box appears.
图2-2 选择数据源
Because there is no data source, you need to create a new data source. Click New Data source and the following dialog box will pop up.
图2-3 选择数据源
Here I am using a SQL Server database, so the selected data source is SQL.
图2-4 选择数据源类型
After selecting the database, you want to link to the database because it is a newly created database, so click the new link.
图2-5 选择数据链接
I believe this program is quite familiar with it, just follow the legend to add data, to complete it.
图2-6 添加链接
Fool operation, Direct next.
图2-7 选择数据链接
Fool operation, Direct next. Need to remember this name, officemanagerconnectionstring, may be used in the future.
图2-8 将字符串保存到配置文件中
It's amazing to configure the SELECT statement. This is the most compelling place here, the most overbearing place, you can directly through the patchwork SELECT statement to complete the operation. Likes.
Here you can select a data source and add a where condition. You can also perform non-select operations.
图2-9 配置SQL语句
图2-10 查询测试
图2-11 选择数据源
图2-12 界面展示
third, add content through background access
This method may be the most flexible, after all, the code is hand-written, through the background database access, direct transfer code. Very good for the force. I'll show you the code right here.
Front-Office Web tier:
Department display Commonfunction CF = new commonfunction (); list<departmentinfo> list = cf. Bcheckdepartment ();if(list! = null) {//For the DDL control to bind the data source and set to select ddldepartment.datasource = list; Ddldepartment.datatextfield ="Departmentname"; Ddldepartment.databind (); DDLDEPARTMENT.ITEMS.ADD ("All"); DDLDEPARTMENT.ITEMS.ADD ("--Please choose --"); Ddldepartment.text ="--Please choose --"; DateTime dt = DateTime.Now; The current time datetime start = dt. AddDays (1-DT. day);//early this month string startmonth = dt. AddDays (1-DT. Day). ToString ("Yyyy-mm-dd"); Earlier this month, string endmonth = start. AddMonths (1). AddDays (-1). ToString ("Yyyy-mm-dd"); End of month//instantiate layer B, click to view and load all application information for this month bquerypurchaserequisition BQ = new Bquerypurchasere Quisition (); list<requisitioninfo> lists = Bq. Bqueryallrecord (Startmonth, endmonth); Determine if the data existsif(lists. Count! =0{//If Access data exists, show givqueryrequest.datasource = lists; Givqueryrequest.databind (); Gridview1.datasource = lists; Gridview1.databind (); }Else{//If the access data does not exist, show null givqueryrequest.datasource = NULL; Givqueryrequest.databind (); } }Else{ddldepartment.datasource = null; Ddldepartment.databind (); }
B Layer:
//实例化D层,获取部门 departmentinfoDAL department = new departmentinfoDAL(); #region 查询所包含的部门--王雷--2016年4月10日16:06:09 /// <summary> /// 查询所包含的部门 /// </summary> /// <returns></returns> public List<departmentinfo> BCheckDepartment() { //调用获取部门的方法 List<departmentinfo> list = department.CheckDepartment(); return list; } #endregion
Layer D:
#region 查询所包含的部门 --王雷--2016年4月22日16:07:50 /// <summary> /// 查询所包含的部门 /// </summary> /// <returns></returns> public List<departmentinfo> CheckDepartment() { DataTable dt = new DataTable(); "select departmentName from [dbo].[T_departmentinfo]"; dt = sqlhelper.ExecuteQuery(cmdtext, CommandType.Text); List<departmentinfo> list =ModelConvertHelper<departmentinfo>.ConvertToModel(dt); return list; } #endregion
3, not to be continued
...
Problems encountered in the system of "office purchasing system"--gridview
Summarize
This is the first time to take over the project, but also directly took over the project is a BS, very happy, in fact, in the process of doing, there are a lot of shortcomings. But the overall is good. Come on!
Summary of issues encountered in the "Office procurement System" System (i)