Should the MVP mode be modified 2 like this?

Source: Internet
Author: User

Finally, it is of course the interface implementation.

After the business operation object and customer data interface have been defined, you can use webform, winform, or WPF to edit the interface. Here we use winform.

Customer Data editing page

The background of the editing interface belowCode

Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;

Namespace henxiao. winui
{
Public partial class frmcustomeredit: form, icustomer
{
Hxcustomerhelper helper = NULL;

Public frmcustomeredit ()
{
Initializecomponent ();
Helper = new hxcustomerhelper (this );
}

# Region icustomer Member

private int cstid = 0;
Public int cstid
{< br> Get
{< br> return this. cstid;
}< br> set
{< br> This. cstid = value;
}< BR >}

Public String cstno
{< br> Get
{< br> return this.txt cstno. text;
}< br> set
{< br> this.txt cstno. TEXT = value;
}< BR >}

Public String cstname
{
Get
{
Return this.txt cstname. text;
}
Set
{
This.txt cstname. Text = value;
}
}

Public datetime cstbirthday
{
Get
{
If (this. dtpcstbirthday. Text = "")
Return datetime. minvalue;
Else
Return convert. todatetime (this. dtpcstbirthday. Text );
}
Set
{
This. dtpcstbirthday. Text = value. tostring ();
}
}

Public String csttele
{< br> Get
{< br> return this.txt csttele. text;
}< br> set
{< br> this.txt csttele. TEXT = value;
}< BR >}

Public String cstzip
{< br> Get
{< br> return this.txt cstzip. text;
}< br> set
{< br> this.txt cstzip. TEXT = value;
}< BR >}

Public String cstaddr
{< br> Get
{< br> return this.txt ADDR. text;
}< br> set
{< br> this.txt ADDR. TEXT = value;
}< BR >}

Public String cstexp
{< br> Get
{< br> return this.txt cstexp. text;
}< br> set
{< br> this.txt cstexp. TEXT = value;
}< BR >}

Public String cstsex
{< br> Get
{< br> return this. cmbcstsex. text;
}< br> set
{< br> This. cmbcstsex. TEXT = value;
}< BR >}

Public String cstcerttype
{< br> Get
{< br> return this. cmbcstcerttype. text;
}< br> set
{< br> This. cmbcstcerttype. TEXT = value;
}< BR >}

Public String cstcertno
{< br> Get
{< br> return this.txt cstcertno. text;
}< br> set
{< br> this.txt cstcertno. TEXT = value;
}< BR >}

Public String cstemail
{< br> Get
{< br> return this.txt cstemail. text;
}< br> set
{< br> this.txt cstemail. TEXT = value;
}< BR >}

Public String cstcompany
{
Get
{
Return this.txt cstcompany. text;
}
Set
{
This.txt cstcompany. Text = value;
}
}

# Endregion

Private void frmcustomer_load (Object sender, eventargs E)
{
This. cmbcstcerttype. Items. Add ("ID card ");
This. cmbcstcerttype. Items. Add ("Passport ");
This. cmbcstcerttype. Items. Add ("military ID card ");

This. cmbcstsex. Items. Add ("male ");
This. cmbcstsex. Items. Add ("female ");

This. helper. dataload ();
}

private void btnok_click (Object sender, eventargs e)
{< br> If (this. helper. save ()
{< br> MessageBox. show ("saved successfully. "," Saved successfully ", messageboxbuttons. OK, messageboxicon. information);
This. close ();
}< br> else
MessageBox. show (this. helper. errormessage, "saving error", messageboxbuttons. OK, messageboxicon. error);
}

Private void btncancel_click (Object sender, eventargs E)
{
This. Close ();
}
}
}

In this way, this case is basically completed, and there is basically no business logic in the background of the editing interface.

There are better ways to separate the business logic from the interface. Thank you for your advice.

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.