标签:des io ar os for 数据 on art cti
private void cbNum_SelectedIndexChanged(object sender, EventArgs e)
{
FieldListLug.Clear();//继续清除字段
if (cbType.Text == A)//选择了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";//查询表A
string where = string.Format("LugNumber = {0} ",
cbNum.Text);//定义查询条件
tbValue = GetAccessData(TypeName, FieldListLug, where);//查出需要的表
}
else if (cbType.Text == B)//选择B
{
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_B";//定义查询表
string where = string.Format("LugNumber = {0} ",
cbNum.Text);//定义条件
tbValue = GetAccessData(TypeName, FieldListLug, where);//查出需要的表 去除无用信息后的数据
}
else if (cbType.Text == C)//选择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();//实例化LUG对象
if (tbValue.Rows.Count > 1)
MessageBox.Show("支座号行数有误!");//如果表中有多行数据 则判断出错
Point3d pt = ed.GetPoint();//获取用户选取点
if (pt == null)
return;
Lug.PInsertMain = pt;//将用户选取点设置成插入点
foreach (string str in FieldListLug)//循环赋值对象
{
try
{
object obj = tbValue.Rows[0][str];//取出数据表中对象的
// string fieldValue = obj.ToString();
Lug.GetType().GetProperty(str).SetValue(Lug, obj, null);//将对象赋值给字段
}
catch (SystemException ex)//如果出错显示缺少的字段
{
ed.WriteMessage("\n" + str + "xxx" + tbValue.Rows[0][str]);
ed.WriteMessage("\n错误行开始\n:" + ex.StackTrace.ToString());//包含出错语句和出错行
ed.WriteMessage("\nTargetSite:" + ex.TargetSite.ToString());
//return;
}
catch (Autodesk.AutoCAD.Runtime.Exception exx)
{
ed.WriteMessage("\n错误行开始:" + exx.Message.ToString());
ed.WriteMessage("\nSource:" + exx.Source.ToString());
ed.WriteMessage("\nStackTrace:" + exx.StackTrace.ToString());
return;
}
}
Lug.DB = db;//定义图形数据库
using (Transaction trans = db.TransactionManager.StartTransaction())//添加事物
{
Lug.Draw();//绘制出图
trans.Commit();//提交
}
}
构造From窗体获取数据库数据,去除数据库中无用信息,并赋值给字段,最后画出图
标签:des io ar os for 数据 on art cti
原文地址:http://www.cnblogs.com/xzh1993/p/4124891.html