zoukankan      html  css  js  c++  java
  • 构造From窗体获取数据库数据,去除数据库中无用信息,并赋值给字段,最后画出图

    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(" " + str + "xxx" + tbValue.Rows[0][str]);
    ed.WriteMessage(" 错误行开始 :" + ex.StackTrace.ToString());//包含出错语句和出错行
    ed.WriteMessage(" TargetSite:" + ex.TargetSite.ToString());
    //return;
    }
    catch (Autodesk.AutoCAD.Runtime.Exception exx)
    {
    ed.WriteMessage(" 错误行开始:" + exx.Message.ToString());
    ed.WriteMessage(" Source:" + exx.Source.ToString());
    ed.WriteMessage(" StackTrace:" + exx.StackTrace.ToString());
    return;
    }
    }
    Lug.DB = db;//定义图形数据库
    using (Transaction trans = db.TransactionManager.StartTransaction())//添加事物
    {
    Lug.Draw();//绘制出图
    trans.Commit();//提交
    }
    }

  • 相关阅读:
    iOS开发HTTP协议相关知识总结
    php的变量作用域
    ArcGIS Server 10.1发布要素服务(FeatureLayer server)时遇到的数据库注册问题
    ArcGIS for JavaScript 关于路径开发的一些记录(三)
    ArcGIS for JavaScript 关于路径开发的一些记录(二)
    学习小结(2014.62014.8)
    ArcGIS for JavaScript 关于路径开发的一些记录(一)
    【转载】javascript深入理解js闭包
    【小记录】关于dojo中的on事件
    虚拟多继承
  • 原文地址:https://www.cnblogs.com/xzh1993/p/4124891.html
Copyright © 2011-2022 走看看