Beispiel #1
0
        public Form1()
        {
            //设置测试或者实际的运用环境。
            if (IsLocal)
            {
                filePath =
                    "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = "
                    + AppDomain.CurrentDomain.BaseDirectory + "XhElementManageLib.mdb";
            }
            else
            {
                filePath =
                    "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = "
                    + "D:\\Code\\Rider\\XhElementManageTool\\XhElementManageTool\\XhElementManageLib.mdb";
            }

            //初始化一下我们的rwh,以后就可以用了
            rwh = new AmumuReadAndWriteHelper(filePath);

            InitializeComponent();

            elementSelectControl1.setRwh(rwh);
            elementSelectControl1.Init();
            //绑定委托与事件,也就是同时更新Tab1中的Element数据
            elementSelectControl1.SelectChange += SelectValueChange;

            //这是啥啊
            WhatIsThis();

            //默认刚开始的时候也会更新一次PCBBox;
            UpDatePcbBox();
        }
Beispiel #2
0
 public SelectPcbElement(Form1 form1, AmumuReadAndWriteHelper rwh)
 {
     _f       = form1;
     this.rwh = rwh;
     InitializeComponent();
     //绑定委托
     elementSelectControl1.setRwh(rwh);
     elementSelectControl1.Init();
     elementSelectControl1.DbClickElement += MyDbClick;
 }
Beispiel #3
0
 public void setRwh(AmumuReadAndWriteHelper rwh)
 {
     this.rwh = rwh;
 }
Beispiel #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();
        }
Beispiel #5
0
 public Dialog(AmumuReadAndWriteHelper rwh)
 {
     this.rwh = rwh;
     InitializeComponent();
 }