Jcfxbl auxiliary class -- helper class Introduction

Source: Internet
Author: User
Jcfxbl auxiliary class --- helper class introduction this series of articles was written by ex_net (Zhang jianbo). Please indicate the source for reprinting.
Http://blog.csdn.net/ex_net/article/details/8771111
Author: Zhang jianbo mailbox: 281451020@qq.com Phone: 13577062679 welcome to exchange calls!

 

The main purpose of writing the helper class is to simplify programming in the C #. NET environment. Especially in Windows Forms, The combox control, the datagridview control, and the datatable object interact with the database are simplified.

The premise of using the following helper class is to reference

Using jcfxbl. srvinterface;
Using jcfxbl. srvinterface. Core. protocollayer;

The corresponding assembly is as follows:

 

The source code is as follows:

 

Using jcfxbl. srvinterface; using jcfxbl. srvinterface. core. protocollayer; using system. collections. generic; using system. data; using system. LINQ; using system. text; using system. windows. forms; namespace jcfxbl. API {public class helper {public static string serverurl; /// <summary> /// automatically fills the DIC Dictionary data into the combox control /// </Summary> /// <Param name = "dic"> dictionary name </ param> /// <Param name = "CMB"> combox control object </PAR Am> Public static void fillcomboxbydic (string DIC, ComboBox CMB) {birequest Bir = new birequest (); Bir. url = helper. serverurl + "Execute. ashx? Serlet = getdicstore & act = get & DIC = "+ DIC; If (BIR. request () {try {srvresponse r = new srvresponse (BIR. response (); datatable dt = R. getresulttable (); CMB. datasource = DT; CMB. displaymember = "value"; CMB. valuemember = "key";} catch (exception ex) {// MessageBox. show (ex. message );}}} /// <summary> /// enter the corresponding data fields in the data table into the combox control /// </Summary> /// <Param name = "CMB"> combox Control object </param> /// <Param Nam E = "parms"> query parameters </param> /// <Param name = "act"> stored procedure name </param> /// <Param name = "displaymember"> combox display field </param> /// <Param name = "valuemember"> combox Value Field </param> Public static void fillcomboboxbytable (ComboBox CMB, system. collections. arraylist parms, string act, string displaymember, string valuemember) {birequest Bir = new birequest (); Bir. url = helper. serverurl + "execute. ashx? Serlet = getdbstore & act = "+ act; if (parms! = NULL) for (INT I = 0; I <parms. count; I ++) {postparm P = (postparm) parms [I]; Bir. addformparam (P. parmname, P. parmvalue);} If (BIR. request () {try {srvresponse r = new srvresponse (BIR. response (); datatable dt = R. getresulttable (); CMB. datasource = DT; CMB. displaymember = displaymember; // ""; CMB. valuemember = valuemember; // "";} catch (exception ex) {// MessageBox. show (ex. message );}}}// /<Summary> // fill in the data in the database to the datagridview control /// </Summary> // <Param name = "dgv"> datagridview control object </param> /// <Param name = "act"> stored procedure name </param> /// <Param name = "parms"> query parameter </param> Public static void filldatagridviewbytable (datagridview dgv, string act, system. collections. arraylist parms) {birequest Bir = new birequest (); Bir. url = jcfxbl. API. helper. serverurl + "execute. ashx? Serlet = getdbstore & act = "+ act; if (parms! = NULL) for (INT I = 0; I <parms. count; I ++) {postparm P = (postparm) parms [I]; Bir. addformparam (P. parmname, P. parmvalue);} If (BIR. request () {srvresponse r = new srvresponse (BIR. response (); If (R. return_value = "1") {datatable dt = R. getresulttable (); dgv. datasource = DT;} else {MessageBox. show (BIR. response () ;}} else {MessageBox. show (BIR. response () ;}/// <summary> /// fill in the Data queried from the database Add to a able object // </Summary> /// <Param name = "act"> stored procedure name </param> /// <Param name = "parms "> query parameters </param> /// <returns> </returns> Public static datatable filldatatable (string act, system. collections. arraylist parms) {birequest Bir = new birequest (); Bir. url = jcfxbl. API. helper. serverurl + "execute. ashx? Serlet = getdbstore & act = "+ act; if (parms! = NULL) for (INT I = 0; I <parms. count; I ++) {postparm P = (postparm) parms [I]; Bir. addformparam (P. parmname, P. parmvalue);} If (BIR. request () {srvresponse r = new srvresponse (BIR. response (); If (R. return_value = "1") {datatable dt = R. getresulttable (); Return DT;} else {MessageBox. show (BIR. response () ;}} else {MessageBox. show (BIR. response () ;}return null ;}}}

 

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.