示例#1
0
        private void buttonSaveNew_Click(object sender, EventArgs e)
        {
            //frmFixAdd frmsub = new frmFixAdd();
            //frmsub.buttonPairSearch.Enabled = true;

            try
            {
                string  CusID        = textBoxClientID.Text.Trim();
                string  FatherId     = textBoxFixMaiNId.Text.Trim();
                string  fittingName  = textBoxProductName.Text.Trim();
                string  typeId       = comboBoxTypeID.Text.Trim();
                string  TypeName     = textBoxTypeNAME.Text.Trim();
                string  unit         = textBoxUnit.Text.Trim();
                string  materialID   = comboBoxMaterialID.Text.Trim();
                string  materialName = textBoxMaterialName.Text.Trim();
                string  Flength      = textBoxLength.Text.Trim();
                string  Fwide        = textBoxWide.Text.Trim();
                string  Fheight      = textBoxHeight.Text.Trim();
                string  quantity     = textBoxQuantity.Text.Trim();
                string  memo         = textBoxMemo.Text.Trim();
                string  price        = textBoxPrice.Text.Trim();
                Boolean yinshua      = checkBox1.Checked;
                Boolean zhanjiao     = checkBox2.Checked;
                Boolean dading       = checkBox3.Checked;
                //string sql = "insert into T_fixbox (cusID,productname,producttype,materialname,plength,pwide,pheight,unit,quantity,price,memo) values
                string      MidQuery    = "select ID from T_MATERIAL where materialid ='" + materialID + "'";
                databaseexe databaseexe = new databaseexe();
                string      id          = databaseexe.getTopselect(MidQuery, "ID");
                string      sql         = "insert into T_fixpro (CusId,productNAME,typeid,producttype,materialId,MaterialName,plength,pwide,pheight,unit,quantity,fatherid,memo,price) values ('" + CusID + "','" + fittingName + "','" + typeId + "','" + TypeName + "','" + id + "','" + materialName + "','" + Flength + "','" + Fwide + "','" + Fheight + "','" + unit + "','" + quantity + "','" + FatherId + "','" + memo + "','" + price + "')";


                /*string sql = "update T_Customer set CusShort='" + CusShort + "',CusName='" + CusName + "',CusTelephone='" + CusTel + "',CusFax='" + CusFax + "',CusAdress='" + CusAdress + "',CusPerson='" + CusPerson + "',CusBank='" + CusBank + "',CusAccount='" + CusAccount + "',CusMemo='" + CusMemo + "'where CusId='" + CusId + "'";*/
                dbexe.sqlcmd(sql);
                string      sql1         = "select  top 1 id from T_fixpro order by id DESC ";
                databaseexe databaseexe2 = new databaseexe();
                string      newid        = databaseexe2.getTopid(sql1);



                if (yinshua.Equals(true))
                {
                    string sql2 = "update T_fixpro set yingshua ='true' where id='" + newid + "'";
                    dbexe.sqlcmd(sql2);
                }
                if (zhanjiao.Equals(true))
                {
                    string sql3 = "update T_fixpro set zhanjiao ='true' where id='" + newid + "'";
                    dbexe.sqlcmd(sql3);
                }
                if (dading.Equals(true))
                {
                    string sql4 = "update T_fixpro set dading ='true' where id='" + newid + "'";
                    dbexe.sqlcmd(sql4);
                }
                MessageBox.Show("数据保存成功!");

                string      sql5         = "select  top 1 id from T_fixpro order by id DESC ";
                databaseexe databaseexe3 = new databaseexe();
                textBoxFixId.Text = databaseexe2.getTopid(sql5);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }