示例#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();
        }
示例#2
0
 public void LoadComboBoxData()
 {
     string[] ooo = { "eType", "eFacturer", "ePosition" };
     SelectList = new List <List <string> >();
     foreach (var o in ooo)
     {
         var dr   = rwh.OpenSelectSqlStr("select " + o + " from Element group by " + o + " order by " + o);
         var list = new List <string> {
             "全部"
         };
         while (dr != null && dr.Read())
         {
             list.Add((string)dr[0]);
         }
         SelectList.Add(list);
     }
     cb_type.DataSource     = SelectList[0];
     cb_facturer.DataSource = SelectList[1];
     cb_position.DataSource = SelectList[2];
     cb_type.Update();
     cb_facturer.Update();
     cb_position.Update();
     rwh.Close();
 }
示例#3
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();
        }
示例#4
0
        //更新PCB元件的列表;
        private void lb_pcb_SelectedValueChanged(object sender, EventArgs e)
        {
            var s = 0;

            Console.Out.WriteLine("第三页 :" + s);
            var   zongCount = 0;
            float zongJiaGe = 0;

            p_pcbEle.Controls.Clear();
            //获得当前选中的pName
            var pName = lb_pcb.SelectedItem.ToString();
            //查找表数据
            var dr = rwh.OpenSelectSqlStr("select * from " + pName);

            if (dr == null)
            {
                return;
            }
            //TODO 非常诡异
            //dr.Read()有时true,有时false.
            //当PCB表中出现在元件表中不存在的元件时,(这种情况是存在的)
            //pcb表的载入就会截止到这个不存在的元件上而不会继续加载下面还是存在的元件
            //诡异
            //还记得那个会联动的list么??????
            //我猜测在下一次dr.Read()的时候其实读取的是dr22的Read值。
            //因为他们都引用过rwh.OpenSelectSqlStr
            //果然是这样
            var rwh22 = new AmumuReadAndWriteHelper(filePath);

            while (dr.Read())
            {
                //查找是否在元件库中有着这个元件的价格
                var   dr22    = rwh22.OpenSelectSqlStr("select ePrice from Element where eName ='" + dr["eName"] + "'");
                var   price   = "未知";
                float zongJia = 0;
                if (dr22 != null)
                {
                    dr22.Read();
                    price   = dr22[0].ToString();
                    zongJia = float.Parse(price) * int.Parse(dr["eCount"].ToString());
                    dr22.Dispose();
                }
                //构造新的PCBElementControl
                var pe = new PCBElementControl(
                    dr["eName"].ToString(),
                    dr["eWeihao"].ToString(),
                    dr["eCount"].ToString(),
                    price,
                    zongJia.ToString())
                {
                    Name     = "pe" + s,
                    Location = new Point(0, 30 * s)
                };
                p_pcbEle.Controls.Add(pe);
                //来点委托
                pe.ClickEvent += EventPcbElement;
                zongCount     += int.Parse(dr["eCount"].ToString());
                zongJiaGe     += zongJia;
                s++;
            }
            dr = rwh.OpenSelectSqlStr("select OtherInfo from PCBs where pName ='" + pName + "'");
            if (dr != null)
            {
                dr.Read();
                tb_pcb_info.Text = dr[0].ToString();
            }
            l_zongCount.Text = zongCount.ToString();
            l_zongJiaGe.Text = zongJiaGe.ToString();
            rwh.Close();
            rwh22.Close();
            dr.Dispose();
        }