Beispiel #1
0
        //判断,这是辣眼睛的烂代码
        private void btn_dl_yes_Click(object sender, EventArgs e)
        {
            if (tb_dl_No.Text.Trim() == "")
            {
                return;
            }
            if (tb_dl_name.Text.Trim() == "")
            {
                return;
            }
            //从数据库中检测是否有同名的
            var dr = rwh.OpenSelectSqlStr("select pNo from PCBs where pNo = '" + tb_dl_No.Text.Trim() + "'");

            if (dr != null)
            {
                label_dl_info1.Text = "此编号已存在";
                return;
            }
            dr = rwh.OpenSelectSqlStr("select pName from PCBs where pName = '" + tb_dl_name.Text.Trim() + "'");
            if (dr != null)
            {
                label_dl_info2.Text = "此名称已存在";
                return;
            }
            rwh.Close();
            //需要在PCBs表中添加
            //这就是新的
            rwh.RunSqlStr("insert into PCBs "
                          + "(pNo,"
                          + "pName,"
                          + "elementTableName,"
                          + "createDate,"
                          + "modifyDate,"
                          + "OtherInfo)"
                          + " values("
                          + "'" + tb_dl_No.Text.Trim() + "',"
                          + "'" + tb_dl_name.Text.Trim() + "',"
                          + "'" + tb_dl_name.Text.Trim() + "',"
                          + "'" + DateTime.Now + "',"
                          + "'" + DateTime.Now + "',"
                          + "'" + tb_otherInfo.Text.Trim() + "')");
            rwh.RunSqlStr("CREATE TABLE " + tb_dl_name.Text.Trim()
                          + " (_id AUTOINCREMENT PRIMARY KEY , " +
                          "eName varchar(255) NOT NULL ," +
                          "eWeihao varchar(255), eCount SmallInt)");
            Close();
        }
Beispiel #2
0
        //向pcb的元件列表中添加新的元件
        internal void AddEleMentToPcb(string selectElementName)
        {
            if (selectElementName == "")
            {
                return;
            }
            var pName = lb_pcb.SelectedItem.ToString();
            var eName = selectElementName;

            //首先查询数据库中是否有重复的元件
            var dr = rwh.OpenSelectSqlStr("select * from " + pName + " where eName = '" + eName + "'");

            if (dr != null)
            {
                MessageBox.Show("此元件已添加");
                return;
            }
            rwh.Close();
            rwh.RunSqlStr(" insert into " + pName + " (eName ,eWeihao,eCount) "
                          + "values( '" + eName + "', '未知',0)");
            UpDatePcbElementPanel();
        }