Exemple #1
0
        //遥测新增
        private void tb_ycadd_Click(object sender, EventArgs e)
        {
            if ((m_obj.equtype.ToString()).StartsWith("P_"))
            {
                if (cb_ycarea.SelectedItem == null)
                {
                    MessageBox.Show("请选择分区");
                    return;
                }
                YCExt yccfg = new YCExt();
                yccfg.AreaID = (int)cb_ykarea.SelectedValue;
                yccfg.Order  = Byklist.Count;
                yccfg.EquID  = m_obj.equ.EquID;
                string sql = string.Format("insert into yc(equid,ycfield)values('{0}','{1}');SELECT @@Identity", yccfg.EquID, m_obj.equ.EquTypeID);
                int    i   = DBHelper.ExcuteSql(sql);
                if (i > -1)
                {
                    yccfg.YCID = i;

                    string sql1 = string.Format("insert into yc_cfg(equid,`order`,areaid,ycid)values('{0}',{1},{2},{3});SELECT @@Identity", yccfg.EquID, Byclist.Count, yccfg.AreaID, yccfg.YCID);
                    int    j    = DBHelper.ExcuteSql(sql1);
                    if (j > -1)
                    {
                        yccfg.ID = i;
                        Byclist.Add(yccfg);
                    }
                    else
                    {
                        DBHelper.ExcuteTransactionSql("delete from yc where YCID=" + i);
                    }
                }
            }
        }
Exemple #2
0
 //修改遥测点位
 private void dataGridView3_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (cb_ycarea.SelectedItem == null)
         {
             MessageBox.Show("请选择分区");
             return;
         }
         YCExt  ycext = dataGridView3.CurrentRow.DataBoundItem as YCExt;
         string sql   = string.Format("update yc set ycfun={0} where(ycid={1})", ycext.YCFun, ycext.YCID);
         int    i     = DBHelper.ExcuteTransactionSql(sql);
         if (i > 0)
         {
             string sql1 = string.Format("update yc_cfg set addrandbit='{0}',areaid={1},`order`={2} where(id={3})", ycext.AddrAndBit, ycext.AreaID, ycext.Order, ycext.ID);;
             if (!checkBox1.Checked)
             {
                 sql1 = string.Format("update yc_cfg set addrandbit='{0}',areaid={1},`order`={2} where(id={3})", Int2Hex(ycext.AddrAndBit), ycext.AreaID, ycext.Order, ycext.ID);
             }
             int j = DBHelper.ExcuteTransactionSql(sql1);
         }
     }
     catch (Exception ex)
     {
         Log.WriteLog(ex);
     }
 }