Some Garden friends called on the blog Park to organize some open-source projects, which were recognized by everyone. More than five years ago, I learned a lot of technologies and met many friends. To thank you for your help, we open source a customer relationship management (CRM) project a few years ago from the hard drive. Due to copyright concerns, the implemented business logic and core components have been shielded. The main contribution is its interface framework and beautiful and practical interface framework.
As shown in, the form title is CRM, the subject uses a light blue background, including a standard menu, the toolbar, the navigation bar on the left, and the main frame of the display interface on the right. This layout is also the practice of simulating outlook, which is still quite popular at present.
The language of the interface is English, and the interface of the form is handwritten directly on the interface.ProgramIt contains three languages: English simplified and traditional. Simplified processing is provided here, which only contains the English interface. The menu in the navigation bar on the left was originally designed in the Menu Designer. The menu is directly designed in the tree, without dynamic menu loading. Because I want to share with you the interface framework, rather than the handling of all its details, you know that this can easily infringe copyright.
GoCodeTo analyze its implementation. See the design results in Visual Studio.
To implement a framework similar to the office interface, inherit from the kryptonform form. The code looks like this
Public Partial ClassFrmmain: kryptonform {PublicFrmmain () {initializecomponent ();}Private VoidForm1_load (ObjectSender, eventargs e) {frmstart FRM =NewFrmstart (); frm. toplevel =False; Frm. Parent = kryptonmainpanel; frm. Dock = dockstyle. Fill; frm. Show ();}}
As you can see, when the main form is started, the start page is loaded. The right side is a panel. to load the form into the panel, you must set form. toplevel = false.
The basic function of this software is customer relationship management. The customer region, customer information, user role permissions, and data import and export functions also provide reports. The lightweight rdlc report Technology of SQL Server reporting services is used to browse customer reports.
The main implementation code for displaying rdlc reports is as follows:
Rpt. localreport. reportpath = appdomain. currentdomain. basedirectory +"Customerreport. rdlc"; Baseoperate boperate =NewBaseoperate (); datatable TBL = boperate. getds ("Select clientid, cname, cstep, Croot, ctype, ctrade, carea,
Cphone, cfax, cpostcode, caddress, cemail, cremark from DBO. tb_clientinfo","Tb_clientinfo"). Tables [0];If(TBL! =Null) {Rpt. localreport. CES. Clear (); Rpt. localreport. CES. Add (NewMicrosoft. Reporting. winforms. reportdatasource (
"Db_crmdataset_tb_clientinfo", TBL); Rpt. localreport. Refresh ();} Rpt. refreshreport ();
Send the written SQL code to SQL Server, return the dataset, and upload it to the report to display the content of the rdlc report.
Data access technology is implemented using basic SQL + Dao, without ORM or data binding technology, so the code looks a little bloated and unnecessary. If you are disgusted with the following code, please refer to my articleArticleThe Application of Data Binding Technology in the data solution R & D diary of the knowledge management system can greatly simplify data binding to the interface, and then write data back to the database from the interface.
Private Void Frmusermanage_load ( Object Sender, eventargs e) {dataset myds = boperate. getds (m_str_ SQL, m_str_table); dgvuinfo. datasource = myds. Tables [0]; If (Myds. Tables [0]. Rows. Count> 0) tsbtndel. Enabled = True ; Else Tsbtndel. Enabled = False ;} Private Void Tsbtnadd_click ( Object Sender, eventargs e) {opandvalidate. autonum ( "Select userid from tb_user" , "Tb_user" , "Userid" , "YH" , "1000001" , Txtuserid); tsbtnsave. Enabled = True ; M_int_judge = 0; txtusername. Text = "" ; Txtuserpwd. Text = "" ;}
This code is unnecessary if you have experience in data binding. It was limited to my technical skills at that time. Only in this way can we make progress through continuous learning. If you have been focusing on your initial technical experience, there may be no difference between working for five years and working for one year. This sentence is sharp. It is often mentioned by the interviewer during the interview. I often say this to myself, reflecting on my technical gains and making continuous improvements.
The code of the CRM system is less readable and valuable. It is basically a combination of Dao + SQL, business logic and interface confusion, and data access and business logic confusion, therefore, it is not recommended that you directly read its code. My goal is that you only need to get the interface framework you need from the code. The focus of my presentation is its interface framework. If you want to improve it, the following ideas can help you do this.
1. The interface is implemented in many languages, such as simplified Chinese, English, and traditional Chinese. We recommend that you use database tables to store resource files in multiple languages. After the system is deployed to the customer, the customer may need to modify the interface language. For example, the central English represents centre in the UK and centre in the United States, which is a text difference between the two cultures. The CRM system allows you to modify the default language definition of the interface. Store it in the database, and then provide a table operation program to update language resources.
2. The following example shows how to implement code in multiple languages.
Private Void Applylanguageresource (){ Foreach (Control CTL In Controls ){ If (CTRL Is Label) {label lable = CTRL As Label; label. Text = languagehelper. gettranslation (Label. Text )} If (CTRLIs Toolstripmenuitem) {toolstripmenuitem strip = CTRL As Toolstripmenuitem strip. Text = languagehelper. gettranslation (Label. Text )} // Tab control, button... }} This . Text = languagehelper. gettranslation ( This . Text )}
Put this method into the baseform type, so that other types inherit from this baseform type. Therefore, any newly created form can obtain the ability to change the interface language. This is also the best solution I have ever seen to implement multiple languages.
Here, there is a bit of repetitive code, which should be abbreviated as this is the code with no bad taste (repeated)
Private VoidApplylanguageresource (){Foreach(Control CTLInControls ){// For controls (Label, button, toolstripmenuitem) that set text to the text attribute, you can writeStringOriginaltext = reflectionhelper. getproperty (CTRL,"Text");StringTranlatedtext = languagehelper. gettranslation (originaltext); reflectionhelper. setproperty (CTRL,"Text", Translatedtext );}This. Text = languagehelper. gettranslation (This. Text )}
Reflection technology is used to set the attributes of a common text language. The code is much simpler than above.
3. After several years of experience, I have gained a better understanding of accessing SQL Server. Compared with the ORM framework, even if you want to write SQL statements to access the database, you must create an SQL code generator to reduce the number of keyboard hits. The biggest fear of handwriting SQL is to add and reduce fields. Maybe all SQL scripts must be re-debugged. You can use the ORM framework without changing any code. Encapsulate SQL scripts into the DaO type and provide a DaO type factory to cache the DaO type to improve performance. I think these two experiences can improve the efficiency and maintainability of SQL script + Dao projects.
4. mis-type systems are generally the primary data input, data query, and report query. There are three types of forms, which can be made into a standard interface framework. Data input, including add, modify, delete, import, and report query, only the specified report (Reporting Service, crystal rport) is displayed, data Query is read-only and cannot be modified for posting or historical records. These three forms can be made into standard MIS forms to improve the development speed. Please refer to the articles "informatization infrastructure form features" and "informatization infrastructure form development" to learn how I implemented these three standard forms.
5. For the content of the navigation bar on the left, you need to provide a Menu Designer to design its content. A practical system generally takes into account user preferences and customizes the interface. Users will not easily recognize the interface we designed. It also requires some minor changes or personalized settings. Personalization originated from ASP. NET 2.o. later, the Windows 7 operating system introduced this concept to customize your favorite part.
6. The evolution of the interface solution has always been a rule, so there is no error in following Microsoft's pace. Visual c ++ 5/6 has created a standard SDI/MDI application framework. A large number of programs at this time imitate the word/Excel MDI style. You may even add XP to your product name to show that it is quite trendy. After the birth of Office 2007, the style of the ribbon interface was followed up. At that time, many programs evolved into the ribbon style interface. Third-party control vendors also provided ribbon style form controls. Now, TAB-MDI should be a popular trend
This style of interface framework facilitates user operations. In terms of program implementation, it is easy to migrate the previous SDI/MDI migration (Migration, upgrade) to this tab-mid interface. I have observed that some listed companies use this interface model to enhance my confidence in this interface model.
In the first half of this year, I wrote an article to explain the implementation of this interface mode and its source code. For details, refer to the article "management console tool management software general development framework (Open Source Code) get its implementation.
Go to epn.codeplex.com to download the latestSource codeAnd database. The code name is paradox CRM.