/** // <Summary> // database connection name value: // </Summary> private const string db_connection = "crmconnectionstring "; private Database _ DB = NULL; /** // <summary> // data operation object // </Summary> protected database dB {get {If (_ DB = NULL) {_ DB = databasefactory. createdatabase (db_connection);} return _ dB;} private dbproviderfactory _ dbfactory = NULL; /**//**//**//**//**//**//**//// <Summary> /// </Summary> protected dbproviderfactory dbfactory {get {If (_ dbfactory = NULL) {/** // both METHODS Construct the object // string dbprovidername = configurationmanager. connectionstrings [db_connection]. providername; // _ dbfactory = dbproviderfactories. getfactory (dbprovidername); _ dbfactory = dB. dbproviderfactory;} return _ dbfactory ;}} /** // <summary> // save Method /// </Summary> /// <Param name = "datacompany"> </param> /// <Param name = "dataproduct"> </param> // /<returns> </returns> Public bool save (datatable datacompany, datatable dataproduct) {dbcommand cmd; dbdataadapter ADP; dbcommandbuilder CMB; using (dbconnection conn = dB. createconnection () {Conn. open (); dbtransaction TRAN = NULL; try {TRAN = Conn. begintransaction (); // create the SELECT command. Cmd = dbfactory. createcommand (); cmd. commandtext = "select * From competecompany"; cmd. connection = conn; cmd. transaction = Tran; // create the dbdataadapter. ADP = dbfactory. createdataadapter (); ADP. selectcommand = cmd; // create the dbcommandbuilder. CMB = dbfactory. createcommandbuilder (); CMB. dataadapter = ADP; // get the insert, update and delete commands. ADP. insertcommand = CMB. getinsertcomm And (); ADP. updatecommand = CMB. getupdatecommand (); ADP. deletecommand = CMB. getdeletecommand (); /** // update the competition for the watch ADP. update (datacompany); // create the SELECT command. cmd = dbfactory. createcommand (); cmd. commandtext = "select * From competeproduct"; cmd. connection = conn; cmd. transaction = Tran; // create the dbdataadapter. ADP = dbfactory. createdataadapter (); ADP. selectcomm And = cmd; // create the dbcommandbuilder. CMB = dbfactory. createcommandbuilder (); CMB. dataadapter = ADP; // get the insert, update and delete commands. ADP. insertcommand = CMB. getinsertcommand (); ADP. updatecommand = CMB. getupdatecommand (); ADP. deletecommand = CMB. getdeletecommand (); /** // update the table of competing products (ADP. update (dataproduct);} catch {If (Tran. connection! = NULL) Tran. rollback () ;}finally {If (Tran. connection! = NULL) Tran. Commit () ;}return true ;}
. Csharpcode,. csharpcode pre {
Font-size: small;
Color: black;
Font-family: consolas, "Courier New", courier, monospace;
Background-color: # ffffff;
}
. Csharpcode pre {
Margin: 0em;
}
. Csharpcode. Rem {
Color: #008000;
}
. Csharpcode. kwrd {
Color: # 0000ff;
}
. Csharpcode. Str {
Color: #006080;
}
. Csharpcode. Op {
Color: # effecc0;
}
. Csharpcode. preproc {
Color: # cc6633;
}
. Csharpcode. asp {
Background-color: # FFFF00;
}
. Csharpcode. html {
Color: #800000;
}
. Csharpcode. ATTR {
Color: # ff0000;
}
. Csharpcode. Alt {
Background-color: # f4f4f4;
Width: 100%;
Margin: 0em;
}
. Csharpcode. lnum {
Color: #606060;
}