Constructs from form obtains the database data, removes the useless information in the database, assigns the value to the field, finally draws the diagram

Source: Internet
Author: User

private void Cbnum_selectedindexchanged (object sender, EventArgs e)
{
Fieldlistlug.clear ();//continue to clear fields
if (Cbtype.text = = a)//select a
{
String killedstring = "";
killedstring = "id,lugnumber,q1,q2,dnx,dnd,th,kg";
DataTable tbsize =getaccessdata ("y_support_lug_4712_3_2007_a");
Fieldlistlug = Tbsize.getfieldlist (killedstring);
String TypeName = "y_support_lug_4712_3_2007_a";//query Table A
string where = string. Format ("Lugnumber = {0}",
Cbnum.text);//define query criteria
Tbvalue = Getaccessdata (TypeName, Fieldlistlug, where);//Isolate the required table
}
else if (Cbtype.text = = b)//select B
{
String killedstring = "";//define Remove field
killedstring = "id,lugnumber,q1,q2,dnx,dnd,th,kg";//Remove some useless fields
DataTable tbsize = Getaccessdata ("y_support_lug_4712_3_2007_a");//Lookup table
Fieldlistlug = Tbsize.getfieldlist (killedstring);//Get the field list after removal
String TypeName = "Y_support_lug_4712_3_2007_b";//define Query table
string where = string. Format ("Lugnumber = {0}",
Cbnum.text);//define Conditions
Tbvalue = Getaccessdata (TypeName, Fieldlistlug, where);//Isolate the required table data after removing useless information
}
else if (Cbtype.text = = c)//select C
{
String killedstring = "";
killedstring = "id,lugnumber,q1,q2,dnx,dnd,th,kg";
DataTable tbsize = Getaccessdata ("y_support_lug_4712_3_2007_a");
Fieldlistlug = Tbsize.getfieldlist (killedstring);
String TypeName = "Y_support_lug_4712_3_2007_c";
string where = string. Format ("Lugnumber = {0}",
Cbnum.text);
Tbvalue = Getaccessdata (TypeName, Fieldlistlug, where);
}

}

private void Button1_Click (object sender, EventArgs e)
{
Supportlug Lug = new PV. Supportlug ();//Instantiate Lug object
if (TbValue.Rows.Count > 1)
MessageBox.Show ("The number of support lines is wrong!") If there are multiple rows of data in the table, the error is determined.
Point3D pt = ed. GetPoint ();//get user pick points

if (pt = = null)
Return
Lug.pinsertmain = pt;//Sets the user selection point to the insertion point
foreach (String str in fieldlistlug)//Cyclic Assignment object
{
Try
{
Object obj = tbvalue.rows[0][str];//out the objects in the data table.
String fieldvalue = obj. ToString ();
Lug.gettype (). GetProperty (str). SetValue (Lug, obj, null);//Assigning an object to a field
}
catch (SystemException ex)//If the error shows missing fields
{
Ed. Writemessage ("\ n" + str + "XXX" + tbvalue.rows[0][str]);
Ed. Writemessage ("\ nthe error line starts \ n:" + ex.) Stacktrace.tostring ());//contains an error statement and an error line
Ed. Writemessage ("\ntargetsite:" + ex.) Targetsite.tostring ());
Return
}
catch (Autodesk.AutoCAD.Runtime.Exception Exx)
{
Ed. Writemessage ("\ n error Line start:" + Exx.) Message.tostring ());
Ed. Writemessage ("\nsource:" + Exx. Source.tostring ());
Ed. Writemessage ("\nstacktrace:" + Exx. Stacktrace.tostring ());
Return
}
}
Lug.db = db;//Defining the Graphics database
using (Transaction trans = db). Transactionmanager.starttransaction ())//Add things
{
Lug.draw ();//Draw a diagram
Trans.commit ();//Submit
}
}

Constructs from form obtains the database data, removes the useless information in the database, assigns the value to the field, finally draws the diagram

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.