Winform development framework-General Personnel Information Management implementation code introduction-General accessory management module of Winform development framework

Source: Internet
Author: User
Document directory
  • 1. Project framework Layout
  • 2. Multi-Database Support
  • 3. Interface implementation

In the previous article "Winform Development Framework's General Personnel Information Management", I introduced the general implementation interface and ideas of this general personnel information management, this article further analyzes and shares the implementation details. I hope you can understand the implementation code and give more valuable comments. General personnel information management module, which may be used in many occasions, such as Enterprise Employee management and Department employee management. These system modules require the details and images of registrants.

1. Project framework Layout

The preceding modules are separated to meet the needs of more projects. If the WCF module is used, Entity classes must be referenced independently. However, if it is a pure Winform module and the minimum project is used as the management principle, there is no need for so many projects, which also facilitates Project Integration reference. Although we encapsulate the logic and database access implementation supported by multiple databases into a WHC. staffData. in the Core project, but if it is a Winform project application, we only need to reference its code path. This ensures a code entity, good processing of multiple external applications. As shown below.

After such integration of the Winform module, we can easily integrate the project, and the personnel management module has only one WHC. staffDataDx assembly, you do not need to manage too many program DLL about the Personnel module (otherwise there are many project projects such as the UI Layer, BLL layer, DAL layer, IDAL layer, Entity layer, etc, in this way, dozens of modules are generated, which is difficult to manage ).

The above is the related application used by an integrated test project. We can see that there is only one assembly in the personnel management module, and the others are other public modules used by the personnel management module, which is easier to manage, it is more conducive to the integration of large projects. Different modules have different responsibilities, and maintenance may also be maintained by different technical personnel. The biggest advantage is that all projects are universal, improve reuse efficiency.

The integration test project is a reference example of our actual integration. It is easy to use, as shown below.

private void btnAddStaff_Click(object sender, EventArgs e)        {            FrmEditStaff dlg = new FrmEditStaff();            dlg.ShowDialog();        }        private void btnStaffList_Click(object sender, EventArgs e)        {            FrmStaff dlg = new FrmStaff();            dlg.ShowDialog();        }
2. Multi-Database Support

The whole small project is the epitome of my Winform development framework. My Winform development framework basically follows a rule to develop independent modules. It has the features of multi-database support, good framework layout and high-quality code features.

The design of my traditional Winform development framework is as follows. The UI of the interface layer directly accesses the BLL layer without passing through the network. The Common layer and entity layer of the Public auxiliary library can be accessed in each layer, common permission management and dictionary management are encapsulated into component modules and called directly. The underlying layer uses the factory method to support different databases, the UI Layer, BLL layer, DAL layer, and entity layer use the inheritance class method to achieve the best encapsulation and optimal code design.

Of course, the following framework also applies to this personnel management module.

The actual code structure of the Framework project that supports multiple databases is shown below.

I introduced the relationship between the several layers of the Framework database structure very early, as shown below.

The relationships between these several layers have very strong inheritance relationships. The data access layer has a super base class, which is formed on the basis of various databases. For different databases, there is also a general base class used to implement detailed database features. After each business class has a clear inheritance relationship, with an extraordinary capability (with almost all common interfaces commonly used), we usually do not need to write any code or perform database operations.

3. Interface implementation

For the interface design, I always hope to better reflect my design ideas. In the entire personnel information management, there are people's learning situations, resumes, family situations, overseas situations, titles, etc. The interface is basically unified, that is, a list management, regular management ideas, generally, you also need to adjust the order of the list. This is a common function. Therefore, a sequence can be adjusted here.GridControlDragerAuxiliary class. You can drag the records to any order during use.

The implementation code is as follows:

        private void StaffResumeControl_Load(object sender, EventArgs e)        {            if (!this.DesignMode)            {                GridControlDrager drager = new GridControlDrager(this.gridControl1);                drager.ProcessDragRow += new GridControlDrager.ProcessEventHandler(drager_ProcessDragRow);            }        }        bool drager_ProcessDragRow(int sourceRowHandle, int targetRowHandle)        {            DataTable table = this.gridControl1.DataSource as DataTable;            if (table != null)            {                string sourceID = this.gridView1.GetRowCellValue(sourceRowHandle, "ID").ToString();                string targetID = this.gridView1.GetRowCellValue(targetRowHandle, "ID").ToString();                bool result = BLLFactory<StaffResume>.Instance.UpdateTwoSeq(sourceID, targetID);                if (result)                {                    DataRow sourceRow = table.Rows[sourceRowHandle];                    DataRow row = table.NewRow();                    row.ItemArray = sourceRow.ItemArray;                    table.Rows.Remove(sourceRow);                    table.Rows.InsertAt(row, targetRowHandle);                    this.gridControl1.DataSource = table;                    this.gridView1.FocusedRowHandle = targetRowHandle;                }            }            return true;        }

The following figure shows the general design interface of several modules. Then, you can integrate them in the form.

The running time interface is as follows.

The above also includes the attachment management. This module is described in the previous "Winform Development Framework's general attachment management module", and will not be repeated here.

4. Export Word reports

The previous article introduced the format of Word export. The exported personnel information table is as follows:

We can see that a lot of information is single-field, and some are list. For Single-field, we add tag reference in the template, then Replace the text Implementation of the label reference, as shown below.

# Region uses bookmarks to replace the content Dictionary <string, string> dictBookMark = new Dictionary <string, string> (); // name, gender, birth time, political appearance, Party and group time, nationality, nationality, position, employment time, work time, highest education level, education level, highest degree, // time of obtaining a degree, marital status, title, title time, whether the only child is StaffInfo staffInfo = BLLFactory <Staff>. instance. findByID (ID); if (staffInfo! = Null) {dictBookMark. add ("name", staffInfo. name); dictBookMark. add ("gender", staffInfo. sex); dictBookMark. add ("Birth time", staffInfo. birthDate. getDateTimeString ("yyyy. MM. dd "); dictBookMark. add ("political outlook", staffInfo. political); dictBookMark. add ("party time", staffInfo. partyDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("ethnic", staffInfo. nationality); dictBookMark. add ("Hometown", staffInfo. nativePlace); dictBookMark. add ("Title", staffInfo. officialRank); dictBookMark. add ("time of employment", staffInfo. servingDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("working time", staffInfo. workingDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("highest degree", staffInfo. highestEducation); dictBookMark. add ("time of education", staffInfo. educationDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("highest degree", staffInfo. highestDegree); dictBookMark. add ("time of obtaining a degree ", StaffInfo. degreeDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("Marital status", staffInfo. marriageStatus); dictBookMark. add ("title", staffInfo. titles); dictBookMark. add ("title time", staffInfo. titlesDate. getDateTimeString ("yyyy. MM "); dictBookMark. add ("Only Child", staffInfo. childStatus); StaffAwardInfo awardInfo = BLLFactory <StaffAward>. instance. findSingle (condition); if (awardInfo! = Null) {dictBookMark. add ("Awards", awardInfo. note) ;}} Aspose. words. document doc = new Aspose. words. document (templateFile); foreach (string name in dictBookMark. keys) {Aspose. words. bookmark bookmark = doc. range. bookmarks [name]; if (bookmark! = Null) {bookmark. Text = dictBookMark [name] ;}# endregion

For the list content, we need to introduce the MailMerge function of Aspose. Word. First insert and define the relevant domain reference in the fixed template, as shown below.

The MailMerge function of Aspose. Word can be used only after a series of domain code references are created.

The red part indicates the domain code that must be created for a list, including the ID of TableStart: And TableEnd.

After the data source is created, it is not complicated to bind the data source, as shown below.

                Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);                List<StaffStudyInfo> studyList = BLLFactory<StaffStudy>.Instance.Find(condition);                DataTable dtStudy = DataTableHelper.ToDataTable<StaffStudyInfo>(studyList);                dtStudy.TableName = "study";                FillStaticRow(dtStudy, 5);                List<StaffTitlesInfo> titleList = BLLFactory<StaffTitles>.Instance.Find(condition);                DataTable dtTitle = DataTableHelper.ToDataTable<StaffTitlesInfo>(titleList);                dtTitle.TableName = "title";                FillStaticRow(dtTitle, 5);

.....................

DataSet ds = new DataSet (); ds. tables. add (dtStudy); ds. tables. add (dtTitle); ds. tables. add (dtResume); ds. tables. add (dtAbroad); ds. tables. add (dtFamily); doc. mailMerge. executeWithRegions (ds); doc. save (saveFile); if (MessageDxUtil. showYesNoAndTips ("exported successfully. Do you want to open the file? ") = System. Windows. Forms. DialogResult. Yes) {Process. Start (saveFile );}

The FillStaticRow function is used to generate fixed multi-row operations, so that the list is not less than a fixed function by default. Otherwise, the list is not easy to read.

The above are some of my experiences in developing this module. I hope you can get more feedback and communicate with each other.

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.