Ejemplo n.º 1
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     m_connectToAccess = new ConnectToAccess(deFaultpath, "CavityLibrary");
     if (this.groBcavitydim.Enabled == true)
     {
         foreach (Control ctr in this.groBcavitydim.Controls)       //输入孔的尺寸参数
         {
             if (ctr is TextBox)
             {
                 //TextBox ctr1=new ctr as TextBox;
                 if ((ctr as TextBox).Text.Length != 0)
                 {
                     string sqlupdate = "update " + indexname + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codingname + "'";
                     if (m_connectToAccess.UpdateInformation(sqlupdate))
                     {
                     }
                     ;
                 }
             }
         }
         foreach (Control ctr in this.groBThread.Controls)           //输入螺纹的参数信息
         {
             if (ctr is TextBox)
             {
                 //TextBox ctr1=new ctr as TextBox;
                 if ((ctr as TextBox).Text.Length != 0)
                 {
                     string sqlupdate = "update " + indexname + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codingname + "'";
                     if (m_connectToAccess.UpdateInformation(sqlupdate))
                     {
                     }
                     ;
                 }
             }
         }
     }
     if (groBcarvalve.Enabled == true)
     {
         foreach (Control ctr in this.groBcarvalve.Controls)        //输入油孔的参数信息
         {
             if (ctr is TextBox)
             {
                 //TextBox ctr1=new ctr as TextBox;
                 if ((ctr as TextBox).Text.Length != 0)
                 {
                     string sqlupdate = "update " + indexname + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codingname + "'";
                     if (m_connectToAccess.UpdateInformation(sqlupdate))
                     {
                     }
                     ;
                 }
             }
         }
     }
     if (groBfacedim.Enabled == true)
     {
     }
     MessageBox.Show("修改参数成功!");
 }
        private void AddNewGrouFaceDim()//创建一个新的油孔位置信息表
        {
            string sqlcreate = @"CREATE TABLE " + codenumber + "Footprint(ID AUTOINCREMENT,油孔名称 TEXT(50),Dia" + codename + " TEXT(50),X" + codename + " TEXT(50),Y" + codename + " TEXT(50))";

            m_connectToAccess.CreateTable(sqlcreate);
            foreach (DataGridViewRow dr in dataGridViewdim.Rows)
            {
                dataGridViewdim.AllowUserToAddRows = false;
                string sqlupdate1 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "dmax='" + dr.Cells[1].Value.ToString() + "' where 编码 ='" + codename + "'";
                if (m_connectToAccess.UpdateInformation(sqlupdate1))
                {
                }
                ;
                string sqlupdate2 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "coordX='" + dr.Cells[2].Value.ToString() + "' where 编码 ='" + codename + "'";
                if (m_connectToAccess.UpdateInformation(sqlupdate2))
                {
                }
                ;
                string sqlupdate3 = "update " + IndexName + " set " + dr.Cells[0].Value.ToString() + "coordY='" + dr.Cells[3].Value.ToString() + "' where 编码 ='" + codename + "'";
                if (m_connectToAccess.UpdateInformation(sqlupdate3))
                {
                }
                ;
                string sqlinsert = "insert into " + codenumber + "Footprint(油孔名称,Dia" + codename + ",X" + codename + ",Y" + codename + ") values('" + dr.Cells[0].Value.ToString() + "','" + dr.Cells[1].Value.ToString() + "','" + dr.Cells[2].Value.ToString() + "','" + dr.Cells[3].Value.ToString() + "')";
                if (m_connectToAccess.InsertInformation(sqlinsert))
                {
                    MessageBox.Show("坐标位置信息添加成功");
                }
            }
        }
Ejemplo n.º 3
0
        private void EditPortNet(string oldNet, string newNet, string portName)
        {
            m_connectToAccess = new ConnectToAccess(deFaultpath, "项目数据库");
            string update = "update NETList set " + oldNet + "='' where PortName ='" + portName + "'";

            if (m_connectToAccess.UpdateInformation(update))
            {
            }
            ;
            string updatenew = "update NETList set " + newNet + "='" + portName + "' where PortName ='" + portName + "'";

            if (m_connectToAccess.UpdateInformation(updatenew))
            {
            }
            ;
        }
        private void btnsave_Click(object sender, EventArgs e)
        {
            IndexName  = cmbIndexName.Text.ToString();
            codenumber = combcodenumber.Text.ToString();
            codename   = tb1.Text.ToString();
            string sql = "insert into " + IndexName + "(索引编号,编码) values('" + codenumber + "','" + codename + "')";

            m_connectToAccess = new ConnectToAccess(deFaultpath, "CavityLibrary");
            if (m_connectToAccess.InsertInformation(sql))
            {
                foreach (Control ctr in this.groBcavitydim.Controls)       //输入孔的尺寸参数
                {
                    if (ctr is TextBox)
                    {
                        //TextBox ctr1=new ctr as TextBox;
                        if ((ctr as TextBox).Text.Length != 0)
                        {
                            string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'";
                            if (m_connectToAccess.UpdateInformation(sqlupdate))
                            {
                            }
                            ;
                        }
                    }
                }
                foreach (Control ctr in this.groBThread.Controls)           //输入螺纹的参数信息
                {
                    if (ctr is TextBox)
                    {
                        //TextBox ctr1=new ctr as TextBox;
                        if ((ctr as TextBox).Text.Length != 0)
                        {
                            string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'";
                            if (m_connectToAccess.UpdateInformation(sqlupdate))
                            {
                            }
                            ;
                        }
                    }
                }
                foreach (Control ctr in this.groBcarvalve.Controls)        //输入油孔的参数信息
                {
                    if (ctr is TextBox)
                    {
                        //TextBox ctr1=new ctr as TextBox;
                        if ((ctr as TextBox).Text.Length != 0)
                        {
                            string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'";
                            if (m_connectToAccess.UpdateInformation(sqlupdate))
                            {
                            }
                            ;
                        }
                    }
                }
                if (groBfacedim.Enabled == true)                             //输入安装面的油孔位置信息
                {
                    int i = 0;
                    while (i < combcodenumber.Items.Count && combcodenumber.Text.ToString() != combcodenumber.Items[i].ToString())
                    {
                        i++;
                    }
                    if (combcodenumber.Text.ToString() == combcodenumber.Items[i].ToString())
                    {
                        EditGrouFaceDim();
                    }
                    else
                    {
                        AddNewGrouFaceDim();
                    }
                }
                MessageBox.Show("插入新元件成功");
            }
        }