예제 #1
0
        //
        // GET: /en/Reader/
        public ActionResult Index()
        {
            Db_Connection dbconn = new Db_Connection();
            Utility       util   = new Utility();

            try
            {
                dbconn.openConnection();
                string strSQL = "";
                strSQL = @"SELECT ID,GID,READERMODEL,READERNAME,PORT,IP,TIME,LOCATION
                         FROM VREADER ORDER BY READERNAME ASC";


                SqlCommand        cmd    = new SqlCommand(strSQL, dbconn.DbConn);
                SqlDataReader     dr     = cmd.ExecuteReader();
                List <mdlReaders> record = new List <mdlReaders>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        mdlReaders list = new mdlReaders();
                        list.ID          = dr["ID"].ToString();
                        list.GID         = dr["GID"].ToString();
                        list.READERNAME  = dr["READERNAME"].ToString();
                        list.READERMODEL = dr["READERMODEL"].ToString();
                        list.LOCATION    = dr["LOCATION"].ToString();
                        list.PORT        = dr["PORT"].ToString();
                        list.IP          = dr["IP"].ToString();
                        list.TIME        = dr["TIME"].ToString();
                        record.Add(list);
                    }
                }
                dr.Dispose();
                cmd.Dispose();
                dbconn.closeConnection();
                return(View(record));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }
예제 #2
0
        public ActionResult edit(string id, string gid)
        {
            Populate DropDown = new Populate();
            List <SelectListItem> location_combo  = new List <SelectListItem>();
            List <SelectListItem> interval_combo  = new List <SelectListItem>();
            List <SelectListItem> rfidmodel_combo = new List <SelectListItem>();

            interval_combo  = DropDown.getTimeInterval();
            rfidmodel_combo = DropDown.getReaderModel();
            location_combo  = DropDown.getLocation();

            Db_Connection dbconn = new Db_Connection();

            try
            {
                dbconn.openConnection();



                string     strSQL = @"SELECT READERMODEL,READERNAME,PORT,IP,TIME,LOCATION FROM VREADER WHERE ID=@ID AND GID=@GID";
                SqlCommand cmd    = new SqlCommand(strSQL, dbconn.DbConn);

                cmd.Parameters.Add("ID", SqlDbType.VarChar).Value  = id;
                cmd.Parameters.Add("GID", SqlDbType.VarChar).Value = gid;
                SqlDataReader dr     = cmd.ExecuteReader();
                mdlReaders    record = new mdlReaders();
                record.ID  = id;
                record.GID = gid;
                if (dr.HasRows)
                {
                    dr.Read();
                    record.ID          = id;
                    record.GID         = gid;
                    record.READERNAME  = dr["READERNAME"].ToString();
                    record.LOCATION    = dr["LOCATION"].ToString();
                    record.PORT        = dr["PORT"].ToString();
                    record.IP          = dr["IP"].ToString();
                    record.READERMODEL = dr["READERMODEL"].ToString();
                    record.TIME        = dr["TIME"].ToString();
                }

                foreach (SelectListItem item in location_combo)
                {
                    if (item.Text.ToUpper() == record.LOCATION.ToUpper())
                    {
                        item.Selected = true;
                    }
                }
                foreach (SelectListItem item in interval_combo)
                {
                    if (item.Value == record.TIME)
                    {
                        item.Selected = true;
                    }
                }
                foreach (SelectListItem item in rfidmodel_combo)
                {
                    if (item.Text.ToUpper() == record.READERMODEL.ToUpper())
                    {
                        item.Selected = true;
                    }
                }

                ViewData["location"]  = location_combo;
                ViewData["interval"]  = interval_combo;
                ViewData["rfidmodel"] = rfidmodel_combo;


                return(PartialView(record));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }