Пример #1
0
 //读写器录入
 public int insertWriterReader(WriterReaderBean bean, Window win)
 {
     try
     {
         return(MyTransaction.WriterReader(bean, win));
     }
     catch (Exception e)
     {
         e.GetBaseException();
         return(BaseRequest.SYSTEM_EXCEPTION);
     }
 }
Пример #2
0
 private void Submit_Add_Click(object sender, RoutedEventArgs e)
 {
     ComboBoxItem antennaNum = (ComboBoxItem)this.antennaNum.SelectedItem;
     ComboBoxItem typeItem = (ComboBoxItem)this.type.SelectedItem;
     ComboBoxItem room = (ComboBoxItem)this.roomBox.SelectedItem;
     if (this.number.Text.Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "非法操作!", MsgImage.Error);
         return;
     }
     if (this.name.Text.Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请输入读写器名称!", MsgImage.Error);
         return;
     }
     if (this.ip.Text.Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请输入读写器IP!", MsgImage.Error);
         return;
     }
     if (this.port.Text.Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请输入读写器端口!", MsgImage.Error);
         return;
     }
     if ("".Equals(antennaNum.Tag.ToString()))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请选择读写器支持天线数目!", MsgImage.Error);
         return;
     }
     if ("".Equals(typeItem.Tag.ToString()))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请选择读写器的类别!", MsgImage.Error);
         return;
     }
     if (this.time.Text.Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请填写读写器扫描时间间隔!", MsgImage.Error);
         return;
     }
     if (room.Tag.ToString().Equals(""))
     {
         JXMessageBox.Show(Window.GetWindow(this), "请选择所在机房!", MsgImage.Error);
         return;
     }
     WriterReaderBean bean = new WriterReaderBean();
     bean.Id = int.Parse(this.number.Text.ToString());
     bean.Number = int.Parse(this.number.Text.ToString());
     bean.Name = this.name.Text;
     bean.Ip = this.ip.Text;
     bean.Port = int.Parse(this.port.Text);
     bean.AntennaSum = int.Parse(antennaNum.Tag.ToString());
     bean.Type = int.Parse(typeItem.Tag.ToString());
     bean.SweepTime = int.Parse(this.time.Text);
     bean.RoomId = int.Parse(room.Tag.ToString());
     bean.EpcCode = this.numberStr.Text;
     EquipmentClass ec = new EquipmentClass();
     int state = ec.insertWriterReader(bean,this);
     if (state == BaseRequest.SUCCESS)
     {
         EquipmentClass equitment = new EquipmentClass();
         DataSet set = equitment.comingEquipment();
         NewEquipment equipments = DeviceMigrationsFactory.NewEquipment;
         DeviceMigrationsFactory.NewEquipment.page.ShowPages(DeviceMigrationsFactory.NewEquipment.comingGrild, set, BaseRequest.PAGE_SIZE);
       
         JXMessageBox.Show(Window.GetWindow(this), "已成功录入读写器信息!", MsgImage.Success);
         this.Close();
     }
     else
     {
         JXMessageBox.Show(Window.GetWindow(this), "未知错误,请联系管理员!", MsgImage.Error);
     }
 }
Пример #3
0
    //读写器天线录入
    public static int WriterReader(WriterReaderBean bean,Window win)
    {
       ReaderAndWriterConnection _Connection = new ReaderAndWriterConnection();
        MySqlConnection conn = new MySqlConnection(MySqlHelper.Conn);
            conn.Open();
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            MySqlTransaction tx = conn.BeginTransaction();
            cmd.Transaction = tx;
        try
        {
            //读写器连接
            int state = _Connection.Connection();
            int _WState = _Connection.WritertEPC(bean.EpcCode, win);
            if (state == BaseRequest.SUCCESS && _WState == BaseRequest.SUCCESS)
            {
                //把16进制字符串转换成ushout数组
                string date = Convert.ToDateTime(DateTime.Now).ToString(BaseRequest.DATE_TIME_FORMAT);
                string sql = "INSERT INTO reader_writer(READER_WRITER_ID,NUMBER,NAME,IP,PORT,ANTENNA_SUM,TYPE,SWEEP_TIME,CREATE_USER_ID,CREATE_TIME,ROOM_ID)" +
                            "VALUES(" + @bean.Id + ",'" + @bean.EpcCode + "','" + @bean.Name + "','" + @bean.Ip + "'," + @bean.Port + "," + @bean.AntennaSum + "," + @bean.Type + "," +
                            [email protected] + "," + @Session.UserId + ",'" + @date + "'," + @bean.RoomId + ")";
                MySqlParameter[] parameters =
                {
                    new MySqlParameter("@bean.Id",bean.Id),
                    new MySqlParameter("@bean.EpcCode",bean.EpcCode),
                    new MySqlParameter("@bean.Name",bean.Name),
                    new MySqlParameter("@bean.Ip",bean.Ip),
                    new MySqlParameter("@bean.Port",bean.Port),
                    new MySqlParameter("@bean.AntennaSum",bean.AntennaSum),
                    new MySqlParameter("@bean.Type",bean.Type),
                    new MySqlParameter("@bean.SweepTime",bean.SweepTime),
                    new MySqlParameter("@Session.UserId",Session.UserId),
                    new MySqlParameter("@date",date),
                    new MySqlParameter("@bean.RoomId",bean.RoomId),
                };
                cmd.CommandText = sql;
                if (parameters != null)
                {
                    foreach (MySqlParameter parm in parameters)
                        cmd.Parameters.Add(parm);
                }

                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
                //string InSql = "INSERT INTO work_order(ID,STATUS,USER_ID,DATE_TIME) VALUES(" + @bean.Id + "," + @BaseRequest.INPUT_STATUS + "," +
                //[email protected] + ",'" + @date + "')";
                //MySqlParameter[] parametersIt =
                //    {
                //        new MySqlParameter("@bean.Id",bean.Id),
                //        new MySqlParameter("@BaseRequest.INPUT_STATUS",BaseRequest.INPUT_STATUS),
                //        new MySqlParameter("@Session.UserId",Session.UserId),
                //        new MySqlParameter("@date",date),
                //    };
                //cmd.CommandText = InSql;
                //if (parametersIt != null)
                //{
                //    foreach (MySqlParameter parm in parameters)
                //        cmd.Parameters.Add(parm);
                //}
                //cmd.ExecuteNonQuery();
                //cmd.Parameters.Clear();

                for (int i = 1; i < (bean.AntennaSum + 1); i++)
                {
                    string _sql = "INSERT INTO antenna (ID_CODE,READER_WRITER_ID) VALUES(" + @i + "," + @bean.Id + ") ";
                    MySqlParameter[] _Parameters =
                    {
                            new MySqlParameter("@i",i),
                        new MySqlParameter("@bean.Id",bean.Id),
                    };
                    cmd.CommandText = _sql;
                    if (_Parameters != null)
                    {
                        foreach (MySqlParameter parm in parameters)
                            cmd.Parameters.Add(parm);
                    }
                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();
                }
                tx.Commit();
                return BaseRequest.SUCCESS;
            }
            else
            {
                return BaseRequest.SYSTEM_EXCEPTION;
            }
        }
        catch (Exception e)
        {
            tx.Rollback();
            conn.Close();
            e.GetBaseException();
            return BaseRequest.SYSTEM_EXCEPTION;
        }
    }
Пример #4
0
 //读写器录入
 public int insertWriterReader(WriterReaderBean bean,Window win)
 {
     try
     {
         return MyTransaction.WriterReader(bean,win);
     }
     catch (Exception e)
     {
         e.GetBaseException();
         return BaseRequest.SYSTEM_EXCEPTION;
     }
 }